Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@
"mocha": "7.0.1",
"moment": "2.24.0",
"morgan": "1.9.1",
"npm-install-version": "6.0.2",
"react-15.6.1": "npm:[email protected]",
"react-16.0.0": "npm:[email protected]",
"react-dom-15.6.1": "npm:[email protected]",
"react-dom-16.0.0": "npm:[email protected]",
"setimmediate": "1.0.5",
"sinon": "8.1.1",
"text-mask-addons": "3.8.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/driver/test/cypress/fixtures/react-15.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</head>
<body>
<div id="react-container"></div>
<script src="/node_modules/react@15.6.1/dist/react.js"></script>
<script src="/node_modules/react-dom@15.6.1/dist/react-dom.js"></script>
<script src="/node_modules/react-15.6.1/dist/react.js"></script>
<script src="/node_modules/react-dom-15.6.1/dist/react-dom.js"></script>
<script>
window.onChangeEvents = 0

Expand Down
4 changes: 2 additions & 2 deletions packages/driver/test/cypress/fixtures/react-16.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</head>
<body>
<div id="react-container"></div>
<script src="/node_modules/react@16.0.0/umd/react.development.js"></script>
<script src="/node_modules/react-dom@16.0.0/umd/react-dom.development.js"></script>
<script src="/node_modules/react-16.0.0/umd/react.development.js"></script>
<script src="/node_modules/react-dom-16.0.0/umd/react-dom.development.js"></script>
<script>
window.onChangeEvents = 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe "src/cy/commands/angular", ->

describe "errors", ->
beforeEach ->
Cypress.config("defaultCommandTimeout", 50)
Cypress.config("defaultCommandTimeout", 100)

@angular = cy.state("window").angular

Expand Down Expand Up @@ -94,7 +94,7 @@ describe "src/cy/commands/angular", ->

describe "errors", ->
beforeEach ->
Cypress.config("defaultCommandTimeout", 50)
Cypress.config("defaultCommandTimeout", 100)

@angular = cy.state("window").angular

Expand Down Expand Up @@ -208,7 +208,7 @@ describe "src/cy/commands/angular", ->

describe "errors", ->
beforeEach ->
Cypress.config("defaultCommandTimeout", 50)
Cypress.config("defaultCommandTimeout", 100)

@angular = cy.state("window").angular

Expand Down
7 changes: 0 additions & 7 deletions packages/driver/test/support/server.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
_ = require("lodash")
fs = require("fs")
niv = require("npm-install-version")
auth = require("basic-auth")
bodyParser = require("body-parser")
express = require("express")
Expand All @@ -11,12 +10,6 @@ coffee = require("@packages/coffee")

args = require("minimist")(process.argv.slice(2))

## make sure we have both versions of react
niv.install("[email protected]")
niv.install("[email protected]")
niv.install("[email protected]")
niv.install("[email protected]")

[3500, 3501].forEach (port) ->
app = express()
server = http.Server(app)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exports['e2e async timeouts failing1 1'] = `
exports['e2e async timeouts / failing1'] = `

====================================================================================================

Expand Down
12 changes: 6 additions & 6 deletions packages/server/__snapshots__/8_reporters_spec.coffee.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ finished!

`

exports['e2e reporters mochawesome passes with mochawesome@1.5.2 npm custom reporter 1'] = `
exports['e2e reporters mochawesome passes with mochawesome-1.5.2 npm custom reporter 1'] = `

====================================================================================================

Expand Down Expand Up @@ -197,7 +197,7 @@ exports['e2e reporters mochawesome passes with [email protected] npm custom repo

`

exports['e2e reporters mochawesome fails with mochawesome@1.5.2 npm custom reporter 1'] = `
exports['e2e reporters mochawesome fails with mochawesome-1.5.2 npm custom reporter 1'] = `

====================================================================================================

Expand Down Expand Up @@ -314,7 +314,7 @@ Because this error occurred during a \`after all\` hook we are skipping the rema

`

exports['e2e reporters mochawesome passes with mochawesome@2.3.1 npm custom reporter 1'] = `
exports['e2e reporters mochawesome passes with mochawesome-2.3.1 npm custom reporter 1'] = `

====================================================================================================

