mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-01 12:30:01 -05:00
4b368830fa
* WIP: refactor runs and recordings, update to new API updates, iteratively send spec results [skip ci] * update / add schema deps * add takenAt to screenshots payload * WIP: refactor recordings to send correctly payloads, iterative through each spec, error handling, e2e tests * add missing properties, remove hacks, upload stdout, passing tests * normalize wall clock for newest schema spec * rename projectPath -> projectRoot for clarity * normalize specPattern to be relative to projectRoot * comment out lib/api debug code * WIP fixes a lot of failing tests * many more tests around recording * WIP: update to use x-os-name on all instead of platform * WIP: update to route version 4 for creating instances * server: upgrade json-schemas to 4.7.2 * remove debug logs * fix stdout not being restored correctly between specs * test all the edge cases with failed api interactions and early exits * add e2e tests around recording without projectID * add e2e tests around recording without recordKey * refactored all tests surrounding record mode, removed duplicates, tested only edge cases * fixes #1692 * fix failing unit tests, bump schemas * bump sinon, replace custom sandbox * fix sinon@5 not restoring fake timers automatically * missing e2e record snapshots * fix failing tests, don't pass config through each run, remove old timings in favor of spec isolation * more e2e test fixes * add e2e tests around uploading artifacts, fix bug with not uploading videos when it should - cleanup some dead code - add debug logs * cleanup dead code, remove notion of failingTests
124 lines
3.4 KiB
CoffeeScript
124 lines
3.4 KiB
CoffeeScript
_ = require("lodash")
|
|
la = require("lazy-ass")
|
|
path = require("path")
|
|
check = require("check-more-types")
|
|
debug = require("debug")("cypress:server:specs")
|
|
minimatch = require("minimatch")
|
|
glob = require("./glob")
|
|
|
|
MINIMATCH_OPTIONS = { dot: true, matchBase: true }
|
|
|
|
getPatternRelativeToProjectRoot = (specPattern, projectRoot) ->
|
|
_.map specPattern, (p) ->
|
|
path.relative(projectRoot, p)
|
|
|
|
find = (config, specPattern) ->
|
|
la(check.maybe.strings(specPattern), "invalid spec pattern", specPattern)
|
|
|
|
integrationFolderPath = config.integrationFolder
|
|
|
|
debug(
|
|
"looking for test specs in the folder:",
|
|
integrationFolderPath
|
|
)
|
|
|
|
## support files are not automatically
|
|
## ignored because only _fixtures are hard
|
|
## coded. the rest is simply whatever is in
|
|
## the javascripts array
|
|
|
|
if config.fixturesFolder
|
|
fixturesFolderPath = path.join(
|
|
config.fixturesFolder,
|
|
"**",
|
|
"*"
|
|
)
|
|
|
|
supportFilePath = config.supportFile or []
|
|
|
|
## map all of the javascripts to the project root
|
|
## TODO: think about moving this into config
|
|
## and mapping each of the javascripts into an
|
|
## absolute path
|
|
javascriptsPaths = _.map config.javascripts, (js) ->
|
|
path.join(config.projectRoot, js)
|
|
|
|
## ignore fixtures + javascripts
|
|
options = {
|
|
sort: true
|
|
absolute: true
|
|
cwd: integrationFolderPath
|
|
ignore: _.compact(_.flatten([
|
|
javascriptsPaths
|
|
supportFilePath
|
|
fixturesFolderPath
|
|
]))
|
|
}
|
|
|
|
## filePath = /Users/bmann/Dev/my-project/cypress/integration/foo.coffee
|
|
## integrationFolderPath = /Users/bmann/Dev/my-project/cypress/integration
|
|
## relativePathFromIntegrationFolder = foo.coffee
|
|
## relativePathFromProjectRoot = cypress/integration/foo.coffee
|
|
|
|
relativePathFromIntegrationFolder = (file) ->
|
|
path.relative(integrationFolderPath, file)
|
|
|
|
relativePathFromProjectRoot = (file) ->
|
|
path.relative(config.projectRoot, file)
|
|
|
|
setNameParts = (file) ->
|
|
debug("found spec file %s", file)
|
|
|
|
if not path.isAbsolute(file)
|
|
throw new Error("Cannot set parts of file from non-absolute path #{file}")
|
|
|
|
{
|
|
name: relativePathFromIntegrationFolder(file)
|
|
path: relativePathFromProjectRoot(file)
|
|
absolute: file
|
|
}
|
|
|
|
ignorePatterns = [].concat(config.ignoreTestFiles)
|
|
|
|
## a function which returns true if the file does NOT match
|
|
## all of our ignored patterns
|
|
doesNotMatchAllIgnoredPatterns = (file) ->
|
|
## using {dot: true} here so that folders with a '.' in them are matched
|
|
## as regular characters without needing an '.' in the
|
|
## using {matchBase: true} here so that patterns without a globstar **
|
|
## match against the basename of the file
|
|
_.every ignorePatterns, (pattern) ->
|
|
not minimatch(file, pattern, MINIMATCH_OPTIONS)
|
|
|
|
matchesSpecPattern = (file) ->
|
|
if not specPattern
|
|
return true
|
|
|
|
matchesPattern = (pattern) ->
|
|
minimatch(file, pattern, MINIMATCH_OPTIONS)
|
|
|
|
## check to see if the file matches
|
|
## any of the spec patterns array
|
|
return _
|
|
.chain([])
|
|
.concat(specPattern)
|
|
.some(matchesPattern)
|
|
.value()
|
|
|
|
## grab all the files
|
|
glob(config.testFiles, options)
|
|
|
|
## filter out anything that matches our
|
|
## ignored test files glob
|
|
.filter(doesNotMatchAllIgnoredPatterns)
|
|
.filter(matchesSpecPattern)
|
|
.map(setNameParts)
|
|
.tap (files) ->
|
|
debug("found %d spec files: %o", files.length, files)
|
|
|
|
module.exports = {
|
|
find
|
|
|
|
getPatternRelativeToProjectRoot
|
|
}
|