mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-04 14:00:22 -05:00
* fixes #1585 exit with status 1 whenever no specs were found * add a couple tests around spec video file name * cleanup old circleci branch filters * bump up range of expected timings * rename specsUtil for clarity, fix failing tests
This commit is contained in:
@@ -718,7 +718,6 @@ workflows:
|
||||
branches:
|
||||
only:
|
||||
- develop
|
||||
- fix-engines-1373
|
||||
requires:
|
||||
- build
|
||||
- build-binary:
|
||||
@@ -726,7 +725,6 @@ workflows:
|
||||
branches:
|
||||
only:
|
||||
- develop
|
||||
- fix-engines-1373
|
||||
requires:
|
||||
- build
|
||||
- test-next-version:
|
||||
@@ -734,7 +732,6 @@ workflows:
|
||||
branches:
|
||||
only:
|
||||
- develop
|
||||
- fix-engines-1373
|
||||
requires:
|
||||
- build-npm-package
|
||||
- build-binary
|
||||
@@ -751,7 +748,6 @@ workflows:
|
||||
branches:
|
||||
only:
|
||||
- develop
|
||||
- issue-895
|
||||
requires:
|
||||
- build-npm-package
|
||||
- build-binary
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
exports['e2e specs failing when no specs found 1'] = `Can't run because no spec files were found.
|
||||
|
||||
We searched for any files inside of this folder:
|
||||
|
||||
/foo/bar/.projects/e2e/cypress/specs
|
||||
`
|
||||
|
||||
exports['e2e specs failing when no spec pattern found 1'] = `Can't run because no spec files were found.
|
||||
|
||||
We searched for any files matching this glob pattern:
|
||||
|
||||
/foo/bar/.projects/e2e/cypress/integration/cypress/integration/**notfound**
|
||||
`
|
||||
@@ -3,13 +3,13 @@ path = require("path")
|
||||
Promise = require("bluebird")
|
||||
cwd = require("../cwd")
|
||||
glob = require("../util/glob")
|
||||
specs = require("../util/specs")
|
||||
specsUtil = require("../util/specs")
|
||||
pathHelpers = require("../util/path_helpers")
|
||||
CacheBuster = require("../util/cache_buster")
|
||||
|
||||
module.exports = {
|
||||
handleFiles: (req, res, config) ->
|
||||
specs.find(config)
|
||||
specsUtil.find(config)
|
||||
.then (files) ->
|
||||
res.json({
|
||||
integration: files
|
||||
@@ -43,7 +43,7 @@ module.exports = {
|
||||
getSpecs = =>
|
||||
## grab all of the specs if this is ci
|
||||
if spec is "__all"
|
||||
specs.find(config)
|
||||
specsUtil.find(config)
|
||||
.map (spec) ->
|
||||
## grab the name of each
|
||||
spec.absolute
|
||||
|
||||
@@ -11,7 +11,7 @@ listPaths = (paths) ->
|
||||
API = {
|
||||
# forms well-formatted user-friendly error for most common
|
||||
# errors Cypress can encounter
|
||||
getMsgByType: (type, arg1 = {}, arg2 = {}) ->
|
||||
getMsgByType: (type, arg1 = {}, arg2) ->
|
||||
switch type
|
||||
when "CANNOT_TRASH_ASSETS"
|
||||
"""
|
||||
@@ -209,8 +209,25 @@ API = {
|
||||
|
||||
#{chalk.yellow(arg2)}
|
||||
"""
|
||||
when "SPEC_FILE_NOT_FOUND"
|
||||
"Can't find test spec: " + chalk.blue(arg1)
|
||||
when "NO_SPECS_FOUND"
|
||||
## no glob provided, searched all specs
|
||||
if not arg2
|
||||
"""
|
||||
Can't run because no spec files were found.
|
||||
|
||||
We searched for any files inside of this folder:
|
||||
|
||||
#{chalk.blue(arg1)}
|
||||
"""
|
||||
else
|
||||
"""
|
||||
Can't run because no spec files were found.
|
||||
|
||||
We searched for any files matching this glob pattern:
|
||||
|
||||
#{chalk.blue(arg2)}
|
||||
"""
|
||||
|
||||
when "RENDERER_CRASHED"
|
||||
"""
|
||||
We detected that the Chromium Renderer process just crashed.
|
||||
|
||||
@@ -16,11 +16,11 @@ Reporter = require("../reporter")
|
||||
openProject = require("../open_project")
|
||||
Windows = require("../gui/windows")
|
||||
fs = require("../util/fs")
|
||||
specs = require("../util/specs")
|
||||
trash = require("../util/trash")
|
||||
random = require("../util/random")
|
||||
progress = require("../util/progress_bar")
|
||||
terminal = require("../util/terminal")
|
||||
specsUtil = require("../util/specs")
|
||||
humanTime = require("../util/human_time")
|
||||
electronApp = require("../util/electron_app")
|
||||
|
||||
@@ -382,11 +382,11 @@ module.exports = {
|
||||
else
|
||||
finish()
|
||||
|
||||
trashAssets: (options = {}) ->
|
||||
if options.trashAssetsBeforeHeadlessRuns is true
|
||||
trashAssets: (config = {}) ->
|
||||
if config.trashAssetsBeforeHeadlessRuns is true
|
||||
Promise.join(
|
||||
trash.folder(options.videosFolder)
|
||||
trash.folder(options.screenshotsFolder)
|
||||
trash.folder(config.videosFolder)
|
||||
trash.folder(config.screenshotsFolder)
|
||||
)
|
||||
.catch (err) ->
|
||||
## dont make trashing assets fail the build
|
||||
@@ -440,7 +440,7 @@ module.exports = {
|
||||
console.log("")
|
||||
|
||||
runSpecs: (options = {}) ->
|
||||
{ project, config, outputPath } = options
|
||||
{ project, config, outputPath, specs } = options
|
||||
|
||||
results = {
|
||||
startedTestsAt: null
|
||||
@@ -461,20 +461,11 @@ module.exports = {
|
||||
config
|
||||
}
|
||||
|
||||
specs.find(config, options.spec)
|
||||
.then (specs = []) =>
|
||||
if not specs.length
|
||||
## TODO: throw error when no specs found
|
||||
errors.throw('SPEC_FILE_NOT_FOUND', options.spec)
|
||||
runSpec = (spec) =>
|
||||
@runSpec(spec, options)
|
||||
.get("results")
|
||||
|
||||
names = _.map(specs, "name")
|
||||
debug("found '%d' specs using spec pattern '%s': %o", names.length, options.spec, names)
|
||||
|
||||
runSpec = (spec) =>
|
||||
@runSpec(spec, options)
|
||||
.get("results")
|
||||
|
||||
Promise.map(specs, runSpec, { concurrency: 1 })
|
||||
Promise.map(specs, runSpec, { concurrency: 1 })
|
||||
.then (runs = []) ->
|
||||
results.startedTestsAt = start = getRun(_.first(runs), "stats.start")
|
||||
results.endedTestsAt = end = getRun(_.last(runs), "stats.end")
|
||||
@@ -565,6 +556,23 @@ module.exports = {
|
||||
})
|
||||
})
|
||||
|
||||
findSpecs: (config, spec) ->
|
||||
specsUtil.find(config, spec)
|
||||
.then (files = []) =>
|
||||
if not files.length
|
||||
errors.throw('NO_SPECS_FOUND', config.integrationFolder, spec)
|
||||
|
||||
if debug.enabled
|
||||
names = _.map(files, "name")
|
||||
debug(
|
||||
"found '%d' specs using spec pattern '%s': %o",
|
||||
names.length,
|
||||
spec,
|
||||
names
|
||||
)
|
||||
|
||||
return files
|
||||
|
||||
ready: (options = {}) ->
|
||||
debug("run mode ready with options %j", options)
|
||||
|
||||
@@ -598,29 +606,31 @@ module.exports = {
|
||||
## record mode
|
||||
errors.warning("PROJECT_ID_AND_KEY_BUT_MISSING_RECORD_OPTION", projectId)
|
||||
|
||||
@trashAssets(config)
|
||||
.then =>
|
||||
@runSpecs({
|
||||
projectPath
|
||||
socketId
|
||||
project
|
||||
config
|
||||
videosFolder: config.videosFolder
|
||||
videoRecording: config.videoRecording
|
||||
videoCompression: config.videoCompression
|
||||
videoUploadOnPasses: config.videoUploadOnPasses
|
||||
exit: options.exit
|
||||
spec: options.spec
|
||||
headed: options.headed
|
||||
browser: options.browser
|
||||
outputPath: options.outputPath
|
||||
})
|
||||
.finally =>
|
||||
## TODO: remove this
|
||||
@copy(config.videosFolder, config.screenshotsFolder)
|
||||
@findSpecs(config, options.spec)
|
||||
.then (specs) =>
|
||||
@trashAssets(config)
|
||||
.then =>
|
||||
if options.allDone isnt false
|
||||
@allDone()
|
||||
@runSpecs({
|
||||
projectPath
|
||||
socketId
|
||||
project
|
||||
config
|
||||
specs
|
||||
videosFolder: config.videosFolder
|
||||
videoRecording: config.videoRecording
|
||||
videoCompression: config.videoCompression
|
||||
videoUploadOnPasses: config.videoUploadOnPasses
|
||||
exit: options.exit
|
||||
headed: options.headed
|
||||
browser: options.browser
|
||||
outputPath: options.outputPath
|
||||
})
|
||||
.finally =>
|
||||
## TODO: remove this
|
||||
@copy(config.videosFolder, config.screenshotsFolder)
|
||||
.then =>
|
||||
if options.allDone isnt false
|
||||
@allDone()
|
||||
|
||||
run: (options) ->
|
||||
electronApp
|
||||
|
||||
@@ -25,8 +25,8 @@ savedState = require("./saved_state")
|
||||
Automation = require("./automation")
|
||||
preprocessor = require("./plugins/preprocessor")
|
||||
fs = require("./util/fs")
|
||||
specs = require("./util/specs")
|
||||
settings = require("./util/settings")
|
||||
specsUtil = require("./util/specs")
|
||||
|
||||
localCwd = cwd()
|
||||
|
||||
@@ -596,7 +596,7 @@ class Project extends EE
|
||||
.getConfig()
|
||||
# TODO: handle wild card pattern or spec filename
|
||||
.then (cfg) ->
|
||||
specs.find(cfg, specPattern)
|
||||
specsUtil.find(cfg, specPattern)
|
||||
.then R.prop("integration")
|
||||
.then R.map(R.prop("name"))
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ expectRunsToHaveCorrectStats = (runs = []) ->
|
||||
run,
|
||||
"stats.duration",
|
||||
wallClocks,
|
||||
wallClocks + 100, ## add 100ms to account for padding
|
||||
wallClocks + 150, ## add 150ms to account for padding
|
||||
1234
|
||||
)
|
||||
|
||||
@@ -97,7 +97,7 @@ expectRunsToHaveCorrectStats = (runs = []) ->
|
||||
run,
|
||||
"reporterStats.duration",
|
||||
wallClocks,
|
||||
wallClocks + 100, ## add 100ms to account for padding
|
||||
wallClocks + 150, ## add 150ms to account for padding
|
||||
1234
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
e2e = require("../support/helpers/e2e")
|
||||
Fixtures = require("../support/helpers/fixtures")
|
||||
|
||||
e2ePath = Fixtures.projectPath("e2e")
|
||||
|
||||
describe "e2e specs", ->
|
||||
e2e.setup()
|
||||
|
||||
it "failing when no specs found", ->
|
||||
e2e.exec(@, {
|
||||
config: "integrationFolder=cypress/specs"
|
||||
snapshot: true
|
||||
expectedExitCode: 1
|
||||
})
|
||||
|
||||
it "failing when no spec pattern found", ->
|
||||
e2e.exec(@, {
|
||||
spec: "cypress/integration/**notfound**"
|
||||
snapshot: true
|
||||
expectedExitCode: 1
|
||||
})
|
||||
@@ -88,7 +88,7 @@ expectRunToHaveCorrectStats = (run) ->
|
||||
run,
|
||||
"stats.duration",
|
||||
wallClocks,
|
||||
wallClocks + 100, ## add 100ms to account for padding
|
||||
wallClocks + 150, ## add 150ms to account for padding
|
||||
1234
|
||||
)
|
||||
|
||||
@@ -96,7 +96,7 @@ expectRunToHaveCorrectStats = (run) ->
|
||||
run,
|
||||
"reporterStats.duration",
|
||||
wallClocks,
|
||||
wallClocks + 100, ## add 100ms to account for padding
|
||||
wallClocks + 150, ## add 150ms to account for padding
|
||||
1234
|
||||
)
|
||||
|
||||
|
||||
@@ -545,6 +545,29 @@ describe "lib/cypress", ->
|
||||
|
||||
expect(found2, "browser names should be listed").to.be.ok
|
||||
|
||||
it "logs error and exits when spec file was specified and does not exist", ->
|
||||
cypress.start(["--run-project=#{@todosPath}", "--spec=path/to/spec"])
|
||||
.then =>
|
||||
@expectExitWithErr("NO_SPECS_FOUND", "path/to/spec")
|
||||
@expectExitWithErr("NO_SPECS_FOUND", "We searched for any files matching this glob pattern:")
|
||||
|
||||
it "logs error and exits when spec absolute file was specified and does not exist", ->
|
||||
cypress.start([
|
||||
"--run-project=#{@todosPath}",
|
||||
"--spec=#{@todosPath}/tests/path/to/spec"
|
||||
])
|
||||
.then =>
|
||||
@expectExitWithErr("NO_SPECS_FOUND", "#{@todosPath}/tests/path/to/spec")
|
||||
|
||||
it "logs error and exits when no specs were found at all", ->
|
||||
cypress.start([
|
||||
"--run-project=#{@todosPath}",
|
||||
"--config=integrationFolder=cypress/specs"
|
||||
])
|
||||
.then =>
|
||||
@expectExitWithErr("NO_SPECS_FOUND", "We searched for any files inside of this folder:")
|
||||
@expectExitWithErr("NO_SPECS_FOUND", "cypress/specs")
|
||||
|
||||
it "logs error and exits when project has cypress.json syntax error", ->
|
||||
fs.writeFileAsync(@todosPath + "/cypress.json", "{'foo': 'bar}")
|
||||
.then =>
|
||||
|
||||
@@ -10,8 +10,8 @@ Project = require("#{root}../lib/project")
|
||||
Reporter = require("#{root}../lib/reporter")
|
||||
headless = require("#{root}../lib/modes/headless")
|
||||
openProject = require("#{root}../lib/open_project")
|
||||
specs = require("#{root}../lib/util/specs")
|
||||
random = require("#{root}../lib/util/random")
|
||||
specsUtil = require("#{root}../lib/util/specs")
|
||||
|
||||
describe "lib/modes/headless", ->
|
||||
beforeEach ->
|
||||
@@ -420,6 +420,7 @@ describe "lib/modes/headless", ->
|
||||
@sandbox.stub(headless, "waitForSocketConnection").resolves()
|
||||
@sandbox.stub(headless, "waitForTestsToFinishRunning").resolves({ stats: { failures: 10 } })
|
||||
@sandbox.spy(headless, "waitForBrowserToConnect")
|
||||
@sandbox.stub(video, "start").resolves()
|
||||
@sandbox.stub(openProject, "launch").resolves()
|
||||
@sandbox.stub(openProject, "getProject").resolves(@projectInstance)
|
||||
@sandbox.spy(errors, "warning")
|
||||
@@ -429,7 +430,7 @@ describe "lib/modes/headless", ->
|
||||
videosFolder: "videos",
|
||||
integrationFolder: "/path/to/integrationFolder"
|
||||
})
|
||||
@sandbox.stub(specs, "find").resolves([
|
||||
@sandbox.stub(specsUtil, "find").resolves([
|
||||
{
|
||||
name: "foo_spec.js"
|
||||
path: "cypress/integration/foo_spec.js"
|
||||
@@ -457,6 +458,14 @@ describe "lib/modes/headless", ->
|
||||
.then ->
|
||||
expect(errors.warning).to.be.calledWith("CANNOT_RECORD_VIDEO_FOR_THIS_BROWSER")
|
||||
|
||||
it "names video file with spec name", ->
|
||||
headless.run()
|
||||
.then =>
|
||||
expect(video.start).to.be.calledWith("videos/foo_spec.js.mp4")
|
||||
expect(headless.waitForTestsToFinishRunning).to.be.calledWithMatch({
|
||||
cname: "videos/foo_spec.js-compressed.mp4"
|
||||
})
|
||||
|
||||
context ".run", ->
|
||||
beforeEach ->
|
||||
@sandbox.stub(@projectInstance, "getConfig").resolves({proxyUrl: "http://localhost:12345"})
|
||||
@@ -470,7 +479,7 @@ describe "lib/modes/headless", ->
|
||||
@sandbox.spy(headless, "waitForBrowserToConnect")
|
||||
@sandbox.stub(openProject, "launch").resolves()
|
||||
@sandbox.stub(openProject, "getProject").resolves(@projectInstance)
|
||||
@sandbox.stub(specs, "find").resolves([
|
||||
@sandbox.stub(specsUtil, "find").resolves([
|
||||
{
|
||||
name: "foo_spec.js"
|
||||
path: "cypress/integration/foo_spec.js"
|
||||
|
||||
@@ -505,11 +505,6 @@ describe "lib/project", ->
|
||||
.then (str) ->
|
||||
expect(str).to.eq("http://localhost:8888/__/#/tests/__all")
|
||||
|
||||
it "throws when spec isnt found", ->
|
||||
@project.getSpecUrl("does/not/exist.js")
|
||||
.catch (err) ->
|
||||
expect(err.type).to.eq("SPEC_FILE_NOT_FOUND")
|
||||
|
||||
context ".add", ->
|
||||
beforeEach ->
|
||||
@pristinePath = Fixtures.projectPath("pristine")
|
||||
@@ -747,7 +742,7 @@ describe "lib/project", ->
|
||||
|
||||
Project.getProjectStatuses([{ id: "id-123", path: "/_test-output/path/to/project" }])
|
||||
.then =>
|
||||
throw new Error("Should throw error")
|
||||
throw new Error("should have caught error but did not")
|
||||
.catch (err) ->
|
||||
expect(err).to.equal(error)
|
||||
|
||||
@@ -821,7 +816,7 @@ describe "lib/project", ->
|
||||
|
||||
Project.getProjectStatus(@clientProject)
|
||||
.then =>
|
||||
throw new Error("Should throw error")
|
||||
throw new Error("should have caught error but did not")
|
||||
.catch (err) ->
|
||||
expect(err).to.equal(error)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ R = require("ramda")
|
||||
path = require("path")
|
||||
files = require("#{root}lib/files")
|
||||
config = require("#{root}lib/config")
|
||||
specs = require("#{root}lib/util/specs")
|
||||
specsUtil = require("#{root}lib/util/specs")
|
||||
FixturesHelper = require("#{root}/test/support/helpers/fixtures")
|
||||
|
||||
describe "lib/util/specs", ->
|
||||
@@ -26,21 +26,21 @@ describe "lib/util/specs", ->
|
||||
throw new Error("path to found spec should be absolute #{JSON.stringify(foundSpec)}")
|
||||
|
||||
it "returns absolute filenames", ->
|
||||
specs
|
||||
specsUtil
|
||||
.find(@config)
|
||||
.then (R.forEach(checkFoundSpec))
|
||||
|
||||
it "handles fixturesFolder being false", ->
|
||||
@config.fixturesFolder = false
|
||||
|
||||
fn = => specs.find(@config)
|
||||
fn = => specsUtil.find(@config)
|
||||
|
||||
expect(fn).not.to.throw()
|
||||
|
||||
it "by default, returns all files as long as they have a name and extension", ->
|
||||
config.get(FixturesHelper.projectPath("various-file-types"))
|
||||
.then (cfg) ->
|
||||
specs.find(cfg)
|
||||
specsUtil.find(cfg)
|
||||
.then (files) ->
|
||||
expect(files.length).to.equal(3)
|
||||
expect(files[0].name).to.equal("coffee_spec.coffee")
|
||||
@@ -51,7 +51,7 @@ describe "lib/util/specs", ->
|
||||
config.get(FixturesHelper.projectPath("various-file-types"))
|
||||
.then (cfg) ->
|
||||
cfg.testFiles = "**/*.coffee"
|
||||
specs.find(cfg)
|
||||
specsUtil.find(cfg)
|
||||
.then (files) ->
|
||||
expect(files.length).to.equal(1)
|
||||
expect(files[0].name).to.equal("coffee_spec.coffee")
|
||||
@@ -59,7 +59,7 @@ describe "lib/util/specs", ->
|
||||
it "filters using specPattern", ->
|
||||
config.get(FixturesHelper.projectPath("various-file-types"))
|
||||
.then (cfg) ->
|
||||
specs.find(cfg, [
|
||||
specsUtil.find(cfg, [
|
||||
path.join(cfg.projectRoot, "cypress", "integration", "js_spec.js")
|
||||
])
|
||||
.then (files) ->
|
||||
@@ -69,7 +69,7 @@ describe "lib/util/specs", ->
|
||||
it "filters using specPattern as array of glob patterns", ->
|
||||
config.get(FixturesHelper.projectPath("various-file-types"))
|
||||
.then (cfg) ->
|
||||
specs.find(cfg, [
|
||||
specsUtil.find(cfg, [
|
||||
path.join(cfg.projectRoot, "cypress", "integration", "js_spec.js")
|
||||
path.join(cfg.projectRoot, "cypress", "integration", "ts*")
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user