mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-06 15:00:50 -05:00
root: refactor run-integration to common scripts -> run-cypress-tests, accept options, use xvfb-maybe, cleanup circle.yml
- this enables us to use a common script for running cypress tests within the monorepo itself - useful for the driver, desktop-gui, and the reporter
This commit is contained in:
+6
-5
@@ -268,7 +268,7 @@ jobs:
|
||||
- run:
|
||||
command: cd packages/driver && npm start
|
||||
background: true
|
||||
- run: cd packages/driver && xvfb-run -as "-screen 0 1280x720x16" npm run test-integration -- --parallel 4 --index 0
|
||||
- run: cd packages/driver && npm run test-integration -- --parallel 4 --index 0
|
||||
|
||||
"driver-integration-tests-2":
|
||||
<<: *defaults
|
||||
@@ -278,7 +278,7 @@ jobs:
|
||||
- run:
|
||||
command: cd packages/driver && npm start
|
||||
background: true
|
||||
- run: cd packages/driver && xvfb-run -as "-screen 0 1280x720x16" npm run test-integration -- --parallel 4 --index 1
|
||||
- run: cd packages/driver && npm run test-integration -- --parallel 4 --index 1
|
||||
|
||||
"driver-integration-tests-3":
|
||||
<<: *defaults
|
||||
@@ -288,7 +288,7 @@ jobs:
|
||||
- run:
|
||||
command: cd packages/driver && npm start
|
||||
background: true
|
||||
- run: cd packages/driver && xvfb-run -as "-screen 0 1280x720x16" npm run test-integration -- --parallel 4 --index 2
|
||||
- run: cd packages/driver && npm run test-integration -- --parallel 4 --index 2
|
||||
|
||||
"driver-integration-tests-4":
|
||||
<<: *defaults
|
||||
@@ -298,7 +298,8 @@ jobs:
|
||||
- run:
|
||||
command: cd packages/driver && npm start
|
||||
background: true
|
||||
- run: cd packages/driver && xvfb-run -as "-screen 0 1280x720x16" npm run test-integration -- --parallel 4 --index 3
|
||||
- run: cd packages/driver && npm run test-integration -- --parallel 4 --index 3
|
||||
|
||||
|
||||
"build-binary":
|
||||
<<: *defaults
|
||||
@@ -364,5 +365,5 @@ workflows:
|
||||
# command: |
|
||||
# if [ $CIRCLE_NODE_INDEX == 3 ]; then
|
||||
# # ./bin/cypress --project=./packages/example --path-to-cypress
|
||||
# # xvfb-run -as "-screen 0 1280x720x16" npm start -- --project=./packages/example
|
||||
# # npm start -- --project=./packages/example
|
||||
# fi
|
||||
|
||||
+3
-2
@@ -78,7 +78,7 @@
|
||||
"lodash": "^4.17.4",
|
||||
"mocha": "^3.5.0",
|
||||
"mocha-junit-reporter": "^1.13.0",
|
||||
"mocha-multi-reporters": "^1.1.4",
|
||||
"mocha-multi-reporters": "^1.1.5",
|
||||
"obfuscator": "^0.5.4",
|
||||
"plist": "^2.1.0",
|
||||
"pluralize": "^6.0.0",
|
||||
@@ -87,7 +87,8 @@
|
||||
"typescript": "^2.3.4",
|
||||
"vagrant": "0.0.1",
|
||||
"vinyl-paths": "^2.1.0",
|
||||
"xvfb": "^0.2.3"
|
||||
"xvfb": "^0.2.3",
|
||||
"xvfb-maybe": "^0.2.1"
|
||||
},
|
||||
"author": "Brian Mann",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"test-unit": "mocha",
|
||||
"test-unit-watch": "./test/support/watch",
|
||||
"test-unit-debug": "node --inspect --debug-brk ./node_modules/.bin/_mocha",
|
||||
"test-integration": "node ./test/scripts/run-integration-all.js",
|
||||
"test-integration": "node ../../scripts/run-cypress-tests.js --browser chrome --dir test",
|
||||
"clean-deps": "rm -rf node_modules"
|
||||
},
|
||||
"files": [
|
||||
@@ -46,7 +46,6 @@
|
||||
"minimatch": "^3.0.0",
|
||||
"minimist": "^1.2.0",
|
||||
"mocha": "cypress-io/mocha#58f6eac05e664fc6b69aa9fba70f1f6b5531a900",
|
||||
"mocha-multi-reporters": "^1.1.5",
|
||||
"moment": "^2.14.1",
|
||||
"morgan": "^1.3.0",
|
||||
"react": "^15.6.1",
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
require('@packages/server').then((code) => {
|
||||
process.exit(code)
|
||||
})
|
||||
+45
-12
@@ -1,5 +1,9 @@
|
||||
/* eslint-disable no-console */
|
||||
|
||||
// this file is a little cypress test runner helper
|
||||
// so that we can utilize our own monorepo when testing
|
||||
// things like the driver, or desktop-gui, or reporter
|
||||
|
||||
require('@packages/coffee/register')
|
||||
|
||||
const _ = require('lodash')
|
||||
@@ -8,7 +12,7 @@ const path = require('path')
|
||||
const minimist = require('minimist')
|
||||
const Promise = require('bluebird')
|
||||
|
||||
const humanTime = require('../../../server/lib/util/human_time.coffee')
|
||||
const humanTime = require('../packages/server/lib/util/human_time.coffee')
|
||||
|
||||
const glob = Promise.promisify(require('glob'))
|
||||
|
||||
@@ -30,7 +34,23 @@ function spawn (cmd, args, opts) {
|
||||
})
|
||||
}
|
||||
|
||||
glob('test/cypress/integration/**/*.coffee')
|
||||
_.defaults(options, {
|
||||
dir: '',
|
||||
glob: 'cypress/integration/**/*',
|
||||
})
|
||||
|
||||
// let us pass in project or resolve it to process.cwd() and dir
|
||||
options.project = options.project || path.resolve(process.cwd(), options.dir)
|
||||
|
||||
// normalize and set to absolute path based on process.cwd
|
||||
options.glob = path.resolve(options.project, options.glob)
|
||||
|
||||
console.log(options)
|
||||
|
||||
glob(options.glob, {
|
||||
nodir: true,
|
||||
realpath: true,
|
||||
})
|
||||
.then((specs = []) => {
|
||||
if (options.spec) {
|
||||
return _.filter(specs, (spec) => {
|
||||
@@ -52,23 +72,35 @@ glob('test/cypress/integration/**/*.coffee')
|
||||
})
|
||||
.tap(console.log)
|
||||
.each((spec = []) => {
|
||||
console.log('Running spec', spec)
|
||||
console.log('\nRunning spec', spec)
|
||||
|
||||
// get the path to xvfb-maybe binary
|
||||
const cmd = path.join(__dirname, '..', 'node_modules', '.bin', 'xvfb-maybe')
|
||||
|
||||
const configFile = path.join(__dirname, '..', 'mocha-reporter-config.json')
|
||||
|
||||
const args = [
|
||||
'test/scripts/run-integration',
|
||||
'--project',
|
||||
path.resolve('test'),
|
||||
'--browser=chrome',
|
||||
'--driver',
|
||||
'-s \"-screen 0 1280x1024x8\"',
|
||||
'--',
|
||||
'node',
|
||||
path.resolve('..', '..', 'scripts', 'start.js'), // launch root monorepo start
|
||||
'--run-project',
|
||||
options.project,
|
||||
'--spec',
|
||||
spec.replace('test/', ''),
|
||||
spec,
|
||||
'--reporter',
|
||||
'../../node_modules/mocha-multi-reporters',
|
||||
path.resolve(__dirname, '..', 'node_modules', 'mocha-multi-reporters'),
|
||||
'--reporter-options',
|
||||
'configFile=../../../mocha-reporter-config.json',
|
||||
`configFile=${configFile}`,
|
||||
]
|
||||
|
||||
return spawn('node', args, { stdio: 'inherit' })
|
||||
if (options.browser) {
|
||||
args.push('--browser', options.browser)
|
||||
}
|
||||
|
||||
console.log(cmd, args)
|
||||
|
||||
return spawn(cmd, args, { stdio: 'inherit' })
|
||||
.then((code) => {
|
||||
console.log(`${spec} exited with code`, code)
|
||||
|
||||
@@ -82,6 +114,7 @@ glob('test/cypress/integration/**/*.coffee')
|
||||
.then(() => {
|
||||
const duration = new Date() - started
|
||||
|
||||
console.log('')
|
||||
console.log('Total duration:', humanTime(duration))
|
||||
console.log('Exiting with final code:', numFailed)
|
||||
|
||||
@@ -20,4 +20,5 @@ if (projectArgIndex > -1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
require('@packages/server')
|
||||
|
||||
Reference in New Issue
Block a user