Merge pull request #114 from cypress-io/e2e-tests

e2e tests
This commit is contained in:
Brian Mann
2017-05-31 17:41:21 -04:00
committed by GitHub
23 changed files with 56 additions and 51 deletions

View File

@@ -14,7 +14,7 @@ jobs:
# need to set unsafe perm to be able to do `npm postinstall`
npm_config_unsafe-perm: true
working_directory: ~/cypress-monorepo
parallelism: 3
parallelism: 4
steps:
- checkout
@@ -159,6 +159,7 @@ jobs:
name: Fast unit tests
command: |
if [ $CIRCLE_NODE_INDEX == 0 ]; then
npm test
npm run all test -- --package coffee
npm run all test -- --package desktop-gui
npm run all test -- --package electron
@@ -183,24 +184,32 @@ jobs:
whoami
npm run all test-integration -- --package server
fi
#
# things to run in the 2nd CI container
#
- run:
name: Docs - running E2E tests
name: Server E2E tests (electron)
command: |
if [ $CIRCLE_NODE_INDEX == 1 ]; then
cd docs
npm run test-e2e
npm run all test-e2e -- --package server
fi
#
# things to run in the 3rd CI container
#
- run:
name: Driver unit tests
name: Docs - running E2E tests
command: |
if [ $CIRCLE_NODE_INDEX == 2 ]; then
cd docs
npm run test-e2e
fi
#
# things to run in the 4th CI container
#
- run:
name: Driver unit tests
command: |
if [ $CIRCLE_NODE_INDEX == 3 ]; then
chrome --version
xvfb-run -as "-screen 0 1280x720x16" npm run all test -- --package driver
fi

View File

@@ -12,7 +12,6 @@
"all": "node cli.js --exec run",
"test": "echo 'This runs just the CLI tests' && mocha",
"test-watch": "mocha --watch",
"test-e2e": "blah",
"link": "node ./dev/link-packages.js",
"postinstall": "npm run link && npm run all install && npm run build",
"clean-deps": "npm run all clean-deps",

View File

@@ -52,7 +52,7 @@ module.exports = (Cypress, Commands) ->
## presses a key or clicks in the UI to continue
pause: (subject, options = {}) ->
## bail if we're headless
return subject if $Cypress.isHeadless
return subject if Cypress.isHeadless
_.defaults options, {log: true}

View File

@@ -26,7 +26,7 @@ module.exports = (Cypress, Commands) ->
consoleOutput = {}
options._log = $Log.command({
message: _.truncate(cmd, 25)
message: _.truncate(cmd, { length: 25 })
consoleProps: ->
consoleOutput
})
@@ -56,8 +56,8 @@ module.exports = (Cypress, Commands) ->
return result if result.code is 0 or not options.failOnNonZeroExit
output = ""
output += "\nStdout:\n#{_.truncate(result.stdout, 200)}" if result.stdout
output += "\nStderr:\n#{_.truncate(result.stderr, 200)}" if result.stderr
output += "\nStdout:\n#{_.truncate(result.stdout, { length: 200 })}" if result.stdout
output += "\nStderr:\n#{_.truncate(result.stderr, { length: 200 })}" if result.stderr
utils.throwErrByPath "exec.non_zero_exit", {
onFail: options._log

View File

@@ -181,7 +181,7 @@ module.exports = (Cypress, Commands) ->
indicator ?= if options.response?.isOkStatusCode then "successful" else "bad"
{
message: "#{options.method} #{status} #{_.truncate(options.url, 25)}"
message: "#{options.method} #{status} #{_.truncate(options.url, { length: 25 })}"
indicator: indicator
}
})

View File

