Browse Source

test(runner): reorganise test suites

Reorganise test suite so that unit tests are cleanly separate from e2e
tests. Update tests to make better use of our custom module resolves.
renovate/lint-staged-8.x
Tom Kirkpatrick 6 years ago
parent
commit
d4c51e9e3d
No known key found for this signature in database GPG Key ID: 72203A8EC5967EA8
  1. 2
      .flowconfig
  2. 16
      package.json
  3. 5
      test/example.js
  4. 14
      test/runTests.js
  5. 4
      test/unit/components/AnimatedCheckmark.spec.js
  6. 6
      test/unit/components/CryptoIcon.spec.js
  7. 4
      test/unit/components/CurrencyIcon.spec.js
  8. 6
      test/unit/components/Form.spec.js
  9. 2
      test/unit/components/Form/Pay.spec.js
  10. 2
      test/unit/components/Form/Request.spec.js
  11. 4
      test/unit/components/LoadingBolt.spec.js
  12. 0
      test/unit/reducers/__snapshots__/balance.spec.js.snap
  13. 0
      test/unit/reducers/__snapshots__/channels.spec.js.snap
  14. 0
      test/unit/reducers/__snapshots__/form.spec.js.snap
  15. 0
      test/unit/reducers/__snapshots__/info.spec.js.snap
  16. 0
      test/unit/reducers/__snapshots__/invoice.spec.js.snap
  17. 0
      test/unit/reducers/__snapshots__/payment.spec.js.snap
  18. 0
      test/unit/reducers/__snapshots__/peers.spec.js.snap
  19. 0
      test/unit/reducers/__snapshots__/ticker.spec.js.snap
  20. 2
      test/unit/reducers/balance.spec.js
  21. 2
      test/unit/reducers/channels.spec.js
  22. 2
      test/unit/reducers/form.spec.js
  23. 2
      test/unit/reducers/info.spec.js
  24. 2
      test/unit/reducers/invoice.spec.js
  25. 2
      test/unit/reducers/payment.spec.js
  26. 2
      test/unit/reducers/peers.spec.js
  27. 2
      test/unit/reducers/ticker.spec.js
  28. 0
      test/unit/utils/usd.spec.js

2
.flowconfig

@ -28,6 +28,7 @@ module.name_mapper.extension='scss' -> '<PROJECT_ROOT>/internals/flow/CSSModule.
# Map stylesheets to csssmodule tyoe def
module.name_mapper.extension='png' -> '<PROJECT_ROOT>/internals/flow/WebpackAsset.js.flow'
module.name_mapper.extension='jpg' -> '<PROJECT_ROOT>/internals/flow/WebpackAsset.js.flow'
module.name_mapper.extension='svg' -> '<PROJECT_ROOT>/internals/flow/WebpackAsset.js.flow'
# Map webpack resolved module imports to the app directory
# Example: components/Foo -> `<project_root>/app/components/Foo`
@ -37,3 +38,4 @@ module.name_mapper='^lib/\(.*\)$' -> '<PROJECT_ROOT>/app/lib/\1'
module.name_mapper='^reducers/\(.*\)$' -> '<PROJECT_ROOT>/app/reducers/\1'
module.name_mapper='^routes/\(.*\)$' -> '<PROJECT_ROOT>/app/routes/\1'
module.name_mapper='^store/\(.*\)$' -> '<PROJECT_ROOT>/app/store/\1'
module.name_mapper='^icons/\(.*\)$' -> '<PROJECT_ROOT>/app/icons/\1'

16
package.json

