diff --git a/packages/server/lib/config.coffee b/packages/server/lib/config.coffee index af89d6daf11b..cee6ed9ad0aa 100644 --- a/packages/server/lib/config.coffee +++ b/packages/server/lib/config.coffee @@ -17,7 +17,7 @@ cypressEnvRe = /^(cypress_)/i dashesOrUnderscoresRe = /^(_-)+/ folders = "fileServerFolder videosFolder supportFolder fixturesFolder integrationFolder screenshotsFolder unitFolder supportFile".split(" ") -configKeys = "port reporter reporterOptions baseUrl execTimeout defaultCommandTimeout pageLoadTimeout requestTimeout responseTimeout numTestsKeptInMemory screenshotOnHeadlessFailure waitForAnimations animationDistanceThreshold watchForFileChanges trashAssetsBeforeHeadlessRuns chromeWebSecurity videoRecording videoCompression videoUploadOnPasses viewportWidth viewportHeight supportFile fileServerFolder supportFolder fixturesFolder integrationFolder videosFolder screenshotsFolder environmentVariables hosts".split(" ") +configKeys = "port reporter reporterOptions baseUrl execTimeout defaultCommandTimeout pageLoadTimeout requestTimeout responseTimeout numTestsKeptInMemory screenshotOnHeadlessFailure waitForAnimations animationDistanceThreshold watchForFileChanges trashAssetsBeforeHeadlessRuns chromeWebSecurity videoRecording videoCompression videoUploadOnPasses viewportWidth viewportHeight supportFile fileServerFolder supportFolder fixturesFolder integrationFolder videosFolder screenshotsFolder environmentVariables hosts slowTestThreshold".split(" ") isCypressEnvLike = (key) -> cypressEnvRe.test(key) and key isnt "CYPRESS_ENV" @@ -42,6 +42,7 @@ defaults = { responseTimeout: 30000 pageLoadTimeout: 60000 execTimeout: 60000 + slowTestThreshold: 5000 videoRecording: true videoCompression: 32 videoUploadOnPasses: true @@ -85,6 +86,7 @@ validationRules = { requestTimeout: v.isNumber responseTimeout: v.isNumber screenshotOnHeadlessFailure: v.isBoolean + slowTestThreshold: v.isNumber supportFile: v.isStringOrFalse trashAssetsBeforeHeadlessRuns: v.isBoolean videoCompression: v.isNumberOrFalse diff --git a/packages/server/lib/project.coffee b/packages/server/lib/project.coffee index 140e74020ae5..22f2abffde2a 100644 --- a/packages/server/lib/project.coffee +++ b/packages/server/lib/project.coffee @@ -168,7 +168,7 @@ class Project extends EE paths = Reporter.getSearchPathsForReporter(config.reporter, config.projectRoot) errors.throw("INVALID_REPORTER_NAME", config.reporter, paths) - reporter = Reporter.create(config.reporter, config.reporterOptions, config.projectRoot) + reporter = Reporter.create(config.reporter, config.reporterOptions, config.projectRoot, config.slowTestThreshold) @automation = Automation.create(config.namespace, config.socketIoCookie, config.screenshotsFolder) diff --git a/packages/server/lib/reporter.coffee b/packages/server/lib/reporter.coffee index 5adbf15bd807..8e409ed32d19 100644 --- a/packages/server/lib/reporter.coffee +++ b/packages/server/lib/reporter.coffee @@ -8,15 +8,24 @@ mochaReporters = require("mocha/lib/reporters") STATS = "suites tests passes pending failures start end duration".split(" ") -createSuite = (obj, parent) -> +parseOptions = (obj, slowTestThreshold) -> + _.extend(obj, { + _slow: slowTestThreshold + }) + return obj + +createSuite = (obj, parent, slowTestThreshold) -> suite = new Mocha.Suite(obj.title, {}) suite.parent = parent if parent if obj.file console.log('has file:', obj.file) suite.file = obj.file + + suite = parseOptions(suite, slowTestThreshold) + return suite -createRunnable = (obj, parent) -> +createRunnable = (obj, parent, slowTestThreshold) -> {body} = obj if body @@ -33,6 +42,8 @@ createRunnable = (obj, parent) -> runnable.parent = parent if parent + runnable = parseOptions(runnable, slowTestThreshold) + return runnable mergeRunnable = (testProps, runnables) -> @@ -74,13 +85,14 @@ reporters = { } class Reporter - constructor: (reporterName = "spec", reporterOptions = {}, projectRoot) -> + constructor: (reporterName = "spec", reporterOptions = {}, projectRoot, slowTestThreshold) -> if not (@ instanceof Reporter) return new Reporter(reporterName) @reporterName = reporterName @projectRoot = projectRoot @reporterOptions = reporterOptions + @slowTestThreshold = slowTestThreshold setRunnables: (rootRunnable = {}) -> @runnables = {} @@ -96,14 +108,14 @@ class Reporter _createRunnable: (runnableProps, type, parent) -> runnable = switch type when "suite" - suite = createSuite(runnableProps, parent) + suite = createSuite(runnableProps, parent, @slowTestThreshold) suite.tests = _.map runnableProps.tests, (testProps) => @_createRunnable(testProps, "test", suite) suite.suites = _.map runnableProps.suites, (suiteProps) => @_createRunnable(suiteProps, "suite", suite) suite when "test" - createRunnable(runnableProps, parent) + createRunnable(runnableProps, parent, @slowTestThreshold) else throw new Error("Unknown runnable type: '#{type}'") @@ -166,8 +178,8 @@ class Reporter test.videoTimestamp = test.started - videoStart test - @create = (reporterName, reporterOptions, projectRoot) -> - new Reporter(reporterName, reporterOptions, projectRoot) + @create = (reporterName, reporterOptions, projectRoot, slowTestThreshold) -> + new Reporter(reporterName, reporterOptions, projectRoot, slowTestThreshold) @loadReporter = (reporterName, projectRoot) -> log("loading reporter #{reporterName}")