Skip to content

Commit

Permalink
Merge c2e6f22 into d40b14e
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Lee committed Sep 22, 2019
2 parents d40b14e + c2e6f22 commit 98e76cf
Show file tree
Hide file tree
Showing 12 changed files with 2,042 additions and 320 deletions.
13 changes: 12 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
// {
// "presets": ["@babel/preset-env", "@babel/preset-react"],
// "plugins": ["istanbul"]
// }

{
"presets": ["@babel/preset-env", "@babel/preset-react"]
"presets": ["@babel/preset-react"],
"env": {
"test": {
"plugins": ["istanbul"]
}
},
"plugins": ["transform-class-properties"]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ typings/

# production
/build
/dist

# misc
.DS_Store
Expand Down
39 changes: 28 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,42 @@ cache:
directories:
- ~/.npm
- ~/.cache
override:
- npm ci
- npm run cy:verify

defaults: &defaults
script:
# ## print all Travis environment variables for debugging
# - $(npm bin)/print-env TRAVIS
- npm run start:ci &
- npm run cy:run
# after all tests finish running we need
# to kill all background jobs (like "npm start &")
- npm run cy:test
- npm run report:text
- npm run coveralls
- kill $(jobs -p) || true

jobs:
include:
# we have multiple jobs to execute using just a single stage
# but we can pass group name via environment variable to Cypress test runner
- stage: test
env:
- STAGE_NAME="1x-electron on Travis CI"
<<: *defaults
# # see https://github.com/cypress-io/circleci-orb
# version: 2.1
# orbs:
# cypress: cypress-io/cypress@1
# workflows:
# build:
# jobs:
# - cypress/run:
# # we need to start the web application
# start: npm start
# command: NODE_ENV=test npm run cypress:run
# # there are no jobs to follow this one
# # so no need to save the workspace files (saves time)
# no-workspace: true
# post-steps:
# # store the created coverage report folder
# # you can click on it in the CircleCI UI
# # to see live static HTML site
# - store_artifacts:
# path: coverage
# # show code coverage numbers
# - run: npm run report:coverage:text
# # send code coverage to coveralls.io
# # https://coveralls.io/github/cypress-io/cypress-example-todomvc-redux
# - run: npm run coveralls
2 changes: 2 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"baseUrl": "http://localhost:1234",
"ignoreTestFiles": ["**/*.snap", "**/__snapshot__/*"],
"video": false
}
16 changes: 16 additions & 0 deletions cypress/integration/Ex-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// <reference types="cypress" />

import { setMockState } from '../fixtures/default'

describe('Import Game', () => {
beforeEach(() => {
setMockState()
cy.visit('/')
})

it('Example.', () => {
cy.contains('Market').click()
cy.contains('Planets').click()
cy.contains('Ship').click()
})
})
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/// <reference types="cypress" />

import { setMockState } from '../fixtures/default'

describe('Export Game', () => {
beforeEach(() => {
setMockState()
cy.visit('http://localhost:3000')
cy.visit('/')
})

it('Should export the game state to a JSON file.', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
/// <reference types="cypress" />

import { setMockState } from '../fixtures/default'

describe('Import Game', () => {
beforeEach(() => {
setMockState()
cy.visit('http://localhost:3000')
cy.visit('/')
})

it('Should import the game state from a JSON file.', () => {
Expand Down
4 changes: 4 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
on('task', require('@cypress/code-coverage/task'))
on('file:preprocessor', require('@cypress/code-coverage/use-babelrc'))

// return config
}
1 change: 1 addition & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

// Import commands.js using ES2015 syntax:
import './commands'
import '@cypress/code-coverage/support'

// Alternatively you can use CommonJS syntax:
// require('./commands')
26 changes: 18 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,38 @@
"uuid": "^3.3.3"
},
"devDependencies": {
"@babel/core": "7.5.5",
"@babel/preset-react": "^7.0.0",
"@cypress/code-coverage": "^1.10.1",
"@testing-library/dom": "^6.1.0",
"@testing-library/react": "^9.1.3",
"babel-plugin-istanbul": "^5.2.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"coveralls": "^3.0.6",
"cross-env": "^6.0.0",
"cypress": "^3.4.1",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"istanbul-lib-coverage": "^2.0.5",
"jsdom": "^15.1.1",
"jsdom-global": "^3.0.2",
"nyc": "^14.1.1",
"parcel-bundler": "^1.12.3",
"redux-mock-store": "^1.5.3",
"wait-on": "^3.3.0"
"rimraf": "^3.0.0",
"start-server-and-test": "^1.10.2"
},
"scripts": {
"start": "react-scripts start",
"dev": "react scripts start",
"start-server": "cross-env NODE_ENV=test parcel serve --no-cache test/index.html",
"build": "react-scripts build",
"eject": "react-scripts eject",
"test": "react-scripts test",
"test:coverage": "yarn test --coverage --watchAll=false --collectCoverageFrom=src/components/**/* --collectCoverageFrom=src/views/**/* --collectCoverageFrom=src/util.js",
"test:coveralls": "yarn test --coverage --watchAll=false --collectCoverageFrom=src/components/**/* --collectCoverageFrom=src/views/**/* --collectCoverageFrom=src/util.js --coverageReporters=text-lcov | coveralls",
"cy:open": "cypress open",
"cy:verify": "cypress verify",
"cy:run": "cypress run",
"start:ci": "yarn start & wait-on http://localhost:3000"
"cy:test": "yarn cleanup && start-server-and-test start-server 1234 cy:run",
"cleanup": "rimraf .nyc_output && rimraf coverage && rimraf dist && rimraf build",
"report:text": "nyc report --reporter=text",
"report": "parcel serve --no-cache coverage/lcov-report/index.html --open",
"coveralls": "cat coverage/lcov.info | coveralls"
},
"eslintConfig": {
"extends": "react-app"
Expand Down
13 changes: 13 additions & 0 deletions test/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Hermes</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script src="../src/index.js"></script>
</body>
</html>
Loading

0 comments on commit 98e76cf

Please sign in to comment.