Expand Down Expand Up @@ -379,7 +379,7 @@ exports['e2e reporters mochawesome passes with [email protected] npm custom repo

`

exports['e2e reporters mochawesome fails with mochawesome@2.3.1 npm custom reporter 1'] = `
exports['e2e reporters mochawesome fails with mochawesome-2.3.1 npm custom reporter 1'] = `

====================================================================================================

Expand Down Expand Up @@ -494,7 +494,7 @@ Because this error occurred during a \`after all\` hook we are skipping the rema

`

exports['e2e reporters mochawesome passes with mochawesome@3.0.1 npm custom reporter 1'] = `
exports['e2e reporters mochawesome passes with mochawesome-3.0.1 npm custom reporter 1'] = `

====================================================================================================

Expand Down Expand Up @@ -559,7 +559,7 @@ exports['e2e reporters mochawesome passes with [email protected] npm custom repo

`

exports['e2e reporters mochawesome fails with mochawesome@3.0.1 npm custom reporter 1'] = `
exports['e2e reporters mochawesome fails with mochawesome-3.0.1 npm custom reporter 1'] = `

====================================================================================================

Expand Down
21 changes: 21 additions & 0 deletions packages/server/lib/overrideRequire.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const Module = require('module')

export const overrideRequire = (requireOverride) => {
const _load = Module._load

Module._load = function (...args: any[]) {
let pkg = args

if (requireOverride) {
const mockedDependency = requireOverride(pkg[0], _load)

if (mockedDependency != null) {
return mockedDependency
}
}

const ret = _load.apply(this, pkg)

return ret
}
}
23 changes: 20 additions & 3 deletions packages/server/lib/reporter.coffee
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
_ = require("lodash")
path = require("path")
Mocha = require("mocha")
## mocha-* is used to allow us to have later versions of mocha specified in devDependencies
## and prevents accidently upgrading this one
## TODO: look into upgrading this to version in driver
Mocha = require("mocha-2.4.5")
mochaReporters = require("mocha-2.4.5/lib/reporters")

debug = require("debug")("cypress:server:reporter")
Promise = require("bluebird")
{ overrideRequire } = require('./overrideRequire')

mochaReporters = require("mocha/lib/reporters")

mochaErrMsgExtractionRe = /^([^:]+): expected/

STATS = "suites tests passes pending failures start end duration".split(" ")

## version 4.1.0 is what we've historically ran our e2e tests against
## there is no other reason it is specifically 4.1.0
## TODO: look into upgrading to version in driver
customReporterMocha = path.dirname(require.resolve('mocha-4.1.0'))

## override calls to `require('mocha*')` when to always resolve with a mocha we control
## otherwise mocha will be resolved from project's node_modules and might not work with our code
overrideRequire((depPath, _load) ->
if depPath is 'mocha' or depPath.startsWith('mocha/')
return _load(depPath.replace('mocha', customReporterMocha))
)

if Mocha.Suite.prototype.titlePath
throw new Error('Mocha.Suite.prototype.titlePath already exists. Please remove the monkeypatch code.')

Expand All @@ -20,7 +37,7 @@ Mocha.Suite.prototype.titlePath = ->
result = result.concat(@parent.titlePath())

if !@root
result.push(@title);
result.push(@title)

return result

Expand Down
8 changes: 6 additions & 2 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
"mime": "2.4.4",
"minimatch": "3.0.4",
"minimist": "1.2.5",
"mocha": "2.4.5",
"mocha-2.4.5": "npm:[email protected]",
"mocha-4.1.0": "npm:[email protected]",
"mocha-junit-reporter": "1.23.1",
"mocha-teamcity-reporter": "3.0.0",
"moment": "2.24.0",
Expand Down Expand Up @@ -164,12 +165,15 @@
"http-mitm-proxy": "0.7.0",
"https-proxy-agent": "3.0.1",
"istanbul": "0.4.5",
"mocha": "7.0.1",
"mochawesome-1.5.2": "npm:[email protected]",
"mochawesome-2.3.1": "npm:[email protected]",
"mochawesome-3.0.1": "npm:[email protected]",
"mock-fs": "4.10.4",
"mocked-env": "1.2.4",
"mockery": "2.1.0",
"multiparty": "4.2.1",
"nock": "12.0.2",
"npm-install-version": "6.0.2",
"proxyquire": "2.1.0",
"react": "15.6.2",
"repl.history": "0.1.4",
Expand Down
11 changes: 5 additions & 6 deletions packages/server/test/e2e/1_async_timeouts_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ e2e = require("../support/helpers/e2e")
describe "e2e async timeouts", ->
e2e.setup()

it "failing1", ->
e2e.exec(@, {
spec: "async_timeouts_spec.coffee"
snapshot: true
expectedExitCode: 2
})
e2e.it "failing1", {
spec: "async_timeouts_spec.coffee"
snapshot: true
expectedExitCode: 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Fixtures = require("../support/helpers/fixtures")
e2ePath = Fixtures.projectPath("e2e")

describe "e2e browserify, babel, es2015", ->
e2e.setup({npmInstall: true})
e2e.setup()

it "passes", ->
e2e.exec(@, {
Expand Down
19 changes: 9 additions & 10 deletions packages/server/test/e2e/8_reporters_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ Fixtures = require("../support/helpers/fixtures")
e2ePath = Fixtures.projectPath("e2e")

mochaAwesomes = [
"mochawesome@1.5.2"
"mochawesome@2.3.1"
"mochawesome@3.0.1"
"mochawesome-1.5.2"
"mochawesome-2.3.1"
"mochawesome-3.0.1"
]

describe "e2e reporters", ->
e2e.setup({
npmInstall: mochaAwesomes
})
e2e.setup()

it "reports error if cannot load reporter", ->
e2e.exec(@, {
Expand Down Expand Up @@ -76,10 +74,11 @@ describe "e2e reporters", ->
e2e.exec(@, {
spec: "simple_passing_spec.coffee"
snapshot: true
reporter: ma
## cypress supports passing module name, relative path, or absolute path
reporter: require.resolve(ma)
})
.then ->
if ma is "mochawesome@1.5.2"
if ma is "mochawesome-1.5.2"
fs.readFileAsync(path.join(e2ePath, "mochawesome-reports", "mochawesome.html"), "utf8")
.then (xml) ->
expect(xml).to.include("<h3 class=\"suite-title\">simple passing spec</h3>")
Expand All @@ -95,10 +94,10 @@ describe "e2e reporters", ->
spec: "simple_failing_hook_spec.coffee"
snapshot: true
expectedExitCode: 3
reporter: ma
reporter: require.resolve(ma)
})
.then ->
if ma is "mochawesome@1.5.2"
if ma is "mochawesome-1.5.2"
fs.readFileAsync(path.join(e2ePath, "mochawesome-reports", "mochawesome.html"), "utf8")
.then (xml) ->
expect(xml).to.include("<h3 class=\"suite-title\">simple failing hook spec</h3>")
Expand Down
2 changes: 1 addition & 1 deletion packages/server/test/integration/cypress_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ describe('lib/cypress', () => {
})

it('removes fixtures when they exist and fixturesFolder is false', function (done) {
return config.get(this.idsPath)
config.get(this.idsPath)
.then((cfg) => {
this.cfg = cfg

Expand Down
1 change: 0 additions & 1 deletion packages/server/test/performance/proxy_performance_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const fse = require('fs-extra')
const os = require('os')
const path = require('path')
const _ = require('lodash')
const { it, after, before, beforeEach, describe } = require('mocha')
const { expect } = require('chai')
const debug = require('debug')('test:proxy-performance')
const DebuggingProxy = require('@cypress/debugging-proxy')
Expand Down
5 changes: 4 additions & 1 deletion packages/server/test/scripts/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,14 @@ commandAndArguments.args.push(
'--timeout',
options['inspect-brk'] ? '40000000' : '10000',
'--recursive',
'--compilers ts:@packages/ts/register,coffee:@packages/coffee/register',
'-r @packages/ts/register',
'-r @packages/coffee/register',
'--reporter',
'mocha-multi-reporters',
'--reporter-options',
'configFile=../../mocha-reporter-config.json',
// restore mocha 2.x behavior to force end process after spec run
'--exit',
)

const env = _.clone(process.env)
Expand Down
Loading