1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Refactor test setup (#5391)

- [x] Move jest config from npm scripts to `jest.config.js`
- [x] Remove obsolete cross-env package (we don't need it anymore 🎉)
- [x] Fix bug where tests are not waiting for webdriver to be ready.
This commit is contained in:
Henrik Wenz 2018-10-12 14:32:17 +01:00 committed by Tim Neutkens
parent d4785eb013
commit 95a6a872b6
6 changed files with 30 additions and 14 deletions

View file

@ -16,13 +16,13 @@ steps:
displayName: 'Install Node.js'
- script: |
npm install
yarn install
displayName: 'Install dependencies'
- script: |
npm run bootstrap
yarn bootstrap
displayName: 'Lerna bootstrap'
- script: |
npm test
displayName: 'Run tests'
yarn test
displayName: 'Run tests'

12
jest.config.js Normal file
View file

@ -0,0 +1,12 @@
'use strict'
module.exports = {
testMatch: ['**/*.test.js'],
verbose: true,
bail: true,
testEnvironment: 'node',
rootDir: 'test',
modulePaths: ['<rootDir>/lib'],
globalSetup: '<rootDir>/jest-global-setup.js',
globalTeardown: '<rootDir>/jest-global-teardown.js'
}

View file

@ -8,10 +8,10 @@
"lerna": "lerna",
"bootstrap": "lerna bootstrap",
"dev": "lerna run build --stream --parallel",
"testonly": "cross-env NODE_PATH=test/lib jest \\.test.js --config=./test/jest-config.json",
"testonly": "jest",
"testall": "npm run testonly -- --coverage --forceExit --runInBand",
"pretest": "npm run lint",
"test": "cross-env npm run testall || npm run testall",
"test": "npm run testall || npm run testall",
"coveralls": "cat ./test/coverage/lcov.info | coveralls",
"lint": "lerna run lint",
"prepublish": "lerna run prepublish",
@ -46,7 +46,6 @@
"chromedriver": "2.42.0",
"clone": "2.1.1",
"coveralls": "3.0.2",
"cross-env": "5.2.0",
"express": "4.16.3",
"fkill": "5.1.0",
"flatten": "1.0.2",
@ -66,6 +65,7 @@
"rimraf": "2.6.2",
"standard": "11.0.1",
"taskr": "1.1.0",
"wait-port": "0.2.2",
"wd": "1.10.3"
}
}

View file

@ -1,7 +0,0 @@
{
"verbose": true,
"bail": true,
"testEnvironment": "node",
"globalSetup": "./jest-global-setup.js",
"globalTeardown": "./jest-global-teardown.js"
}

View file

@ -1,5 +1,14 @@
'use strict'
const chromedriver = require('chromedriver')
const waitPort = require('wait-port')
module.exports = async function globalSetup () {
chromedriver.start()
// https://github.com/giggio/node-chromedriver/issues/117
await waitPort({
port: 9515,
timeout: 1000 * 60 * 2 // 2 Minutes
})
}

View file

@ -1,3 +1,5 @@
'use strict'
const chromedriver = require('chromedriver')
module.exports = async function globalSetup () {