@@ -62,7 +62,7 @@ $Cy.extend({
module.exports = (Cypress, Commands) ->
Cypress.on "test:after:hooks", (test, runnable) ->
if test.err and $Cypress.isHeadless and Cypress.config("screenshotOnHeadlessFailure")
if test.err and Cypress.isHeadless and Cypress.config("screenshotOnHeadlessFailure")
## give the UI some time to render the error
## because we were noticing that errors were not
## yet displayed in the UI when running headlessly

View File

@@ -150,7 +150,7 @@ $Cy.extend({
indicator ?= if /^2/.test(status) then "successful" else "bad"
{
message: "#{xhr.method} #{status} #{_.truncate(stripOrigin(xhr.url), 20)}"
message: "#{xhr.method} #{status} #{_.truncate(stripOrigin(xhr.url), { length: 20 })}"
indicator: indicator
}
})

View File

@@ -86,8 +86,7 @@ class $Cypress
if d = config.remote?.domainName
document.domain = d
if config.isHeadless
$Cypress.isHeadless = true
@isHeadless = !!config.isHeadless
{environmentVariables, remote} = config
@@ -183,7 +182,7 @@ class $Cypress
## event here, so other commands can tap into that
return if not @cy
@cy.silenceConsole(contentWindow) if $Cypress.isHeadless
@cy.silenceConsole(contentWindow) if @isHeadless
@cy.bindWindowListeners(contentWindow)
@cy._setWindowDocumentProps(contentWindow)

View File

@@ -5,7 +5,6 @@ chai = require("chai")
chaijQuery = require("chai-jquery")
sinonChai = require("sinon-chai")
$Cypress = require("../cypress")
$Dom = require("./dom")
$Utils = require("./utils")

View File

@@ -76,7 +76,7 @@ class $Command
{name, args} = @attributes
args = _.reduce args, (memo, arg) ->
arg = if _.isString(arg) then _.truncate(arg, 20) else "..."
arg = if _.isString(arg) then _.truncate(arg, { length: 20 }) else "..."
memo.push(arg)
memo
, []

View File

@@ -50,7 +50,7 @@ $Cookies = (namespace, domain) ->
m = if removed then "warn" else "info"
args = [_.truncate(message, 50)]
args = [_.truncate(message, { length: 50 })]
if isDebuggingVerbose
args.push(cookie)

View File

@@ -1,10 +1,12 @@
_ = require("lodash")
divider = (num, char) ->
Array(num).join(char)
format = (data) ->
switch
when _.isString(data)
_.truncate(data, 100)
_.truncate(data, { length: 100 })
when _.isObject(data)
JSON.stringify(data, null, 2)
else

View File

@@ -265,7 +265,7 @@ class $Log
snapshot: (name, options = {}) ->
## bail early and dont snapshot
## if we're in headless mode
if $Cypress.isHeadless
if @Cypress.isHeadless
return @
_.defaults options,

View File

@@ -3,7 +3,6 @@ Backbone = require("backbone")
moment = require("moment")
Promise = require("bluebird")
$Cypress = require("../cypress")
$Log = require("./log")
utils = require("./utils")
@@ -17,7 +16,7 @@ RUNNABLE_PROPS = "id title root hookName err duration state failedFromHook bod
triggerMocha = (Cypress, event, args...) ->
## dont trigger mocha events if we are not headless
return if not $Cypress.isHeadless
return if not Cypress.isHeadless
Cypress.trigger("mocha", event, args...)
@@ -403,7 +402,7 @@ class $Runner
## we dont need to hold a log reference
## to anything in memory when we're headless
## because you cannot inspect any logs
return if $Cypress.isHeadless
return if Cypress.isHeadless
test = @testsById[attrs.testId]

View File

@@ -229,7 +229,7 @@ module.exports = {
switch form
when "long"
text = _.chain($el.text()).clean().truncate(10).value()
text = _.chain($el.text()).clean().truncate({length: 10 }).value()
children = $el.children().length
str = $el.clone().empty().prop("outerHTML")
switch

View File

@@ -11,9 +11,6 @@ describe "$Cypress.Cy Screenshot Commands", ->
beforeEach ->
@sandbox.spy(@cy, "_takeScreenshot")
afterEach ->
delete $Cypress.isHeadless
it "no screenshot when no test.err", ->
hooks = @Cypress.invoke("test:after:hooks", {err: null})
@@ -22,7 +19,7 @@ describe "$Cypress.Cy Screenshot Commands", ->
expect(@cy._takeScreenshot).not.to.be.called
it "no screenshot when not headless", ->
$Cypress.isHeadless = false
@Cypress.isHeadless = false
hooks = @Cypress.invoke("test:after:hooks", {err: {}})
@@ -33,7 +30,7 @@ describe "$Cypress.Cy Screenshot Commands", ->
it "no screenshot when screenshotOnHeadlessFailure is false", ->
@sandbox.stub(Cypress, "config").withArgs("screenshotOnHeadlessFailure").returns(false)
$Cypress.isHeadless = true
@Cypress.isHeadless = true
hooks = @Cypress.invoke("test:after:hooks", {err: {}})
@@ -44,7 +41,7 @@ describe "$Cypress.Cy Screenshot Commands", ->
it "takes screenshot if test.err and isHeadless and screenshotOnHeadlessFailure is true", ->
@sandbox.stub(Cypress, "config").withArgs("screenshotOnHeadlessFailure").returns(true)
$Cypress.isHeadless = true
@Cypress.isHeadless = true
@Cypress.on "take:screenshot", (data, cb) ->
expect(data).to.deep.eq({

View File

@@ -137,7 +137,7 @@ describe('<Command />', () => {
it('truncates the message when over 100 chars', () => {
const component = shallow(<Command model={model({ message: longText })} />)
expect(component.find(Message).first().shallow().find('.command-message-text').html()).to.contain(_.truncate(longText, 100))
expect(component.find(Message).first().shallow().find('.command-message-text').html()).to.contain(_.truncate(longText, { length: 100 }))
})
it('renders the renderProps message when specified', () => {

View File

@@ -75,7 +75,6 @@ module.exports = {
.videoCodec("libx264")
.outputOptions("-preset ultrafast")
.on "start", (line) ->
console.log "spawned ffmpeg", line
started.resolve(new Date)
# .on "codecData", (data) ->
# console.log "codec data", data

View File

@@ -12,14 +12,14 @@
"clean-deps": "rm -rf node_modules",
"deploy": "gulp deploy",
"release": "gulp release",
"test": "./test/support/helpers/run",
"test-watch": "./test/support/helpers/watch test",
"test-unit": "./test/support/helpers/run test/unit",
"test-unit-watch": "./test/support/helpers/watch test-unit",
"test-integration": "./test/support/helpers/run test/integration",
"test-integration-watch": "./test/support/helpers/watch test-integration",
"test-e2e": "./test/support/helpers/run test/e2e",
"test-e2e-chrome": "./test/support/helpers/run test/e2e chrome",
"test": "./test/support/run",
"test-watch": "./test/support/watch test",
"test-unit": "./test/support/run test/unit",
"test-unit-watch": "./test/support/watch test-unit",
"test-integration": "./test/support/run test/integration",
"test-integration-watch": "./test/support/watch test-integration",
"test-e2e": "./test/support/run test/e2e",
"test-e2e-chrome": "./test/support/run test/e2e chrome",
"test-cov": "NODE_COVERAGE=true NODE_ENV=test CYPRESS_ENV=test BLUEBIRD_DEBUG=1 xvfb-maybe istanbul cover node_modules/.bin/_mocha -- --opts ./test/support/mocha.opts",
"test-cov-process": "NODE_COVERAGE=true NODE_ENV=test CYPRESS_ENV=test BLUEBIRD_DEBUG=1 istanbul cover --include-pid",
"test-debug": "NODE_ENV=test NODE_DEBUG=request CYPRESS_ENV=test BLUEBIRD_DEBUG=1 DEBUG=nock.*,-nock.common,socket.io:* node-debug --hidden='(node_modules|bower_components)' --no-preload _mocha --opts test/support/mocha.opts --watch",
@@ -42,6 +42,7 @@
"cloudflare-cli": "^1.5.2",
"codecov": "^1.0.1",
"coffee-coverage": "^1.0.1",
"cors": "^2.8.3",
"coveralls": "^2.11.8",
"cypress-bumpercar": "^1.0.5",
"electron-osx-sign": "^0.3.0",

View File

@@ -1,4 +1,4 @@
_ = require("lodash")
str = require("underscore.string")
e2e = require("../support/helpers/e2e")
onServer = (app) ->
@@ -65,7 +65,7 @@ describe "e2e web security", ->
## make sure this message is included
## three times in stdout, one for each
## failing test
expect(_.count(stdout, msg)).to.eq(3)
expect(str.count(stdout, msg)).to.eq(3)
context "when disabled", ->
e2e.setup({

View File

@@ -1,4 +1,4 @@
require("../spec_helper")
require("../../spec_helper")
_ = require("lodash")
fs = require("fs-extra")
@@ -9,12 +9,12 @@ human = require("human-interval")
morgan = require("morgan")
express = require("express")
Promise = require("bluebird")
Fixtures = require("../support/helpers/fixtures")
allowDestroy = require("#{root}lib/util/server_destroy")
user = require("#{root}lib/user")
cypress = require("#{root}lib/cypress")
Project = require("#{root}lib/project")
settings = require("#{root}lib/util/settings")
Fixtures = require("./fixtures")
allowDestroy = require("#{root}../lib/util/server_destroy")
user = require("#{root}../lib/user")
cypress = require("#{root}../lib/cypress")
Project = require("#{root}../lib/project")
settings = require("#{root}../lib/util/settings")
cp = Promise.promisifyAll(cp)
fs = Promise.promisifyAll(fs)

View File

@@ -12,6 +12,7 @@ if [ "$SPEC" = '' ]; then
echo ''
echo ' $ npm run test-unit'
echo ' $ npm run test-integration'
echo ' $ npm run test-e2e'
echo ''
exit 1
fi