@ -9,7 +9,7 @@
"build-main": "webpack --require babel-register --config webpack.config.main.prod.js --progress",
"build-renderer": "webpack --require babel-register --config webpack.config.renderer.prod.js --progress",
"build-grpc": "rimraf app/node_modules/grpc/src/node && build install-app-deps",
"clean": "rimraf node_modules app/node_modules dll app/dist",
"clean": "rimraf node_modules app/node_modules dll app/dist coverage .eslintcache",
"coverage": "open coverage/index.html",
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"dev": "cross-env START_HOT=1 npm run start-renderer-dev",
@ -33,10 +33,11 @@
"start": "cross-env NODE_ENV=production electron ./app/",
"start-main-dev": "cross-env HOT=1 NODE_ENV=development electron -r babel-register ./app/main.dev",
"start-renderer-dev": "node --trace-warnings -r babel-register ./node_modules/webpack-serve/lib/cli.js --config webpack.config.renderer.dev.js",
"test": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 node --trace-warnings ./test/runTests.js",
"test-ci": "npm run test && npm run test-e2e",
"test-all": "npm run lint && npm run lint-styles && npm run flow && npm run build && npm run test && npm run test-e2e",
"test-e2e": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 node --trace-warnings ./test/runTests.js e2e"
"test": "npm run lint && npm run lint-styles && npm run flow && npm run build && npm run test-unit && npm run test-e2e",
"test-base": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=true ELECTRON_DISABLE_SECURITY_WARNINGS=true node --trace-warnings ./node_modules/jest/bin/jest",
"test-unit": "npm run test-base -- ./test/unit",
"test-e2e": "npm run test-base -- ./test/e2e",
"test-ci": "npm run test-e2e && npm run test-unit"
},
"config": {
"style_paths": "app/styles/*.scss app/components/**/*.scss",
@ -179,10 +180,7 @@
],
"transform": {
"^.+\\.js$": "babel-jest"
},
"setupFiles": [
"./internals/scripts/CheckBuiltsExist.js"
]
}
},
"devDependencies": {
"@commitlint/cli": "^7.0.0",

5
test/example.js

@ -1,5 +0,0 @@
describe('description', () => {
it('should have description', () => {
expect(1 + 2).toBe(3)
})
})

14
test/runTests.js

@ -1,14 +0,0 @@
const spawn = require('cross-spawn')
const path = require('path')
const s = `\\${path.sep}`
const pattern =
process.argv[2] === 'e2e'
? `test${s}e2e${s}.+\\.spec\\.js`
: `test${s}(?!e2e${s})[^${s}]+${s}.+\\.spec\\.js$`
const result = spawn.sync(path.normalize('./node_modules/.bin/jest'), [pattern], {
stdio: 'inherit'
})
process.exit(result.status)

4
test/components/AnimatedCheckmark.spec.js → test/unit/components/AnimatedCheckmark.spec.js

@ -3,8 +3,8 @@ import { configure, shallow } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import Isvg from 'react-inlinesvg'
import AnimatedCheckmark from '../../app/components/AnimatedCheckmark'
import checkmarkIcon from '../../app/components/AnimatedCheckmark/checkmark.svg'
import AnimatedCheckmark from 'components/AnimatedCheckmark'
import checkmarkIcon from 'components/AnimatedCheckmark/checkmark.svg'
configure({ adapter: new Adapter() })

6
test/components/CryptoIcon.spec.js → test/unit/components/CryptoIcon.spec.js

@ -2,10 +2,10 @@ import React from 'react'
import { configure, shallow } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import Isvg from 'react-inlinesvg'
import CryptoIcon from '../../app/components/CryptoIcon'
import CryptoIcon from 'components/CryptoIcon'
import skinnyBitcoinIcon from '../../app/icons/skinny_bitcoin.svg'
import litecoinIcon from '../../app/icons/litecoin.svg'
import skinnyBitcoinIcon from 'icons/skinny_bitcoin.svg'
import litecoinIcon from 'icons/litecoin.svg'
configure({ adapter: new Adapter() })

4
test/components/CurrencyIcon.spec.js → test/unit/components/CurrencyIcon.spec.js

@ -2,8 +2,8 @@ import React from 'react'
import { configure, shallow } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import FaDollar from 'react-icons/lib/fa/dollar'
import CryptoIcon from '../../app/components/CryptoIcon'
import CurrencyIcon from '../../app/components/CurrencyIcon'
import CryptoIcon from 'components/CryptoIcon'
import CurrencyIcon from 'components/CurrencyIcon'
configure({ adapter: new Adapter() })

6
test/components/Form.spec.js → test/unit/components/Form.spec.js

@ -2,9 +2,9 @@ import React from 'react'
import { configure, shallow } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import Form from '../../app/components/Form'
import Pay from '../../app/components/Form/Pay'
import Request from '../../app/components/Form/Request'
import Form from 'components/Form'
import Pay from 'components/Form/Pay'
import Request from 'components/Form/Request'
configure({ adapter: new Adapter() })

2
test/components/Form/Pay.spec.js → test/unit/components/Form/Pay.spec.js

@ -2,7 +2,7 @@ import React from 'react'
import { configure, shallow } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import Pay from '../../../app/components/Form/Pay'
import Pay from 'components/Form/Pay'
configure({ adapter: new Adapter() })

2
test/components/Form/Request.spec.js → test/unit/components/Form/Request.spec.js

@ -2,7 +2,7 @@ import React from 'react'
import { configure, shallow } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import Request from '../../../app/components/Form/Request'
import Request from 'components/Form/Request'
configure({ adapter: new Adapter() })

4
test/components/LoadingBolt.spec.js → test/unit/components/LoadingBolt.spec.js

@ -3,8 +3,8 @@ import { configure, shallow } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import Isvg from 'react-inlinesvg'
import LoadingBolt from '../../app/components/LoadingBolt'
import cloudboltIcon from '../../app/icons/cloudbolt.svg'
import LoadingBolt from 'components/LoadingBolt'
import cloudboltIcon from 'icons/cloudbolt.svg'
configure({ adapter: new Adapter() })

0
test/reducers/__snapshots__/balance.spec.js.snap → test/unit/reducers/__snapshots__/balance.spec.js.snap

0
test/reducers/__snapshots__/channels.spec.js.snap → test/unit/reducers/__snapshots__/channels.spec.js.snap

0
test/reducers/__snapshots__/form.spec.js.snap → test/unit/reducers/__snapshots__/form.spec.js.snap

0
test/reducers/__snapshots__/info.spec.js.snap → test/unit/reducers/__snapshots__/info.spec.js.snap

0
test/reducers/__snapshots__/invoice.spec.js.snap → test/unit/reducers/__snapshots__/invoice.spec.js.snap

0
test/reducers/__snapshots__/payment.spec.js.snap → test/unit/reducers/__snapshots__/payment.spec.js.snap

0
test/reducers/__snapshots__/peers.spec.js.snap → test/unit/reducers/__snapshots__/peers.spec.js.snap

0
test/reducers/__snapshots__/ticker.spec.js.snap → test/unit/reducers/__snapshots__/ticker.spec.js.snap

2
test/reducers/balance.spec.js → test/unit/reducers/balance.spec.js

@ -1,4 +1,4 @@
import balanceReducer, { GET_BALANCE, RECEIVE_BALANCE } from '../../app/reducers/balance'
import balanceReducer, { GET_BALANCE, RECEIVE_BALANCE } from 'reducers/balance'
describe('reducers', () => {
describe('balanceReducer', () => {

2
test/reducers/channels.spec.js → test/unit/reducers/channels.spec.js

@ -6,7 +6,7 @@ import channelsReducer, {
OPENING_CHANNEL,
OPENING_SUCCESSFUL,
OPENING_FAILURE
} from '../../app/reducers/channels'
} from 'reducers/channels'
describe('reducers', () => {
describe('channelsReducer', () => {

2
test/reducers/form.spec.js → test/unit/reducers/form.spec.js

@ -1,4 +1,4 @@
import formReducer, { SET_FORM_TYPE } from '../../app/reducers/form'
import formReducer, { SET_FORM_TYPE } from 'reducers/form'
describe('reducers', () => {
describe('formReducer', () => {

2
test/reducers/info.spec.js → test/unit/reducers/info.spec.js

@ -1,4 +1,4 @@
import infoReducer, { GET_INFO, RECEIVE_INFO } from '../../app/reducers/info'
import infoReducer, { GET_INFO, RECEIVE_INFO } from 'reducers/info'
describe('reducers', () => {
describe('infoReducer', () => {

2
test/reducers/invoice.spec.js → test/unit/reducers/invoice.spec.js

@ -9,7 +9,7 @@ import invoiceReducer, {
SEND_INVOICE,
INVOICE_SUCCESSFUL,
INVOICE_FAILED
} from '../../app/reducers/invoice'
} from 'reducers/invoice'
describe('reducers', () => {
describe('invoiceReducer', () => {

2
test/reducers/payment.spec.js → test/unit/reducers/payment.spec.js

@ -5,7 +5,7 @@ import paymentReducer, {
SEND_PAYMENT,
PAYMENT_SUCCESSFULL,
PAYMENT_FAILED
} from '../../app/reducers/payment'
} from 'reducers/payment'
describe('reducers', () => {
describe('paymentReducer', () => {

2
test/reducers/peers.spec.js → test/unit/reducers/peers.spec.js

@ -9,7 +9,7 @@ import peersReducer, {
SET_PEER,
GET_PEERS,
RECEIVE_PEERS
} from '../../app/reducers/peers'
} from 'reducers/peers'
describe('reducers', () => {
describe('peersReducer', () => {

2
test/reducers/ticker.spec.js → test/unit/reducers/ticker.spec.js

@ -3,7 +3,7 @@ import tickerReducer, {
SET_CRYPTO,
GET_TICKERS,
RECIEVE_TICKERS
} from '../../app/reducers/ticker'
} from 'reducers/ticker'
describe('reducers', () => {
describe('tickerReducer', () => {

0
test/utils/usd.spec.js → test/unit/utils/usd.spec.js

Loading…
Cancel
Save