From 83e595eb8387b2c4ba83480320f8ff0c0ba08d98 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Mon, 7 Mar 2022 15:06:28 -0600 Subject: [PATCH 01/96] wrap options component as a test --- .../lib/plugins/child/run_require_async_child.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/server/lib/plugins/child/run_require_async_child.js b/packages/server/lib/plugins/child/run_require_async_child.js index db7f6f3ee50a..088b18e21d06 100644 --- a/packages/server/lib/plugins/child/run_require_async_child.js +++ b/packages/server/lib/plugins/child/run_require_async_child.js @@ -108,6 +108,8 @@ function run (ipc, configFile, projectRoot) { return } + wrapNonMigratedOptions(options) + if (testingType === 'component') { if (!isValidDevServer((result.component || {}))) { return @@ -161,4 +163,18 @@ function run (ipc, configFile, projectRoot) { ipc.send('ready') } +const optionsNonValidFor10 = { + 'integrationFolder': 'error blah', +} + +function wrapNonMigratedOptions (options) { + Object.entries(optionsNonValidFor10).forEach(([key, value]) => { + Object.defineProperty(options, key, { + set () { + throw new Error(value) + }, + }) + }) +} + module.exports = run From 1dc3d92df914fc8ac49b387113a4c95fe814fd31 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Mon, 7 Mar 2022 16:15:34 -0600 Subject: [PATCH 02/96] show a good looking error with proper stacktrace --- packages/errors/src/errors.ts | 8 ++++++++ packages/graphql/schemas/schema.graphql | 1 + .../server/lib/plugins/child/run_plugins.js | 6 ++++-- .../plugins/child/run_require_async_child.js | 19 ++++++++++++------- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index dd1b8634f0ca..026b8708be4a 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1309,6 +1309,14 @@ export const AllCypressErrors = { ` }, + MIGRATED_OPTION_INVALID: (optionKey: string, err: Error) => { + return errTemplate` + The ${fmt.highlight(optionKey)} option is invalid + + ${fmt.stackTrace(err)} + ` + }, + } as const // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/packages/graphql/schemas/schema.graphql b/packages/graphql/schemas/schema.graphql index 3079f1950d48..7eca42a2c6ef 100644 --- a/packages/graphql/schemas/schema.graphql +++ b/packages/graphql/schemas/schema.graphql @@ -551,6 +551,7 @@ enum ErrorTypeEnum { INVALID_REPORTER_NAME INVOKED_BINARY_OUTSIDE_NPM_MODULE LEGACY_CONFIG_FILE + MIGRATED_OPTION_INVALID MULTIPLE_SUPPORT_FILES_FOUND NODE_VERSION_DEPRECATION_BUNDLED NODE_VERSION_DEPRECATION_SYSTEM diff --git a/packages/server/lib/plugins/child/run_plugins.js b/packages/server/lib/plugins/child/run_plugins.js index 320a1a24f789..1d8bbaaa2d41 100644 --- a/packages/server/lib/plugins/child/run_plugins.js +++ b/packages/server/lib/plugins/child/run_plugins.js @@ -133,12 +133,14 @@ class RunPlugins { }) .catch((err) => { debug('plugins file errored:', err && err.stack) - this.ipc.send('setupTestingType:error', util.serializeError(require('@packages/errors').getError( + const processedError = err.isCypressErr ? err : require('@packages/errors').getError( 'CONFIG_FILE_SETUP_NODE_EVENTS_ERROR', this.requiredFile, initialConfig.testingType, err, - ))) + ) + + this.ipc.send('setupTestingType:error', util.serializeError(processedError)) }) } diff --git a/packages/server/lib/plugins/child/run_require_async_child.js b/packages/server/lib/plugins/child/run_require_async_child.js index 088b18e21d06..a754ec8ad01f 100644 --- a/packages/server/lib/plugins/child/run_require_async_child.js +++ b/packages/server/lib/plugins/child/run_require_async_child.js @@ -163,16 +163,21 @@ function run (ipc, configFile, projectRoot) { ipc.send('ready') } -const optionsNonValidFor10 = { - 'integrationFolder': 'error blah', -} +const optionsNonValidFor10 = ['integrationFolder'] function wrapNonMigratedOptions (options) { - Object.entries(optionsNonValidFor10).forEach(([key, value]) => { + function throwInvalidOptionError (key) { + const errInternal = new Error(`Invalid option ${key}`) + + Error.captureStackTrace(errInternal, throwInvalidOptionError) + const err = require('@packages/errors').getError('MIGRATED_OPTION_INVALID', key, errInternal) + + throw err + } + + optionsNonValidFor10.forEach((key) => { Object.defineProperty(options, key, { - set () { - throw new Error(value) - }, + set: throwInvalidOptionError.bind(null, key), }) }) } From 60b9add66c350ff441908f2a522d82fa11ced395 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Mon, 7 Mar 2022 16:42:22 -0600 Subject: [PATCH 03/96] quick refactor --- .../plugins/child/run_require_async_child.js | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/packages/server/lib/plugins/child/run_require_async_child.js b/packages/server/lib/plugins/child/run_require_async_child.js index a754ec8ad01f..615644d67eb6 100644 --- a/packages/server/lib/plugins/child/run_require_async_child.js +++ b/packages/server/lib/plugins/child/run_require_async_child.js @@ -163,23 +163,44 @@ function run (ipc, configFile, projectRoot) { ipc.send('ready') } -const optionsNonValidFor10 = ['integrationFolder'] +const optionsNonValidFor10Anywhere = ['integrationFolder', 'componentFolder', 'pluginsFile'] +const optionsNonValidFor10Global = ['baseUrl', 'supportFile'] +const optionsNonValidFor10Component = ['baseUrl'] + +function throwInvalidOptionError (key) { + const errInternal = new Error() + + Error.captureStackTrace(errInternal, throwInvalidOptionError) + const err = require('@packages/errors').getError('MIGRATED_OPTION_INVALID', key, errInternal) + + throw err +} + +function setInvalidPropSetterWarning (opts, key) { + Object.defineProperty(opts, key, { + set: throwInvalidOptionError.bind(null, key), + }) +} function wrapNonMigratedOptions (options) { - function throwInvalidOptionError (key) { - const errInternal = new Error(`Invalid option ${key}`) + optionsNonValidFor10Global.forEach((key) => { + setInvalidPropSetterWarning(options, key) + }) - Error.captureStackTrace(errInternal, throwInvalidOptionError) - const err = require('@packages/errors').getError('MIGRATED_OPTION_INVALID', key, errInternal) + optionsNonValidFor10Anywhere.forEach((key) => { + setInvalidPropSetterWarning(options, key) - throw err - } + const testingTypes = ['component', 'e2e'] - optionsNonValidFor10.forEach((key) => { - Object.defineProperty(options, key, { - set: throwInvalidOptionError.bind(null, key), + testingTypes.forEach((testingType) => { + options[testingType] = options[testingType] || {} + setInvalidPropSetterWarning(options[testingType], key) }) }) + + optionsNonValidFor10Component.forEach((key) => { + setInvalidPropSetterWarning(options.component, key) + }) } module.exports = run From 96cdd84d0f2c3a9e413e6b2f65fe55e7c1822b4a Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Mon, 7 Mar 2022 17:07:18 -0600 Subject: [PATCH 04/96] add nice error structure --- packages/errors/src/errors.ts | 57 +++++++++++++++++-- .../plugins/child/run_require_async_child.js | 5 -- 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index 026b8708be4a..ec2005b1a479 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1310,17 +1310,62 @@ export const AllCypressErrors = { }, MIGRATED_OPTION_INVALID: (optionKey: string, err: Error) => { - return errTemplate` - The ${fmt.highlight(optionKey)} option is invalid + if (optionKey === 'baseUrl') { + return errTemplate` + The option ${fmt.highlight(optionKey)} is no longer supported on the root of the config object. + + Since it is only relevant in e2e testing, you will need to move it in the e2e object. + + ${fmt.stackTrace(err)} + ` + } + + if (optionKey === 'integrationFolder' || optionKey.endsWith('.integrationFolder') + || optionKey === 'componentFolder' || optionKey.endsWith('.componentFolder')) { + return errTemplate` + The option ${fmt.highlight(optionKey)} is no longer supported. + It was merged with ${fmt.highlight('testFiles')} into the ${fmt.highlight('specFiles')} option. + NOTE: ${fmt.highlight('testFiles')} has to be set as a member of the ${fmt.highlight('e2e')} or ${fmt.highlight('component')} property. + ${fmt.stackTrace(err)} ` - }, + } -} as const + if (optionKey === 'testFiles') { + return errTemplate` + The option ${fmt.highlight(optionKey)} is no longer supported. + It was merged with ${fmt.highlight('integrationFolder')} into the ${fmt.highlight('specFiles')} option. + + ${fmt.stackTrace(err)} + ` + } -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const _typeCheck: Record ErrTemplateResult> = AllCypressErrors + if (optionKey === 'supportFile') { + return errTemplate` + The option ${fmt.highlight(optionKey)} is no longer supported in the root of the config object. + Set a specific ${fmt.highlight('supportFile')} in the ${fmt.highlight('e2e')} or ${fmt.highlight('component')} object. + + ${fmt.stackTrace(err)} + ` + } + + if (optionKey === 'pluginFile' || optionKey.endsWith('.pluginsFile')) { + return errTemplate` + The option ${fmt.highlight(optionKey)} is no longer supported. + All plugins are now run within the config file using the ${fmt.highlight('setupNodeEvents()')} function. + + ${fmt.stackTrace(err)}` + } + + return errTemplate` + The option ${fmt.highlight(optionKey)} is no longer supported. + + ${fmt.stackTrace(err)} + ` + }, + +} type AllCypressErrorObj = typeof AllCypressErrors diff --git a/packages/server/lib/plugins/child/run_require_async_child.js b/packages/server/lib/plugins/child/run_require_async_child.js index 615644d67eb6..a2b1d109a16d 100644 --- a/packages/server/lib/plugins/child/run_require_async_child.js +++ b/packages/server/lib/plugins/child/run_require_async_child.js @@ -165,7 +165,6 @@ function run (ipc, configFile, projectRoot) { const optionsNonValidFor10Anywhere = ['integrationFolder', 'componentFolder', 'pluginsFile'] const optionsNonValidFor10Global = ['baseUrl', 'supportFile'] -const optionsNonValidFor10Component = ['baseUrl'] function throwInvalidOptionError (key) { const errInternal = new Error() @@ -197,10 +196,6 @@ function wrapNonMigratedOptions (options) { setInvalidPropSetterWarning(options[testingType], key) }) }) - - optionsNonValidFor10Component.forEach((key) => { - setInvalidPropSetterWarning(options.component, key) - }) } module.exports = run From ae3d86faa5064d64490ba3bad11b7e8f605c39af Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Mon, 7 Mar 2022 17:38:45 -0600 Subject: [PATCH 05/96] prevent using spread or clone to update the values --- .../server/lib/plugins/child/run_plugins.js | 60 +++++++++++++++++++ .../plugins/child/run_require_async_child.js | 37 ------------ 2 files changed, 60 insertions(+), 37 deletions(-) diff --git a/packages/server/lib/plugins/child/run_plugins.js b/packages/server/lib/plugins/child/run_plugins.js index 1d8bbaaa2d41..cb03845fc72e 100644 --- a/packages/server/lib/plugins/child/run_plugins.js +++ b/packages/server/lib/plugins/child/run_plugins.js @@ -114,6 +114,8 @@ class RunPlugins { Promise .try(() => { debug('Calling setupNodeEvents') + // setup all setters for 10.X+ non-supported config options + wrapNonMigratedOptions(initialConfig) return setupNodeEvents(registerChildEvent, initialConfig) }) @@ -125,6 +127,7 @@ class RunPlugins { }) .then((modifiedCfg) => { debug('plugins file successfully loaded') + modifiedCfg && validateNonMigratedOptions(modifiedCfg) this.ipc.send('setupTestingType:reply', { setupConfig: modifiedCfg, registrations: this.registrations, @@ -261,4 +264,61 @@ class RunPlugins { } } +const optionsNonValidFor10Anywhere = ['integrationFolder', 'componentFolder', 'pluginsFile'] +const optionsNonValidFor10Global = ['baseUrl', 'supportFile'] + +function throwInvalidOptionError (key, stackBoundary = throwInvalidOptionError) { + const errInternal = new Error() + + Error.captureStackTrace(errInternal, stackBoundary) + const err = require('@packages/errors').getError('MIGRATED_OPTION_INVALID', key, errInternal) + + throw err +} + +function setInvalidPropSetterWarning (opts, key, keyForError = key) { + Object.defineProperty(opts, key, { + set: throwInvalidOptionError.bind(null, keyForError), + }) +} + +function wrapNonMigratedOptions (options) { + optionsNonValidFor10Global.forEach((key) => { + setInvalidPropSetterWarning(options, key) + }) + + optionsNonValidFor10Anywhere.forEach((key) => { + setInvalidPropSetterWarning(options, key) + + const testingTypes = ['component', 'e2e'] + + testingTypes.forEach((testingType) => { + options[testingType] = options[testingType] || {} + setInvalidPropSetterWarning(options[testingType], key, `${testingType}.${key}`) + }) + }) +} + +function validateNonMigratedOptions (options) { + optionsNonValidFor10Global.forEach((key) => { + if (options[key]) { + throwInvalidOptionError(key) + } + }) + + optionsNonValidFor10Anywhere.forEach((key) => { + const testingTypes = ['component', 'e2e'] + + if (options[key]) { + throwInvalidOptionError(key) + } + + testingTypes.forEach((testingType) => { + if (options[testingType] && options[testingType][key]) { + throwInvalidOptionError(`${testingType}.${key}`) + } + }) + }) +} + exports.RunPlugins = RunPlugins diff --git a/packages/server/lib/plugins/child/run_require_async_child.js b/packages/server/lib/plugins/child/run_require_async_child.js index a2b1d109a16d..db7f6f3ee50a 100644 --- a/packages/server/lib/plugins/child/run_require_async_child.js +++ b/packages/server/lib/plugins/child/run_require_async_child.js @@ -108,8 +108,6 @@ function run (ipc, configFile, projectRoot) { return } - wrapNonMigratedOptions(options) - if (testingType === 'component') { if (!isValidDevServer((result.component || {}))) { return @@ -163,39 +161,4 @@ function run (ipc, configFile, projectRoot) { ipc.send('ready') } -const optionsNonValidFor10Anywhere = ['integrationFolder', 'componentFolder', 'pluginsFile'] -const optionsNonValidFor10Global = ['baseUrl', 'supportFile'] - -function throwInvalidOptionError (key) { - const errInternal = new Error() - - Error.captureStackTrace(errInternal, throwInvalidOptionError) - const err = require('@packages/errors').getError('MIGRATED_OPTION_INVALID', key, errInternal) - - throw err -} - -function setInvalidPropSetterWarning (opts, key) { - Object.defineProperty(opts, key, { - set: throwInvalidOptionError.bind(null, key), - }) -} - -function wrapNonMigratedOptions (options) { - optionsNonValidFor10Global.forEach((key) => { - setInvalidPropSetterWarning(options, key) - }) - - optionsNonValidFor10Anywhere.forEach((key) => { - setInvalidPropSetterWarning(options, key) - - const testingTypes = ['component', 'e2e'] - - testingTypes.forEach((testingType) => { - options[testingType] = options[testingType] || {} - setInvalidPropSetterWarning(options[testingType], key) - }) - }) -} - module.exports = run From c085d462f75350480cab52325ff3bced2273494e Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Mon, 7 Mar 2022 17:39:52 -0600 Subject: [PATCH 06/96] add coments --- packages/server/lib/plugins/child/run_plugins.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/server/lib/plugins/child/run_plugins.js b/packages/server/lib/plugins/child/run_plugins.js index cb03845fc72e..7b011caefa2d 100644 --- a/packages/server/lib/plugins/child/run_plugins.js +++ b/packages/server/lib/plugins/child/run_plugins.js @@ -264,7 +264,10 @@ class RunPlugins { } } +// values not allowed in 10.X+ in the root, e2e and component config const optionsNonValidFor10Anywhere = ['integrationFolder', 'componentFolder', 'pluginsFile'] + +// values not allowed in 10.X+ in the root that have moved in one of the testingTypes const optionsNonValidFor10Global = ['baseUrl', 'supportFile'] function throwInvalidOptionError (key, stackBoundary = throwInvalidOptionError) { From 46f539a36bddabacfae669f1dc7b6f248d97f470 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Mon, 7 Mar 2022 17:40:42 -0600 Subject: [PATCH 07/96] make the comments visible in JSDOc --- packages/server/lib/plugins/child/run_plugins.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/server/lib/plugins/child/run_plugins.js b/packages/server/lib/plugins/child/run_plugins.js index 7b011caefa2d..df47823cc637 100644 --- a/packages/server/lib/plugins/child/run_plugins.js +++ b/packages/server/lib/plugins/child/run_plugins.js @@ -264,10 +264,14 @@ class RunPlugins { } } -// values not allowed in 10.X+ in the root, e2e and component config +/** + * Values not allowed in 10.X+ in the root, e2e and component config + */ const optionsNonValidFor10Anywhere = ['integrationFolder', 'componentFolder', 'pluginsFile'] -// values not allowed in 10.X+ in the root that have moved in one of the testingTypes +/** + * values not allowed in 10.X+ in the root that have moved in one of the testingTypes + */ const optionsNonValidFor10Global = ['baseUrl', 'supportFile'] function throwInvalidOptionError (key, stackBoundary = throwInvalidOptionError) { From 5c43b6d1590279e55bf1bb20ee1226592b0e5114 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 8 Mar 2022 09:17:49 -0600 Subject: [PATCH 08/96] add e2e tests --- .../cypress/e2e/support/e2eProjectDirs.ts | 2 ++ .../e2e/config-files-error-handling.cy.ts | 22 +++++++++++++++++++ .../server/lib/plugins/child/run_plugins.js | 4 ++-- .../cypress.config.js | 11 ++++++++++ .../cypress.config.js | 8 +++++++ 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 system-tests/projects/config-update-non-migrated-value-clone/cypress.config.js create mode 100644 system-tests/projects/config-update-non-migrated-value/cypress.config.js diff --git a/packages/frontend-shared/cypress/e2e/support/e2eProjectDirs.ts b/packages/frontend-shared/cypress/e2e/support/e2eProjectDirs.ts index d8a5e7bfee1c..ecc1df65ae7b 100644 --- a/packages/frontend-shared/cypress/e2e/support/e2eProjectDirs.ts +++ b/packages/frontend-shared/cypress/e2e/support/e2eProjectDirs.ts @@ -5,6 +5,8 @@ export const e2eProjectDirs = [ 'busted-support-file', 'chrome-browser-preferences', 'component-tests', + 'config-update-non-migrated-value', + 'config-update-non-migrated-value-clone', 'config-with-custom-file-js', 'config-with-custom-file-ts', 'config-with-import-error', diff --git a/packages/launchpad/cypress/e2e/config-files-error-handling.cy.ts b/packages/launchpad/cypress/e2e/config-files-error-handling.cy.ts index 260aa40c9cd4..5a1bcee5dd5a 100644 --- a/packages/launchpad/cypress/e2e/config-files-error-handling.cy.ts +++ b/packages/launchpad/cypress/e2e/config-files-error-handling.cy.ts @@ -149,4 +149,26 @@ describe('Launchpad: Error System Tests', () => { cy.get('[data-testid="error-code-frame"]').should('contain', 'cypress.config.js:4:23') }) + + it('throws an error when in setupNodeEvents updating a config value that was removed in 10.X', () => { + cy.scaffoldProject('config-update-non-migrated-value') + cy.openProject('config-update-non-migrated-value') + cy.visitLaunchpad() + cy.findByText('E2E Testing').click() + cy.get('h1').should('contain', 'Error Loading Config') + cy.percySnapshot() + + cy.get('[data-testid="error-code-frame"]').should('contain', 'cypress.config.js:5:32') + }) + + it('throws an error when in setupNodeEvents updating a config value on a clone of config that was removed in 10.X', () => { + cy.scaffoldProject('config-update-non-migrated-value-clone') + cy.openProject('config-update-non-migrated-value-clone') + cy.visitLaunchpad() + cy.findByText('E2E Testing').click() + cy.get('h1').should('contain', 'Error Loading Config') + cy.percySnapshot() + + cy.get('[data-cy="alert-body"]').should('contain', 'integrationFolder') + }) }) diff --git a/packages/server/lib/plugins/child/run_plugins.js b/packages/server/lib/plugins/child/run_plugins.js index df47823cc637..3a680d6b2740 100644 --- a/packages/server/lib/plugins/child/run_plugins.js +++ b/packages/server/lib/plugins/child/run_plugins.js @@ -274,10 +274,10 @@ const optionsNonValidFor10Anywhere = ['integrationFolder', 'componentFolder', 'p */ const optionsNonValidFor10Global = ['baseUrl', 'supportFile'] -function throwInvalidOptionError (key, stackBoundary = throwInvalidOptionError) { +function throwInvalidOptionError (key) { const errInternal = new Error() - Error.captureStackTrace(errInternal, stackBoundary) + Error.captureStackTrace(errInternal, throwInvalidOptionError) const err = require('@packages/errors').getError('MIGRATED_OPTION_INVALID', key, errInternal) throw err diff --git a/system-tests/projects/config-update-non-migrated-value-clone/cypress.config.js b/system-tests/projects/config-update-non-migrated-value-clone/cypress.config.js new file mode 100644 index 000000000000..75d4b2df5e50 --- /dev/null +++ b/system-tests/projects/config-update-non-migrated-value-clone/cypress.config.js @@ -0,0 +1,11 @@ +module.exports = { + e2e: { + supportFile: false, + setupNodeEvents (on, config) { + return { + ...config, + integrationFolder: 'path/to/integration/folder', + } + }, + }, +} diff --git a/system-tests/projects/config-update-non-migrated-value/cypress.config.js b/system-tests/projects/config-update-non-migrated-value/cypress.config.js new file mode 100644 index 000000000000..37cde0d63cec --- /dev/null +++ b/system-tests/projects/config-update-non-migrated-value/cypress.config.js @@ -0,0 +1,8 @@ +module.exports = { + e2e: { + supportFile: false, + setupNodeEvents (on, config) { + config.integrationFolder = 'path/to/integration/folder' + }, + }, +} From ee37eca42e1e9a9c7546b8cb5fa06f617645eb3e Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 8 Mar 2022 10:15:16 -0600 Subject: [PATCH 09/96] have the breaking options only in one place --- packages/errors/src/brokenOptionsMap.ts | 63 +++++++++++++++++++ packages/errors/src/errors.ts | 61 ++++-------------- packages/errors/src/index.ts | 2 + .../cypress/e2e/support/e2eProjectDirs.ts | 1 + .../server/lib/plugins/child/run_plugins.js | 27 +++++--- .../cypress.config.js | 8 +++ 6 files changed, 105 insertions(+), 57 deletions(-) create mode 100644 packages/errors/src/brokenOptionsMap.ts create mode 100644 system-tests/projects/config-update-non-migrated-value-e2e/cypress.config.js diff --git a/packages/errors/src/brokenOptionsMap.ts b/packages/errors/src/brokenOptionsMap.ts new file mode 100644 index 000000000000..167b5072de27 --- /dev/null +++ b/packages/errors/src/brokenOptionsMap.ts @@ -0,0 +1,63 @@ +import { errPartial, fmt } from './errTemplate' + +export function errPrefixRootOnly (optionKey: string) { + return errPartial` + ${fmt.highlight('setupNodeEvents()')} is updating the option ${fmt.highlight(optionKey)}. + + Since 10.0, this option is no longer supported on the root of the config object. + ` +} + +export function errPrefix (optionKey: string) { + return errPartial` + ${fmt.highlight('setupNodeEvents()')} is updating the option ${fmt.highlight(optionKey)}. + + Since 10.0, this option is no longer supported. + ` +} + +function getSpecPatternAdditionalHelp (optionKey: string) { + const mergedOptionKey = 'testFiles' === optionKey ? 'integrationFolder' : 'testFiles' + + return errPartial` + It was merged with ${fmt.highlight(mergedOptionKey)} into the ${fmt.highlight('specPattern')} option. + + NOTE: ${fmt.highlight('specPattern')} has to be set as a member of the ${fmt.highlight('e2e')} or ${fmt.highlight('component')} property. + ` +} + +/** + * Only listing of values that have broken configs between 9.X and 10.X + * `brokenOnlyAtRoot` means that the option is only broken + * at the root of the config object and can still + * be used in e2e or component configs + */ +export const brokenOptionsMap = { + baseUrl: { + brokenOnlyAtRoot: true, + additionalHelp: errPartial` + Since 10.0, this option is no longer supported on the root of the config object. + `, + }, + supportFile: { + brokenOnlyAtRoot: true, + additionalHelp: errPartial` + Set a specific ${fmt.highlight('supportFile')} in the ${fmt.highlight('e2e')} or ${fmt.highlight('component')} object. + `, + }, + + integrationFolder: { + brokenOnlyAtRoot: false, + additionalHelp: getSpecPatternAdditionalHelp('integrationFolder'), + }, + + componentFolder: { + brokenOnlyAtRoot: false, + additionalHelp: getSpecPatternAdditionalHelp('componentFolder'), + }, + + testFiles: { + brokenOnlyAtRoot: false, + additionalHelp: getSpecPatternAdditionalHelp('testFiles'), + }, +} as const diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index ec2005b1a479..b7a28552418d 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -11,6 +11,7 @@ import { errPartial, errTemplate, fmt, theme, PartialErr } from './errTemplate' import { stackWithoutMessage } from './stackUtils' import type { ClonedError, ConfigValidationFailureInfo, CypressError, ErrTemplateResult, ErrorLike } from './errorTypes' +import { brokenOptionsMap, errPrefix, errPrefixRootOnly } from './brokenOptionsMap' const ansi_up = new AU() @@ -1309,60 +1310,24 @@ export const AllCypressErrors = { ` }, - MIGRATED_OPTION_INVALID: (optionKey: string, err: Error) => { - if (optionKey === 'baseUrl') { - return errTemplate` - The option ${fmt.highlight(optionKey)} is no longer supported on the root of the config object. + MIGRATED_OPTION_INVALID: (optionKey: string, err?: Error) => { + const stackTrace = err ? fmt.stackTrace(err) : null - Since it is only relevant in e2e testing, you will need to move it in the e2e object. - - ${fmt.stackTrace(err)} - ` - } + // some keys come prefixed with a `component.` or `e2e.` but they are not referenced + // in the errors maps with this prefix. strip it out. + const rootKey = optionKey.replace(/^(component|e2e)\./, '') as keyof typeof brokenOptionsMap - if (optionKey === 'integrationFolder' || optionKey.endsWith('.integrationFolder') - || optionKey === 'componentFolder' || optionKey.endsWith('.componentFolder')) { - return errTemplate` - The option ${fmt.highlight(optionKey)} is no longer supported. - It was merged with ${fmt.highlight('testFiles')} into the ${fmt.highlight('specFiles')} option. + const errorObj = brokenOptionsMap[rootKey] - NOTE: ${fmt.highlight('testFiles')} has to be set as a member of the ${fmt.highlight('e2e')} or ${fmt.highlight('component')} property. - - ${fmt.stackTrace(err)} - ` - } - - if (optionKey === 'testFiles') { - return errTemplate` - The option ${fmt.highlight(optionKey)} is no longer supported. - It was merged with ${fmt.highlight('integrationFolder')} into the ${fmt.highlight('specFiles')} option. - - ${fmt.stackTrace(err)} - ` - } - - if (optionKey === 'supportFile') { - return errTemplate` - The option ${fmt.highlight(optionKey)} is no longer supported in the root of the config object. - Set a specific ${fmt.highlight('supportFile')} in the ${fmt.highlight('e2e')} or ${fmt.highlight('component')} object. - - ${fmt.stackTrace(err)} - ` - } - - if (optionKey === 'pluginFile' || optionKey.endsWith('.pluginsFile')) { - return errTemplate` - The option ${fmt.highlight(optionKey)} is no longer supported. - All plugins are now run within the config file using the ${fmt.highlight('setupNodeEvents()')} function. - - ${fmt.stackTrace(err)}` - } + const message = errorObj.brokenOnlyAtRoot ? errPrefixRootOnly(optionKey) : errPrefix(optionKey) return errTemplate` - The option ${fmt.highlight(optionKey)} is no longer supported. + ${message} - ${fmt.stackTrace(err)} - ` + ${errorObj.additionalHelp} + + ${stackTrace} + ` }, } diff --git a/packages/errors/src/index.ts b/packages/errors/src/index.ts index 63d3c1ffcdb8..269ef1e3d568 100644 --- a/packages/errors/src/index.ts +++ b/packages/errors/src/index.ts @@ -10,4 +10,6 @@ export * from './errors' export * from './errorTypes' +export * from './brokenOptionsMap' + export default errorsApi diff --git a/packages/frontend-shared/cypress/e2e/support/e2eProjectDirs.ts b/packages/frontend-shared/cypress/e2e/support/e2eProjectDirs.ts index ecc1df65ae7b..c215fcd3f12e 100644 --- a/packages/frontend-shared/cypress/e2e/support/e2eProjectDirs.ts +++ b/packages/frontend-shared/cypress/e2e/support/e2eProjectDirs.ts @@ -7,6 +7,7 @@ export const e2eProjectDirs = [ 'component-tests', 'config-update-non-migrated-value', 'config-update-non-migrated-value-clone', + 'config-update-non-migrated-value-e2e', 'config-with-custom-file-js', 'config-with-custom-file-ts', 'config-with-import-error', diff --git a/packages/server/lib/plugins/child/run_plugins.js b/packages/server/lib/plugins/child/run_plugins.js index 3a680d6b2740..ef7b3980ebaa 100644 --- a/packages/server/lib/plugins/child/run_plugins.js +++ b/packages/server/lib/plugins/child/run_plugins.js @@ -14,6 +14,7 @@ const resolve = require('../../util/resolve') const browserLaunch = require('./browser_launch') const util = require('../util') const validateEvent = require('./validate_event') +const errors = require('@packages/errors') const UNDEFINED_SERIALIZED = '__cypress_undefined__' @@ -267,18 +268,26 @@ class RunPlugins { /** * Values not allowed in 10.X+ in the root, e2e and component config */ -const optionsNonValidFor10Anywhere = ['integrationFolder', 'componentFolder', 'pluginsFile'] +const optionsNonValidFor10Anywhere = Object.keys(errors.brokenOptionsMap).filter((key) => { + return errors.brokenOptionsMap[key].brokenOnlyAtRoot === false +}) /** - * values not allowed in 10.X+ in the root that have moved in one of the testingTypes + * Values not allowed in 10.X+ in the root that have moved in one of the testingTypes */ -const optionsNonValidFor10Global = ['baseUrl', 'supportFile'] +const optionsNonValidFor10Root = Object.keys(errors.brokenOptionsMap).filter((key) => { + return errors.brokenOptionsMap[key].brokenOnlyAtRoot +}) + +function getNonMigratedOptionsErr (key, errInternal) { + return errors.getError('MIGRATED_OPTION_INVALID', key, errInternal) +} function throwInvalidOptionError (key) { const errInternal = new Error() Error.captureStackTrace(errInternal, throwInvalidOptionError) - const err = require('@packages/errors').getError('MIGRATED_OPTION_INVALID', key, errInternal) + const err = getNonMigratedOptionsErr(key, errInternal) throw err } @@ -290,7 +299,7 @@ function setInvalidPropSetterWarning (opts, key, keyForError = key) { } function wrapNonMigratedOptions (options) { - optionsNonValidFor10Global.forEach((key) => { + optionsNonValidFor10Root.forEach((key) => { setInvalidPropSetterWarning(options, key) }) @@ -307,9 +316,9 @@ function wrapNonMigratedOptions (options) { } function validateNonMigratedOptions (options) { - optionsNonValidFor10Global.forEach((key) => { + optionsNonValidFor10Root.forEach((key) => { if (options[key]) { - throwInvalidOptionError(key) + throw getNonMigratedOptionsErr(key) } }) @@ -317,12 +326,12 @@ function validateNonMigratedOptions (options) { const testingTypes = ['component', 'e2e'] if (options[key]) { - throwInvalidOptionError(key) + throw getNonMigratedOptionsErr(key) } testingTypes.forEach((testingType) => { if (options[testingType] && options[testingType][key]) { - throwInvalidOptionError(`${testingType}.${key}`) + throw getNonMigratedOptionsErr(`${testingType}.${key}`) } }) }) diff --git a/system-tests/projects/config-update-non-migrated-value-e2e/cypress.config.js b/system-tests/projects/config-update-non-migrated-value-e2e/cypress.config.js new file mode 100644 index 000000000000..fe61ca3c919f --- /dev/null +++ b/system-tests/projects/config-update-non-migrated-value-e2e/cypress.config.js @@ -0,0 +1,8 @@ +module.exports = { + e2e: { + supportFile: false, + setupNodeEvents (on, config) { + config.e2e.integrationFolder = 'path/to/integration/folder' + }, + }, +} From 4838f0416a24a1e441d4fe81216b57178674e8ff Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 8 Mar 2022 10:21:13 -0600 Subject: [PATCH 10/96] add test and duplictae --- .../cypress/e2e/config-files-error-handling.cy.ts | 11 +++++++++++ packages/server/lib/plugins/child/run_plugins.js | 13 ++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/launchpad/cypress/e2e/config-files-error-handling.cy.ts b/packages/launchpad/cypress/e2e/config-files-error-handling.cy.ts index 5a1bcee5dd5a..34d785229aa9 100644 --- a/packages/launchpad/cypress/e2e/config-files-error-handling.cy.ts +++ b/packages/launchpad/cypress/e2e/config-files-error-handling.cy.ts @@ -171,4 +171,15 @@ describe('Launchpad: Error System Tests', () => { cy.get('[data-cy="alert-body"]').should('contain', 'integrationFolder') }) + + it('throws an error when in setupNodeEvents updating an e2e config value that was removed in 10.X', () => { + cy.scaffoldProject('config-update-non-migrated-value-e2e') + cy.openProject('config-update-non-migrated-value-e2e') + cy.visitLaunchpad() + cy.findByText('E2E Testing').click() + cy.get('h1').should('contain', 'Error Loading Config') + cy.percySnapshot() + + cy.get('[data-testid="error-code-frame"]').should('contain', 'cypress.config.js:5:36') + }) }) diff --git a/packages/server/lib/plugins/child/run_plugins.js b/packages/server/lib/plugins/child/run_plugins.js index ef7b3980ebaa..75ca20d76815 100644 --- a/packages/server/lib/plugins/child/run_plugins.js +++ b/packages/server/lib/plugins/child/run_plugins.js @@ -14,7 +14,6 @@ const resolve = require('../../util/resolve') const browserLaunch = require('./browser_launch') const util = require('../util') const validateEvent = require('./validate_event') -const errors = require('@packages/errors') const UNDEFINED_SERIALIZED = '__cypress_undefined__' @@ -268,19 +267,15 @@ class RunPlugins { /** * Values not allowed in 10.X+ in the root, e2e and component config */ -const optionsNonValidFor10Anywhere = Object.keys(errors.brokenOptionsMap).filter((key) => { - return errors.brokenOptionsMap[key].brokenOnlyAtRoot === false -}) +const optionsNonValidFor10Anywhere = ['integrationFolder', 'componentFolder', 'pluginsFile'] /** - * Values not allowed in 10.X+ in the root that have moved in one of the testingTypes + * values not allowed in 10.X+ in the root that have moved in one of the testingTypes */ -const optionsNonValidFor10Root = Object.keys(errors.brokenOptionsMap).filter((key) => { - return errors.brokenOptionsMap[key].brokenOnlyAtRoot -}) +const optionsNonValidFor10Root = ['baseUrl', 'supportFile'] function getNonMigratedOptionsErr (key, errInternal) { - return errors.getError('MIGRATED_OPTION_INVALID', key, errInternal) + return require('@packages/errors').getError('MIGRATED_OPTION_INVALID', key, errInternal) } function throwInvalidOptionError (key) { From d8d007fa565e4461597d096519586c34499848d5 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 8 Mar 2022 10:26:13 -0600 Subject: [PATCH 11/96] if the 2 arrays are disconnect throw an understandable error --- packages/errors/src/errors.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index b7a28552418d..cd94fd0dd3be 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1319,6 +1319,18 @@ export const AllCypressErrors = { const errorObj = brokenOptionsMap[rootKey] + if (!errorObj) { + return errTemplate` + The ${fmt.highlight(optionKey)} option is invalid. + + The map of broken options is missing a mapping for ${fmt.highlight(rootKey)}. + + Please consider adding an issue to the [Cypress Github repo](https://github.com/cypress-io/cypress/issues/new/choose). + + ${stackTrace} + ` + } + const message = errorObj.brokenOnlyAtRoot ? errPrefixRootOnly(optionKey) : errPrefix(optionKey) return errTemplate` From 1789bab69c41c56b9aea569a4e8e7786364b5f21 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 8 Mar 2022 11:57:46 -0600 Subject: [PATCH 12/96] update generated project files --- packages/frontend-shared/cypress/e2e/support/e2eProjectDirs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend-shared/cypress/e2e/support/e2eProjectDirs.ts b/packages/frontend-shared/cypress/e2e/support/e2eProjectDirs.ts index 589c98f935a9..954b4e5ccd9b 100644 --- a/packages/frontend-shared/cypress/e2e/support/e2eProjectDirs.ts +++ b/packages/frontend-shared/cypress/e2e/support/e2eProjectDirs.ts @@ -46,8 +46,8 @@ export const e2eProjectDirs = [ 'migration-e2e-coffeescript', 'migration-e2e-component-default-everything', 'migration-e2e-component-default-test-files', - 'migration-e2e-component-with-json-files', 'migration-e2e-component-default-with-types', + 'migration-e2e-component-with-json-files', 'migration-e2e-custom-integration', 'migration-e2e-custom-test-files', 'migration-e2e-defaults', From 603b0363c89c2d81d909dae40f6ad18da34760bd Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 8 Mar 2022 12:09:57 -0600 Subject: [PATCH 13/96] add a migration error snapshot --- .../errors/test/unit/visualSnapshotErrors_spec.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/errors/test/unit/visualSnapshotErrors_spec.ts b/packages/errors/test/unit/visualSnapshotErrors_spec.ts index 6fa6c932eb43..6bfd273b6187 100644 --- a/packages/errors/test/unit/visualSnapshotErrors_spec.ts +++ b/packages/errors/test/unit/visualSnapshotErrors_spec.ts @@ -1096,5 +1096,18 @@ describe('visual error templates', () => { default: [makeErr()], } }, + MIGRATED_OPTION_INVALID: () => { + const keyChanging = ['integrationFolder', 'componentFolder', 'testFiles', 'pluginsFile', 'supportFile', 'baseUrl'], + const err = makeErr() + + return keyChanging.reduce((acc: ErrorGenerator<'MIGRATED_OPTION_INVALID'>, key) => { + acc[key] = [key, err] + acc[`${key}PostValidation`] = [key] + + return acc + }, { + default: ['integrationFolder', makeErr()], + }) + }, }) }) From 11ed1af8f426c33b83c1545bf70ba5e994542d8a Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 8 Mar 2022 12:45:52 -0600 Subject: [PATCH 14/96] add error snapshots --- .../MIGRATED_OPTION_INVALID - baseUrl.html | 46 ++++++++++++++++++ ...PTION_INVALID - baseUrlPostValidation.html | 42 ++++++++++++++++ ...ATED_OPTION_INVALID - componentFolder.html | 48 +++++++++++++++++++ ...VALID - componentFolderPostValidation.html | 44 +++++++++++++++++ ...ED_OPTION_INVALID - integrationFolder.html | 48 +++++++++++++++++++ ...LID - integrationFolderPostValidation.html | 44 +++++++++++++++++ ...MIGRATED_OPTION_INVALID - pluginsFile.html | 46 ++++++++++++++++++ ...N_INVALID - pluginsFilePostValidation.html | 42 ++++++++++++++++ ...MIGRATED_OPTION_INVALID - supportFile.html | 46 ++++++++++++++++++ ...N_INVALID - supportFilePostValidation.html | 42 ++++++++++++++++ .../MIGRATED_OPTION_INVALID - testFiles.html | 48 +++++++++++++++++++ ...ION_INVALID - testFilesPostValidation.html | 44 +++++++++++++++++ .../MIGRATED_OPTION_INVALID.html | 48 +++++++++++++++++++ 13 files changed, 588 insertions(+) create mode 100644 packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrl.html create mode 100644 packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrlPostValidation.html create mode 100644 packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolder.html create mode 100644 packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolderPostValidation.html create mode 100644 packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolder.html create mode 100644 packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolderPostValidation.html create mode 100644 packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFile.html create mode 100644 packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFilePostValidation.html create mode 100644 packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - supportFile.html create mode 100644 packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - supportFilePostValidation.html create mode 100644 packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFiles.html create mode 100644 packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFilesPostValidation.html create mode 100644 packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID.html diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrl.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrl.html new file mode 100644 index 000000000000..752cf6a939ff --- /dev/null +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrl.html @@ -0,0 +1,46 @@ + + + + + + + + + + + +
setupNodeEvents() is updating the option baseUrl.
+
+Since 10.0, this option is no longer supported on the root of the config object. 
+
+Since 10.0, this option is no longer supported on the root of the config object. 
+
+Error: fail whale
+    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrlPostValidation.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrlPostValidation.html new file mode 100644 index 000000000000..29b79fff051a --- /dev/null +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrlPostValidation.html @@ -0,0 +1,42 @@ + + + + + + + + + + + +
setupNodeEvents() is updating the option baseUrl.
+
+Since 10.0, this option is no longer supported on the root of the config object. 
+
+Since 10.0, this option is no longer supported on the root of the config object. 
+
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolder.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolder.html new file mode 100644 index 000000000000..02e1327ca977 --- /dev/null +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolder.html @@ -0,0 +1,48 @@ + + + + + + + + + + + +
setupNodeEvents() is updating the option componentFolder.
+
+Since 10.0, this option is no longer supported. 
+
+It was merged with testFiles into the specPattern option.
+
+NOTE: specPattern has to be set as a member of the e2e or component property.
+
+Error: fail whale
+    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolderPostValidation.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolderPostValidation.html new file mode 100644 index 000000000000..f4eabbd7dcf0 --- /dev/null +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolderPostValidation.html @@ -0,0 +1,44 @@ + + + + + + + + + + + +
setupNodeEvents() is updating the option componentFolder.
+
+Since 10.0, this option is no longer supported. 
+
+It was merged with testFiles into the specPattern option.
+
+NOTE: specPattern has to be set as a member of the e2e or component property.
+
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolder.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolder.html new file mode 100644 index 000000000000..a45fad1f3261 --- /dev/null +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolder.html @@ -0,0 +1,48 @@ + + + + + + + + + + + +
setupNodeEvents() is updating the option integrationFolder.
+
+Since 10.0, this option is no longer supported. 
+
+It was merged with testFiles into the specPattern option.
+
+NOTE: specPattern has to be set as a member of the e2e or component property.
+
+Error: fail whale
+    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolderPostValidation.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolderPostValidation.html new file mode 100644 index 000000000000..a56b690292a5 --- /dev/null +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolderPostValidation.html @@ -0,0 +1,44 @@ + + + + + + + + + + + +
setupNodeEvents() is updating the option integrationFolder.
+
+Since 10.0, this option is no longer supported. 
+
+It was merged with testFiles into the specPattern option.
+
+NOTE: specPattern has to be set as a member of the e2e or component property.
+
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFile.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFile.html new file mode 100644 index 000000000000..41f611383d6b --- /dev/null +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFile.html @@ -0,0 +1,46 @@ + + + + + + + + + + + +
The pluginsFile option is invalid.
+
+The map of broken options is missing a mapping for pluginsFile.
+
+Please consider adding an issue to the [Cypress Github repo](https://github.com/cypress-io/cypress/issues/new/choose).
+
+Error: fail whale
+    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFilePostValidation.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFilePostValidation.html new file mode 100644 index 000000000000..93451b6ccde9 --- /dev/null +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFilePostValidation.html @@ -0,0 +1,42 @@ + + + + + + + + + + + +
The pluginsFile option is invalid.
+
+The map of broken options is missing a mapping for pluginsFile.
+
+Please consider adding an issue to the [Cypress Github repo](https://github.com/cypress-io/cypress/issues/new/choose).
+
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - supportFile.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - supportFile.html new file mode 100644 index 000000000000..a3057d6b2af0 --- /dev/null +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - supportFile.html @@ -0,0 +1,46 @@ + + + + + + + + + + + +
setupNodeEvents() is updating the option supportFile.
+
+Since 10.0, this option is no longer supported on the root of the config object. 
+
+Set a specific supportFile in the e2e or component object.
+
+Error: fail whale
+    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - supportFilePostValidation.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - supportFilePostValidation.html new file mode 100644 index 000000000000..e3639ccf3853 --- /dev/null +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - supportFilePostValidation.html @@ -0,0 +1,42 @@ + + + + + + + + + + + +
setupNodeEvents() is updating the option supportFile.
+
+Since 10.0, this option is no longer supported on the root of the config object. 
+
+Set a specific supportFile in the e2e or component object.
+
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFiles.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFiles.html new file mode 100644 index 000000000000..201d29a63e79 --- /dev/null +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFiles.html @@ -0,0 +1,48 @@ + + + + + + + + + + + +
setupNodeEvents() is updating the option testFiles.
+
+Since 10.0, this option is no longer supported. 
+
+It was merged with integrationFolder into the specPattern option.
+
+NOTE: specPattern has to be set as a member of the e2e or component property.
+
+Error: fail whale
+    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFilesPostValidation.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFilesPostValidation.html new file mode 100644 index 000000000000..0673189453a9 --- /dev/null +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFilesPostValidation.html @@ -0,0 +1,44 @@ + + + + + + + + + + + +
setupNodeEvents() is updating the option testFiles.
+
+Since 10.0, this option is no longer supported. 
+
+It was merged with integrationFolder into the specPattern option.
+
+NOTE: specPattern has to be set as a member of the e2e or component property.
+
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID.html new file mode 100644 index 000000000000..a45fad1f3261 --- /dev/null +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID.html @@ -0,0 +1,48 @@ + + + + + + + + + + + +
setupNodeEvents() is updating the option integrationFolder.
+
+Since 10.0, this option is no longer supported. 
+
+It was merged with testFiles into the specPattern option.
+
+NOTE: specPattern has to be set as a member of the e2e or component property.
+
+Error: fail whale
+    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+
\ No newline at end of file From d2af45e8ab310f842103caeacf1f39fbaa06a93e Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 8 Mar 2022 12:50:27 -0600 Subject: [PATCH 15/96] fix error --- .../__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrl.html | 4 ++-- .../MIGRATED_OPTION_INVALID - baseUrlPostValidation.html | 2 +- packages/errors/src/brokenOptionsMap.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrl.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrl.html index 752cf6a939ff..1aefdc75fc35 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrl.html +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrl.html @@ -38,9 +38,9 @@ Since 10.0, this option is no longer supported on the root of the config object. -Since 10.0, this option is no longer supported on the root of the config object. +It has moved to the inside of the e2e object. Error: fail whale at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts) - at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts) + at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts) \ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrlPostValidation.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrlPostValidation.html index 29b79fff051a..8eb1acdf4a62 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrlPostValidation.html +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrlPostValidation.html @@ -38,5 +38,5 @@ Since 10.0, this option is no longer supported on the root of the config object. -Since 10.0, this option is no longer supported on the root of the config object. +It has moved to the inside of the e2e object. \ No newline at end of file diff --git a/packages/errors/src/brokenOptionsMap.ts b/packages/errors/src/brokenOptionsMap.ts index 167b5072de27..25d86d8f7fc0 100644 --- a/packages/errors/src/brokenOptionsMap.ts +++ b/packages/errors/src/brokenOptionsMap.ts @@ -36,7 +36,7 @@ export const brokenOptionsMap = { baseUrl: { brokenOnlyAtRoot: true, additionalHelp: errPartial` - Since 10.0, this option is no longer supported on the root of the config object. + It has moved to the inside of the ${fmt.highlight('e2e')} object. `, }, supportFile: { From e730843f123753c182d12c12c7690b873e172833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barth=C3=A9l=C3=A9my=20Ledoux?= Date: Tue, 8 Mar 2022 13:44:53 -0600 Subject: [PATCH 16/96] reword comment --- packages/errors/src/brokenOptionsMap.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/errors/src/brokenOptionsMap.ts b/packages/errors/src/brokenOptionsMap.ts index 25d86d8f7fc0..6a8e5358ed4f 100644 --- a/packages/errors/src/brokenOptionsMap.ts +++ b/packages/errors/src/brokenOptionsMap.ts @@ -27,7 +27,7 @@ function getSpecPatternAdditionalHelp (optionKey: string) { } /** - * Only listing of values that have broken configs between 9.X and 10.X + * List of options that have used to work in 9.X and not in 10.X not, breaking changes. * `brokenOnlyAtRoot` means that the option is only broken * at the root of the config object and can still * be used in e2e or component configs From 1111a5a0fca5aa9fa958455fddba74ea1e28e4b9 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 8 Mar 2022 14:01:54 -0600 Subject: [PATCH 17/96] ts issue --- packages/errors/test/unit/visualSnapshotErrors_spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/errors/test/unit/visualSnapshotErrors_spec.ts b/packages/errors/test/unit/visualSnapshotErrors_spec.ts index 6bfd273b6187..5dacdb4392b7 100644 --- a/packages/errors/test/unit/visualSnapshotErrors_spec.ts +++ b/packages/errors/test/unit/visualSnapshotErrors_spec.ts @@ -1097,7 +1097,7 @@ describe('visual error templates', () => { } }, MIGRATED_OPTION_INVALID: () => { - const keyChanging = ['integrationFolder', 'componentFolder', 'testFiles', 'pluginsFile', 'supportFile', 'baseUrl'], + const keyChanging = ['integrationFolder', 'componentFolder', 'testFiles', 'pluginsFile', 'supportFile', 'baseUrl'] const err = makeErr() return keyChanging.reduce((acc: ErrorGenerator<'MIGRATED_OPTION_INVALID'>, key) => { From 43bbeb7c0c7112d355f8218eefc6c53a53b16d1b Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 9 Mar 2022 16:19:22 -0600 Subject: [PATCH 18/96] simplify error process with only removed values --- .../MIGRATED_OPTION_INVALID - baseUrl.html | 46 -------------- ...PTION_INVALID - baseUrlPostValidation.html | 42 ------------- ...MIGRATED_OPTION_INVALID - supportFile.html | 46 -------------- ...N_INVALID - supportFilePostValidation.html | 42 ------------- packages/errors/src/brokenOptionsMap.ts | 63 ------------------- packages/errors/src/errors.ts | 26 +++----- .../test/unit/visualSnapshotErrors_spec.ts | 2 +- 7 files changed, 8 insertions(+), 259 deletions(-) delete mode 100644 packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrl.html delete mode 100644 packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrlPostValidation.html delete mode 100644 packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - supportFile.html delete mode 100644 packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - supportFilePostValidation.html delete mode 100644 packages/errors/src/brokenOptionsMap.ts diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrl.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrl.html deleted file mode 100644 index 1aefdc75fc35..000000000000 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrl.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - -
setupNodeEvents() is updating the option baseUrl.
-
-Since 10.0, this option is no longer supported on the root of the config object. 
-
-It has moved to the inside of the e2e object.
-
-Error: fail whale
-    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrlPostValidation.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrlPostValidation.html deleted file mode 100644 index 8eb1acdf4a62..000000000000 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - baseUrlPostValidation.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - -
setupNodeEvents() is updating the option baseUrl.
-
-Since 10.0, this option is no longer supported on the root of the config object. 
-
-It has moved to the inside of the e2e object.
-
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - supportFile.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - supportFile.html deleted file mode 100644 index a3057d6b2af0..000000000000 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - supportFile.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - -
setupNodeEvents() is updating the option supportFile.
-
-Since 10.0, this option is no longer supported on the root of the config object. 
-
-Set a specific supportFile in the e2e or component object.
-
-Error: fail whale
-    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - supportFilePostValidation.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - supportFilePostValidation.html deleted file mode 100644 index e3639ccf3853..000000000000 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - supportFilePostValidation.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - -
setupNodeEvents() is updating the option supportFile.
-
-Since 10.0, this option is no longer supported on the root of the config object. 
-
-Set a specific supportFile in the e2e or component object.
-
\ No newline at end of file diff --git a/packages/errors/src/brokenOptionsMap.ts b/packages/errors/src/brokenOptionsMap.ts deleted file mode 100644 index 6a8e5358ed4f..000000000000 --- a/packages/errors/src/brokenOptionsMap.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { errPartial, fmt } from './errTemplate' - -export function errPrefixRootOnly (optionKey: string) { - return errPartial` - ${fmt.highlight('setupNodeEvents()')} is updating the option ${fmt.highlight(optionKey)}. - - Since 10.0, this option is no longer supported on the root of the config object. - ` -} - -export function errPrefix (optionKey: string) { - return errPartial` - ${fmt.highlight('setupNodeEvents()')} is updating the option ${fmt.highlight(optionKey)}. - - Since 10.0, this option is no longer supported. - ` -} - -function getSpecPatternAdditionalHelp (optionKey: string) { - const mergedOptionKey = 'testFiles' === optionKey ? 'integrationFolder' : 'testFiles' - - return errPartial` - It was merged with ${fmt.highlight(mergedOptionKey)} into the ${fmt.highlight('specPattern')} option. - - NOTE: ${fmt.highlight('specPattern')} has to be set as a member of the ${fmt.highlight('e2e')} or ${fmt.highlight('component')} property. - ` -} - -/** - * List of options that have used to work in 9.X and not in 10.X not, breaking changes. - * `brokenOnlyAtRoot` means that the option is only broken - * at the root of the config object and can still - * be used in e2e or component configs - */ -export const brokenOptionsMap = { - baseUrl: { - brokenOnlyAtRoot: true, - additionalHelp: errPartial` - It has moved to the inside of the ${fmt.highlight('e2e')} object. - `, - }, - supportFile: { - brokenOnlyAtRoot: true, - additionalHelp: errPartial` - Set a specific ${fmt.highlight('supportFile')} in the ${fmt.highlight('e2e')} or ${fmt.highlight('component')} object. - `, - }, - - integrationFolder: { - brokenOnlyAtRoot: false, - additionalHelp: getSpecPatternAdditionalHelp('integrationFolder'), - }, - - componentFolder: { - brokenOnlyAtRoot: false, - additionalHelp: getSpecPatternAdditionalHelp('componentFolder'), - }, - - testFiles: { - brokenOnlyAtRoot: false, - additionalHelp: getSpecPatternAdditionalHelp('testFiles'), - }, -} as const diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index cd94fd0dd3be..c6f842410b59 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -11,7 +11,6 @@ import { errPartial, errTemplate, fmt, theme, PartialErr } from './errTemplate' import { stackWithoutMessage } from './stackUtils' import type { ClonedError, ConfigValidationFailureInfo, CypressError, ErrTemplateResult, ErrorLike } from './errorTypes' -import { brokenOptionsMap, errPrefix, errPrefixRootOnly } from './brokenOptionsMap' const ansi_up = new AU() @@ -1315,28 +1314,17 @@ export const AllCypressErrors = { // some keys come prefixed with a `component.` or `e2e.` but they are not referenced // in the errors maps with this prefix. strip it out. - const rootKey = optionKey.replace(/^(component|e2e)\./, '') as keyof typeof brokenOptionsMap + const rootKey = optionKey.replace(/^(component|e2e)\./, '') - const errorObj = brokenOptionsMap[rootKey] - - if (!errorObj) { - return errTemplate` - The ${fmt.highlight(optionKey)} option is invalid. - - The map of broken options is missing a mapping for ${fmt.highlight(rootKey)}. - - Please consider adding an issue to the [Cypress Github repo](https://github.com/cypress-io/cypress/issues/new/choose). - - ${stackTrace} - ` - } - - const message = errorObj.brokenOnlyAtRoot ? errPrefixRootOnly(optionKey) : errPrefix(optionKey) + const mergedOptionKey = 'testFiles' === rootKey ? 'integrationFolder' : 'testFiles' return errTemplate` - ${message} + During the ${fmt.highlight('setupNodeEvents()')}, the option ${fmt.highlight(optionKey)} gets updated. + Since 10.0, this option is no longer supported. + + It was merged with ${fmt.highlight(mergedOptionKey)} into the ${fmt.highlight('specPattern')} option. - ${errorObj.additionalHelp} + **NOTE** ${fmt.highlight('specPattern')} has to be set as a member of the ${fmt.highlight('e2e')} or ${fmt.highlight('component')} property. ${stackTrace} ` diff --git a/packages/errors/test/unit/visualSnapshotErrors_spec.ts b/packages/errors/test/unit/visualSnapshotErrors_spec.ts index 5dacdb4392b7..2a1ddac471ed 100644 --- a/packages/errors/test/unit/visualSnapshotErrors_spec.ts +++ b/packages/errors/test/unit/visualSnapshotErrors_spec.ts @@ -1097,7 +1097,7 @@ describe('visual error templates', () => { } }, MIGRATED_OPTION_INVALID: () => { - const keyChanging = ['integrationFolder', 'componentFolder', 'testFiles', 'pluginsFile', 'supportFile', 'baseUrl'] + const keyChanging = ['integrationFolder', 'componentFolder', 'testFiles', 'pluginsFile'] const err = makeErr() return keyChanging.reduce((acc: ErrorGenerator<'MIGRATED_OPTION_INVALID'>, key) => { From 26c567e5da1ba41436f2db778c77caf18ed1d90f Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 9 Mar 2022 16:27:10 -0600 Subject: [PATCH 19/96] update error messages --- .../MIGRATED_OPTION_INVALID - componentFolder.html | 9 ++++----- ...D_OPTION_INVALID - componentFolderPostValidation.html | 7 +++---- .../MIGRATED_OPTION_INVALID - integrationFolder.html | 9 ++++----- ...OPTION_INVALID - integrationFolderPostValidation.html | 7 +++---- .../MIGRATED_OPTION_INVALID - pluginsFile.html | 9 +++++---- ...RATED_OPTION_INVALID - pluginsFilePostValidation.html | 7 ++++--- .../MIGRATED_OPTION_INVALID - testFiles.html | 9 ++++----- ...IGRATED_OPTION_INVALID - testFilesPostValidation.html | 7 +++---- .../__snapshot-html__/MIGRATED_OPTION_INVALID.html | 9 ++++----- packages/errors/src/errors.ts | 4 ++-- packages/errors/src/index.ts | 2 -- 11 files changed, 36 insertions(+), 43 deletions(-) diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolder.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolder.html index 02e1327ca977..6f4a07f9ab27 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolder.html +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolder.html @@ -34,15 +34,14 @@ -
setupNodeEvents() is updating the option componentFolder.
-
-Since 10.0, this option is no longer supported. 
+    
componentFolder is updated in setupNodeEvents().
+Cypress 10.X, no longer supports this option.
 
 It was merged with testFiles into the specPattern option.
 
-NOTE: specPattern has to be set as a member of the e2e or component property.
+**NOTE** specPattern has to be set as a member of the e2e or component property.
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolderPostValidation.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolderPostValidation.html index f4eabbd7dcf0..4b02fcf1fce2 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolderPostValidation.html +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolderPostValidation.html @@ -34,11 +34,10 @@ -
setupNodeEvents() is updating the option componentFolder.
-
-Since 10.0, this option is no longer supported. 
+    
componentFolder is updated in setupNodeEvents().
+Cypress 10.X, no longer supports this option.
 
 It was merged with testFiles into the specPattern option.
 
-NOTE: specPattern has to be set as a member of the e2e or component property.
+**NOTE** specPattern has to be set as a member of the e2e or component property.
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolder.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolder.html index a45fad1f3261..41c39bc690b0 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolder.html +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolder.html @@ -34,15 +34,14 @@ -
setupNodeEvents() is updating the option integrationFolder.
-
-Since 10.0, this option is no longer supported. 
+    
integrationFolder is updated in setupNodeEvents().
+Cypress 10.X, no longer supports this option.
 
 It was merged with testFiles into the specPattern option.
 
-NOTE: specPattern has to be set as a member of the e2e or component property.
+**NOTE** specPattern has to be set as a member of the e2e or component property.
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolderPostValidation.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolderPostValidation.html index a56b690292a5..d7dc63c48306 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolderPostValidation.html +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolderPostValidation.html @@ -34,11 +34,10 @@ -
setupNodeEvents() is updating the option integrationFolder.
-
-Since 10.0, this option is no longer supported. 
+    
integrationFolder is updated in setupNodeEvents().
+Cypress 10.X, no longer supports this option.
 
 It was merged with testFiles into the specPattern option.
 
-NOTE: specPattern has to be set as a member of the e2e or component property.
+**NOTE** specPattern has to be set as a member of the e2e or component property.
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFile.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFile.html index 41f611383d6b..6064c4084fd9 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFile.html +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFile.html @@ -34,13 +34,14 @@ -
The pluginsFile option is invalid.
+    
pluginsFile is updated in setupNodeEvents().
+Cypress 10.X, no longer supports this option.
 
-The map of broken options is missing a mapping for pluginsFile.
+It was merged with testFiles into the specPattern option.
 
-Please consider adding an issue to the [Cypress Github repo](https://github.com/cypress-io/cypress/issues/new/choose).
+**NOTE** specPattern has to be set as a member of the e2e or component property.
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFilePostValidation.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFilePostValidation.html index 93451b6ccde9..ab8cd52a7ff7 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFilePostValidation.html +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFilePostValidation.html @@ -34,9 +34,10 @@ -
The pluginsFile option is invalid.
+    
pluginsFile is updated in setupNodeEvents().
+Cypress 10.X, no longer supports this option.
 
-The map of broken options is missing a mapping for pluginsFile.
+It was merged with testFiles into the specPattern option.
 
-Please consider adding an issue to the [Cypress Github repo](https://github.com/cypress-io/cypress/issues/new/choose).
+**NOTE** specPattern has to be set as a member of the e2e or component property.
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFiles.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFiles.html index 201d29a63e79..6517e7cc2a79 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFiles.html +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFiles.html @@ -34,15 +34,14 @@ -
setupNodeEvents() is updating the option testFiles.
-
-Since 10.0, this option is no longer supported. 
+    
testFiles is updated in setupNodeEvents().
+Cypress 10.X, no longer supports this option.
 
 It was merged with integrationFolder into the specPattern option.
 
-NOTE: specPattern has to be set as a member of the e2e or component property.
+**NOTE** specPattern has to be set as a member of the e2e or component property.
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFilesPostValidation.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFilesPostValidation.html index 0673189453a9..352ed3c14df2 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFilesPostValidation.html +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFilesPostValidation.html @@ -34,11 +34,10 @@ -
setupNodeEvents() is updating the option testFiles.
-
-Since 10.0, this option is no longer supported. 
+    
testFiles is updated in setupNodeEvents().
+Cypress 10.X, no longer supports this option.
 
 It was merged with integrationFolder into the specPattern option.
 
-NOTE: specPattern has to be set as a member of the e2e or component property.
+**NOTE** specPattern has to be set as a member of the e2e or component property.
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID.html index a45fad1f3261..41c39bc690b0 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID.html +++ b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID.html @@ -34,15 +34,14 @@ -
setupNodeEvents() is updating the option integrationFolder.
-
-Since 10.0, this option is no longer supported. 
+    
integrationFolder is updated in setupNodeEvents().
+Cypress 10.X, no longer supports this option.
 
 It was merged with testFiles into the specPattern option.
 
-NOTE: specPattern has to be set as a member of the e2e or component property.
+**NOTE** specPattern has to be set as a member of the e2e or component property.
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index c6f842410b59..90d772860442 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1319,8 +1319,8 @@ export const AllCypressErrors = { const mergedOptionKey = 'testFiles' === rootKey ? 'integrationFolder' : 'testFiles' return errTemplate` - During the ${fmt.highlight('setupNodeEvents()')}, the option ${fmt.highlight(optionKey)} gets updated. - Since 10.0, this option is no longer supported. + ${fmt.highlight(optionKey)} is updated in ${fmt.highlight('setupNodeEvents()')}. + Cypress 10.X, no longer supports this option. It was merged with ${fmt.highlight(mergedOptionKey)} into the ${fmt.highlight('specPattern')} option. diff --git a/packages/errors/src/index.ts b/packages/errors/src/index.ts index 269ef1e3d568..63d3c1ffcdb8 100644 --- a/packages/errors/src/index.ts +++ b/packages/errors/src/index.ts @@ -10,6 +10,4 @@ export * from './errors' export * from './errorTypes' -export * from './brokenOptionsMap' - export default errorsApi From d79946ccb5a680c238da1b4540f90fb3d2e10712 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 9 Mar 2022 16:48:13 -0600 Subject: [PATCH 20/96] make better error messages --- .../MIGRATED_OPTION_INVALID.html | 47 ------------------- ...VED_CONFIG_INVALID - componentFolder.html} | 8 ++-- ...ALID - componentFolderPostValidation.html} | 8 ++-- ...D_CONFIG_INVALID - integrationFolder.html} | 8 ++-- ...ID - integrationFolderPostValidation.html} | 8 ++-- ...ESOLVED_CONFIG_INVALID - pluginsFile.html} | 8 ++-- ..._INVALID - pluginsFilePostValidation.html} | 8 ++-- ..._RESOLVED_CONFIG_INVALID - testFiles.html} | 8 ++-- ...IG_INVALID - testFilesPostValidation.html} | 8 ++-- ...P_NODE_EVENTS_RESOLVED_CONFIG_INVALID.html | 47 +++++++++++++++++++ packages/errors/src/errors.ts | 10 ++-- .../test/unit/visualSnapshotErrors_spec.ts | 4 +- packages/graphql/schemas/schema.graphql | 2 +- .../server/lib/plugins/child/run_plugins.js | 24 +++------- 14 files changed, 93 insertions(+), 105 deletions(-) delete mode 100644 packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID.html rename packages/errors/__snapshot-html__/{MIGRATED_OPTION_INVALID - integrationFolder.html => SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - componentFolder.html} (59%) rename packages/errors/__snapshot-html__/{MIGRATED_OPTION_INVALID - testFilesPostValidation.html => SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - componentFolderPostValidation.html} (67%) rename packages/errors/__snapshot-html__/{MIGRATED_OPTION_INVALID - testFiles.html => SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - integrationFolder.html} (59%) rename packages/errors/__snapshot-html__/{MIGRATED_OPTION_INVALID - integrationFolderPostValidation.html => SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - integrationFolderPostValidation.html} (67%) rename packages/errors/__snapshot-html__/{MIGRATED_OPTION_INVALID - componentFolder.html => SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - pluginsFile.html} (59%) rename packages/errors/__snapshot-html__/{MIGRATED_OPTION_INVALID - pluginsFilePostValidation.html => SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - pluginsFilePostValidation.html} (67%) rename packages/errors/__snapshot-html__/{MIGRATED_OPTION_INVALID - pluginsFile.html => SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - testFiles.html} (59%) rename packages/errors/__snapshot-html__/{MIGRATED_OPTION_INVALID - componentFolderPostValidation.html => SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - testFilesPostValidation.html} (67%) create mode 100644 packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID.html diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID.html b/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID.html deleted file mode 100644 index 41c39bc690b0..000000000000 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - -
integrationFolder is updated in setupNodeEvents().
-Cypress 10.X, no longer supports this option.
-
-It was merged with testFiles into the specPattern option.
-
-**NOTE** specPattern has to be set as a member of the e2e or component property.
-
-Error: fail whale
-    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolder.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - componentFolder.html similarity index 59% rename from packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolder.html rename to packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - componentFolder.html index 41c39bc690b0..13f3426b29ea 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolder.html +++ b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - componentFolder.html @@ -34,14 +34,14 @@ -
integrationFolder is updated in setupNodeEvents().
-Cypress 10.X, no longer supports this option.
+    
Option componentFolder can't be updated in setupNodeEvents().
 
-It was merged with testFiles into the specPattern option.
+Since 10.X, Cypress no longer supports this option.
+componentFolder was merged with testFiles into the specPattern option.
 
 **NOTE** specPattern has to be set as a member of the e2e or component property.
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFilesPostValidation.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - componentFolderPostValidation.html similarity index 67% rename from packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFilesPostValidation.html rename to packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - componentFolderPostValidation.html index 352ed3c14df2..6352b5a49109 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFilesPostValidation.html +++ b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - componentFolderPostValidation.html @@ -34,10 +34,10 @@ -
testFiles is updated in setupNodeEvents().
-Cypress 10.X, no longer supports this option.
+    
Option componentFolder can't be updated in setupNodeEvents().
 
-It was merged with integrationFolder into the specPattern option.
+Since 10.X, Cypress no longer supports this option.
+componentFolder was merged with testFiles into the specPattern option.
 
-**NOTE** specPattern has to be set as a member of the e2e or component property.
+**NOTE** specPattern has to be set as a member of the e2e or component property.
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFiles.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - integrationFolder.html similarity index 59% rename from packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFiles.html rename to packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - integrationFolder.html index 6517e7cc2a79..4b3cbd527959 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - testFiles.html +++ b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - integrationFolder.html @@ -34,14 +34,14 @@ -
testFiles is updated in setupNodeEvents().
-Cypress 10.X, no longer supports this option.
+    
Option integrationFolder can't be updated in setupNodeEvents().
 
-It was merged with integrationFolder into the specPattern option.
+Since 10.X, Cypress no longer supports this option.
+integrationFolder was merged with testFiles into the specPattern option.
 
 **NOTE** specPattern has to be set as a member of the e2e or component property.
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolderPostValidation.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - integrationFolderPostValidation.html similarity index 67% rename from packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolderPostValidation.html rename to packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - integrationFolderPostValidation.html index d7dc63c48306..942940697099 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - integrationFolderPostValidation.html +++ b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - integrationFolderPostValidation.html @@ -34,10 +34,10 @@ -
integrationFolder is updated in setupNodeEvents().
-Cypress 10.X, no longer supports this option.
+    
Option integrationFolder can't be updated in setupNodeEvents().
 
-It was merged with testFiles into the specPattern option.
+Since 10.X, Cypress no longer supports this option.
+integrationFolder was merged with testFiles into the specPattern option.
 
-**NOTE** specPattern has to be set as a member of the e2e or component property.
+**NOTE** specPattern has to be set as a member of the e2e or component property.
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolder.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - pluginsFile.html similarity index 59% rename from packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolder.html rename to packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - pluginsFile.html index 6f4a07f9ab27..4b1fc73df113 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolder.html +++ b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - pluginsFile.html @@ -34,14 +34,14 @@ -
componentFolder is updated in setupNodeEvents().
-Cypress 10.X, no longer supports this option.
+    
Option pluginsFile can't be updated in setupNodeEvents().
 
-It was merged with testFiles into the specPattern option.
+Since 10.X, Cypress no longer supports this option.
+pluginsFile was merged with testFiles into the specPattern option.
 
 **NOTE** specPattern has to be set as a member of the e2e or component property.
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFilePostValidation.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - pluginsFilePostValidation.html similarity index 67% rename from packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFilePostValidation.html rename to packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - pluginsFilePostValidation.html index ab8cd52a7ff7..3edd448ef8a0 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFilePostValidation.html +++ b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - pluginsFilePostValidation.html @@ -34,10 +34,10 @@ -
pluginsFile is updated in setupNodeEvents().
-Cypress 10.X, no longer supports this option.
+    
Option pluginsFile can't be updated in setupNodeEvents().
 
-It was merged with testFiles into the specPattern option.
+Since 10.X, Cypress no longer supports this option.
+pluginsFile was merged with testFiles into the specPattern option.
 
-**NOTE** specPattern has to be set as a member of the e2e or component property.
+**NOTE** specPattern has to be set as a member of the e2e or component property.
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFile.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - testFiles.html similarity index 59% rename from packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFile.html rename to packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - testFiles.html index 6064c4084fd9..46e2df2aebb2 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - pluginsFile.html +++ b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - testFiles.html @@ -34,14 +34,14 @@ -
pluginsFile is updated in setupNodeEvents().
-Cypress 10.X, no longer supports this option.
+    
Option testFiles can't be updated in setupNodeEvents().
 
-It was merged with testFiles into the specPattern option.
+Since 10.X, Cypress no longer supports this option.
+testFiles was merged with integrationFolder into the specPattern option.
 
 **NOTE** specPattern has to be set as a member of the e2e or component property.
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at MIGRATED_OPTION_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolderPostValidation.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - testFilesPostValidation.html similarity index 67% rename from packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolderPostValidation.html rename to packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - testFilesPostValidation.html index 4b02fcf1fce2..1f3545c331ba 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_OPTION_INVALID - componentFolderPostValidation.html +++ b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - testFilesPostValidation.html @@ -34,10 +34,10 @@ -
componentFolder is updated in setupNodeEvents().
-Cypress 10.X, no longer supports this option.
+    
Option testFiles can't be updated in setupNodeEvents().
 
-It was merged with testFiles into the specPattern option.
+Since 10.X, Cypress no longer supports this option.
+testFiles was merged with integrationFolder into the specPattern option.
 
-**NOTE** specPattern has to be set as a member of the e2e or component property.
+**NOTE** specPattern has to be set as a member of the e2e or component property.
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID.html new file mode 100644 index 000000000000..4b3cbd527959 --- /dev/null +++ b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID.html @@ -0,0 +1,47 @@ + + + + + + + + + + + +
Option integrationFolder can't be updated in setupNodeEvents().
+
+Since 10.X, Cypress no longer supports this option.
+integrationFolder was merged with testFiles into the specPattern option.
+
+**NOTE** specPattern has to be set as a member of the e2e or component property.
+
+Error: fail whale
+    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+
\ No newline at end of file diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index 90d772860442..1b9e1a3ea23b 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1309,7 +1309,7 @@ export const AllCypressErrors = { ` }, - MIGRATED_OPTION_INVALID: (optionKey: string, err?: Error) => { + SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID: (optionKey: string, err?: Error) => { const stackTrace = err ? fmt.stackTrace(err) : null // some keys come prefixed with a `component.` or `e2e.` but they are not referenced @@ -1319,10 +1319,10 @@ export const AllCypressErrors = { const mergedOptionKey = 'testFiles' === rootKey ? 'integrationFolder' : 'testFiles' return errTemplate` - ${fmt.highlight(optionKey)} is updated in ${fmt.highlight('setupNodeEvents()')}. - Cypress 10.X, no longer supports this option. - - It was merged with ${fmt.highlight(mergedOptionKey)} into the ${fmt.highlight('specPattern')} option. + Option ${fmt.highlight(optionKey)} can't be updated in ${fmt.highlight('setupNodeEvents()')}. + + Since 10.X, Cypress no longer supports this option. + ${fmt.highlight(optionKey)} was merged with ${fmt.highlight(mergedOptionKey)} into the ${fmt.highlight('specPattern')} option. **NOTE** ${fmt.highlight('specPattern')} has to be set as a member of the ${fmt.highlight('e2e')} or ${fmt.highlight('component')} property. diff --git a/packages/errors/test/unit/visualSnapshotErrors_spec.ts b/packages/errors/test/unit/visualSnapshotErrors_spec.ts index 2a1ddac471ed..8397115b6b05 100644 --- a/packages/errors/test/unit/visualSnapshotErrors_spec.ts +++ b/packages/errors/test/unit/visualSnapshotErrors_spec.ts @@ -1096,11 +1096,11 @@ describe('visual error templates', () => { default: [makeErr()], } }, - MIGRATED_OPTION_INVALID: () => { + SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID: () => { const keyChanging = ['integrationFolder', 'componentFolder', 'testFiles', 'pluginsFile'] const err = makeErr() - return keyChanging.reduce((acc: ErrorGenerator<'MIGRATED_OPTION_INVALID'>, key) => { + return keyChanging.reduce((acc: ErrorGenerator<'SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID'>, key) => { acc[key] = [key, err] acc[`${key}PostValidation`] = [key] diff --git a/packages/graphql/schemas/schema.graphql b/packages/graphql/schemas/schema.graphql index a500d35a712b..a5a24bb5698f 100644 --- a/packages/graphql/schemas/schema.graphql +++ b/packages/graphql/schemas/schema.graphql @@ -551,7 +551,6 @@ enum ErrorTypeEnum { INVALID_REPORTER_NAME INVOKED_BINARY_OUTSIDE_NPM_MODULE LEGACY_CONFIG_FILE - MIGRATED_OPTION_INVALID MULTIPLE_SUPPORT_FILES_FOUND NODE_VERSION_DEPRECATION_BUNDLED NODE_VERSION_DEPRECATION_SYSTEM @@ -577,6 +576,7 @@ enum ErrorTypeEnum { RUN_GROUPING_FEATURE_NOT_AVAILABLE_IN_PLAN SETUP_NODE_EVENTS_DO_NOT_SUPPORT_DEV_SERVER SETUP_NODE_EVENTS_IS_NOT_FUNCTION + SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID SUPPORT_FILE_NOT_FOUND TESTS_DID_NOT_START_FAILED TESTS_DID_NOT_START_RETRYING diff --git a/packages/server/lib/plugins/child/run_plugins.js b/packages/server/lib/plugins/child/run_plugins.js index 75ca20d76815..60b373a5cd1a 100644 --- a/packages/server/lib/plugins/child/run_plugins.js +++ b/packages/server/lib/plugins/child/run_plugins.js @@ -267,18 +267,14 @@ class RunPlugins { /** * Values not allowed in 10.X+ in the root, e2e and component config */ -const optionsNonValidFor10Anywhere = ['integrationFolder', 'componentFolder', 'pluginsFile'] - -/** - * values not allowed in 10.X+ in the root that have moved in one of the testingTypes - */ -const optionsNonValidFor10Root = ['baseUrl', 'supportFile'] +const optionsNonValidFor10Anywhere = ['integrationFolder', 'componentFolder', 'pluginsFile', 'testFiles'] function getNonMigratedOptionsErr (key, errInternal) { - return require('@packages/errors').getError('MIGRATED_OPTION_INVALID', key, errInternal) + return require('@packages/errors').getError('SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID', key, errInternal) } function throwInvalidOptionError (key) { + debug('throwing err %s', key) const errInternal = new Error() Error.captureStackTrace(errInternal, throwInvalidOptionError) @@ -288,16 +284,14 @@ function throwInvalidOptionError (key) { } function setInvalidPropSetterWarning (opts, key, keyForError = key) { + debug('setting invalid property %s', key) Object.defineProperty(opts, key, { set: throwInvalidOptionError.bind(null, keyForError), }) } function wrapNonMigratedOptions (options) { - optionsNonValidFor10Root.forEach((key) => { - setInvalidPropSetterWarning(options, key) - }) - + debug('wrapping non-migrated options') optionsNonValidFor10Anywhere.forEach((key) => { setInvalidPropSetterWarning(options, key) @@ -311,12 +305,6 @@ function wrapNonMigratedOptions (options) { } function validateNonMigratedOptions (options) { - optionsNonValidFor10Root.forEach((key) => { - if (options[key]) { - throw getNonMigratedOptionsErr(key) - } - }) - optionsNonValidFor10Anywhere.forEach((key) => { const testingTypes = ['component', 'e2e'] @@ -325,7 +313,7 @@ function validateNonMigratedOptions (options) { } testingTypes.forEach((testingType) => { - if (options[testingType] && options[testingType][key]) { + if (options[testingType]?.[key]) { throw getNonMigratedOptionsErr(`${testingType}.${key}`) } }) From 4b2aaa5376915a5ed9e94f0dc953bbbce0869a55 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 9 Mar 2022 21:22:22 -0600 Subject: [PATCH 21/96] fix error names and create plugins error --- packages/errors/src/errors.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index 1b9e1a3ea23b..2e050682d778 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1309,20 +1309,20 @@ export const AllCypressErrors = { ` }, - SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID: (optionKey: string, err?: Error) => { + SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN: ({ name }: {name: string}, err?: Error) => { const stackTrace = err ? fmt.stackTrace(err) : null // some keys come prefixed with a `component.` or `e2e.` but they are not referenced // in the errors maps with this prefix. strip it out. - const rootKey = optionKey.replace(/^(component|e2e)\./, '') + const rootKey = name.replace(/^(component|e2e)\./, '') const mergedOptionKey = 'testFiles' === rootKey ? 'integrationFolder' : 'testFiles' return errTemplate` - Option ${fmt.highlight(optionKey)} can't be updated in ${fmt.highlight('setupNodeEvents()')}. + Option ${fmt.highlight(name)} can't be updated in ${fmt.highlight('setupNodeEvents()')}. Since 10.X, Cypress no longer supports this option. - ${fmt.highlight(optionKey)} was merged with ${fmt.highlight(mergedOptionKey)} into the ${fmt.highlight('specPattern')} option. + ${fmt.highlight(name)} was merged with ${fmt.highlight(mergedOptionKey)} into the ${fmt.highlight('specPattern')} option. **NOTE** ${fmt.highlight('specPattern')} has to be set as a member of the ${fmt.highlight('e2e')} or ${fmt.highlight('component')} property. @@ -1330,6 +1330,18 @@ export const AllCypressErrors = { ` }, + SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE: ({ name }: {name: string}, err?: Error) => { + const stackTrace = err ? fmt.stackTrace(err) : null + + return errTemplate` + Option ${fmt.highlight(name)} can't be updated in ${fmt.highlight('setupNodeEvents()')}. + + Since 10.X, Cypress no longer supports this option. + Instead, use the ${fmt.highlight('setupNodeEvents()')} function in the config file. + + ${stackTrace} + ` + }, } type AllCypressErrorObj = typeof AllCypressErrors From a1eb2132a28175487f5499c5b8366bc2886b4f1b Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 9 Mar 2022 21:22:54 -0600 Subject: [PATCH 22/96] convert config to typescript --- packages/config/lib/index.js | 144 -------------------------------- packages/config/lib/index.ts | 156 +++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+), 144 deletions(-) delete mode 100644 packages/config/lib/index.js create mode 100644 packages/config/lib/index.ts diff --git a/packages/config/lib/index.js b/packages/config/lib/index.js deleted file mode 100644 index a949d37ff95f..000000000000 --- a/packages/config/lib/index.js +++ /dev/null @@ -1,144 +0,0 @@ -const _ = require('lodash') -const debug = require('debug')('cypress:config:validator') - -const { options, breakingOptions, breakingRootOptions, testingTypeBreakingOptions } = require('./options') - -const dashesOrUnderscoresRe = /^(_-)+/ - -// takes an array and creates an index object of [keyKey]: [valueKey] -const createIndex = (arr, keyKey, valueKey) => { - return _.reduce(arr, (memo, item) => { - if (item[valueKey] !== undefined) { - memo[item[keyKey]] = item[valueKey] - } - - return memo - }, {}) -} - -const breakingKeys = _.map(breakingOptions, 'name') -const defaultValues = createIndex(options, 'name', 'defaultValue') -const publicConfigKeys = _(options).reject({ isInternal: true }).map('name').value() -const validationRules = createIndex(options, 'name', 'validation') -const testConfigOverrideOptions = createIndex(options, 'name', 'canUpdateDuringTestTime') - -const issuedWarnings = new Set() - -const validateNoBreakingOptions = (breakingCfgOptions, cfg, onWarning, onErr) => { - breakingCfgOptions.forEach(({ name, errorKey, newName, isWarning, value }) => { - if (_.has(cfg, name)) { - if (value && cfg[name] !== value) { - // Bail if a value is specified but the config does not have that value. - return - } - - if (isWarning) { - if (issuedWarnings.has(errorKey)) { - return - } - - // avoid re-issuing the same warning more than once - issuedWarnings.add(errorKey) - - return onWarning(errorKey, { - name, - newName, - value, - configFile: cfg.configFile, - }) - } - - return onErr(errorKey, { - name, - newName, - value, - configFile: cfg.configFile, - }) - } - }) -} - -module.exports = { - allowed: (obj = {}) => { - const propertyNames = publicConfigKeys.concat(breakingKeys) - - return _.pick(obj, propertyNames) - }, - - getBreakingKeys: () => { - return breakingKeys - }, - - getBreakingRootKeys: () => { - return breakingRootOptions - }, - - getDefaultValues: (runtimeOptions = {}) => { - // Default values can be functions, in which case they are evaluated - // at runtime - for example, slowTestThreshold where the default value - // varies between e2e and component testing. - return _.mapValues(defaultValues, (value) => (typeof value === 'function' ? value(runtimeOptions) : value)) - }, - - getPublicConfigKeys: () => { - return publicConfigKeys - }, - - matchesConfigKey: (key) => { - if (_.has(defaultValues, key)) { - return key - } - - key = key.toLowerCase().replace(dashesOrUnderscoresRe, '') - key = _.camelCase(key) - - if (_.has(defaultValues, key)) { - return key - } - }, - - options, - - validate: (cfg, onErr) => { - debug('validating configuration', cfg) - - return _.each(cfg, (value, key) => { - const validationFn = validationRules[key] - - // key has a validation rule & value different from the default - if (validationFn && value !== defaultValues[key]) { - const result = validationFn(key, value) - - if (result !== true) { - return onErr(result) - } - } - }) - }, - - validateNoBreakingConfigRoot: (cfg, onWarning, onErr) => { - return validateNoBreakingOptions(breakingRootOptions, cfg, onWarning, onErr) - }, - - validateNoBreakingConfig: (cfg, onWarning, onErr) => { - return validateNoBreakingOptions(breakingOptions, cfg, onWarning, onErr) - }, - - validateNoBreakingTestingTypeConfig: (cfg, testingType, onWarning, onErr) => { - const options = testingTypeBreakingOptions[testingType] - - return validateNoBreakingOptions(options, cfg, onWarning, onErr) - }, - - validateNoReadOnlyConfig: (config, onErr) => { - let errProperty - - Object.keys(config).some((option) => { - return errProperty = testConfigOverrideOptions[option] === false ? option : undefined - }) - - if (errProperty) { - return onErr(errProperty) - } - }, -} diff --git a/packages/config/lib/index.ts b/packages/config/lib/index.ts new file mode 100644 index 000000000000..01660ffa83b3 --- /dev/null +++ b/packages/config/lib/index.ts @@ -0,0 +1,156 @@ +import _ from 'lodash' +import type errors from '@packages/errors' +import Debug from 'debug' +import { options, breakingOptions, breakingRootOptions, testingTypeBreakingOptions } from './options' +import type { BreakingOption } from './options' + +export { breakingOptions } + +const debug = Debug('cypress:config:validator') + +const dashesOrUnderscoresRe = /^(_-)+/ + +// takes an array and creates an index object of [keyKey]: [valueKey] +const createIndex = (arr, keyKey, valueKey) => { + return _.reduce(arr, (memo: Record, item) => { + if (item[valueKey] !== undefined) { + memo[item[keyKey]] = item[valueKey] + } + + return memo + }, {}) +} + +const breakingKeys = _.map(breakingOptions, 'name') +const defaultValues = createIndex(options, 'name', 'defaultValue') +const publicConfigKeys = _(options).reject({ isInternal: true }).map('name').value() +const validationRules = createIndex(options, 'name', 'validation') +const testConfigOverrideOptions = createIndex(options, 'name', 'canUpdateDuringTestTime') + +const issuedWarnings = new Set() + +type ErrorHandler = ( + key: keyof typeof errors.AllCypressErrors, + options: { + name: string + newName?: string + value?: string + configFile: string + }) => void + +const validateNoBreakingOptions = (breakingCfgOptions: BreakingOption[], cfg, onWarning: ErrorHandler, onErr: ErrorHandler) => { + breakingCfgOptions.forEach(({ name, errorKey, newName, isWarning, value }) => { + if (_.has(cfg, name)) { + if (value && cfg[name] !== value) { + // Bail if a value is specified but the config does not have that value. + return + } + + if (isWarning) { + if (issuedWarnings.has(errorKey)) { + return + } + + // avoid re-issuing the same warning more than once + issuedWarnings.add(errorKey) + + return onWarning(errorKey, { + name, + newName, + value, + configFile: cfg.configFile, + }) + } + + return onErr(errorKey, { + name, + newName, + value, + configFile: cfg.configFile, + }) + } + }) +} + +export const allowed = (obj = {}) => { + const propertyNames = publicConfigKeys.concat(breakingKeys) + + return _.pick(obj, propertyNames) +} + +export const getBreakingKeys = () => { + return breakingKeys +} + +export const getBreakingRootKeys = () => { + return breakingRootOptions +} + +export const getDefaultValues = (runtimeOptions = {}) => { + // Default values can be functions, in which case they are evaluated + // at runtime - for example, slowTestThreshold where the default value + // varies between e2e and component testing. + return _.mapValues(defaultValues, (value) => (typeof value === 'function' ? value(runtimeOptions) : value)) +} + +export const getPublicConfigKeys = () => { + return publicConfigKeys +} + +export const matchesConfigKey = (key) => { + if (_.has(defaultValues, key)) { + return key + } + + key = key.toLowerCase().replace(dashesOrUnderscoresRe, '') + key = _.camelCase(key) + + if (_.has(defaultValues, key)) { + return key + } +} + +export { options } + +export const validate = (cfg, onErr) => { + debug('validating configuration', cfg) + + return _.each(cfg, (value, key) => { + const validationFn = validationRules[key] + + // key has a validation rule & value different from the default + if (validationFn && value !== defaultValues[key]) { + const result = validationFn(key, value) + + if (result !== true) { + return onErr(result) + } + } + }) +} + +export const validateNoBreakingConfigRoot = (cfg, onWarning: ErrorHandler, onErr: ErrorHandler) => { + return validateNoBreakingOptions(breakingRootOptions, cfg, onWarning, onErr) +} + +export const validateNoBreakingConfig = (cfg, onWarning: ErrorHandler, onErr: ErrorHandler) => { + return validateNoBreakingOptions(breakingOptions, cfg, onWarning, onErr) +} + +export const validateNoBreakingTestingTypeConfig = (cfg, testingType: keyof typeof testingTypeBreakingOptions, onWarning: ErrorHandler, onErr: ErrorHandler) => { + const options = testingTypeBreakingOptions[testingType] + + return validateNoBreakingOptions(options, cfg, onWarning, onErr) +} + +export const validateNoReadOnlyConfig = (config, onErr: (property: string) => void) => { + let errProperty + + Object.keys(config).some((option) => { + return errProperty = testConfigOverrideOptions[option] === false ? option : undefined + }) + + if (errProperty) { + return onErr(errProperty) + } +} From b294091988bb5807570dafd143e76a3914c71686 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 9 Mar 2022 22:52:02 -0600 Subject: [PATCH 23/96] make config package type safe --- packages/config/index.d.ts | 1 + packages/config/index.js | 1 + packages/config/lib/index.ts | 2 + packages/config/lib/options.ts | 22 +- packages/config/lib/validation.d.ts | 36 --- .../lib/{validation.js => validation.ts} | 207 +++++++++--------- packages/config/package.json | 11 +- packages/config/tsconfig.json | 7 + .../data-context/src/util/config-options.ts | 2 +- packages/graphql/schemas/schema.graphql | 3 +- packages/server/lib/config.ts | 4 +- .../server/lib/plugins/child/run_plugins.js | 47 ++-- .../server/test/integration/cypress_spec.js | 2 +- 13 files changed, 161 insertions(+), 184 deletions(-) create mode 100644 packages/config/index.d.ts create mode 100644 packages/config/index.js delete mode 100644 packages/config/lib/validation.d.ts rename packages/config/lib/{validation.js => validation.ts} (61%) diff --git a/packages/config/index.d.ts b/packages/config/index.d.ts new file mode 100644 index 000000000000..a25cfd4911fb --- /dev/null +++ b/packages/config/index.d.ts @@ -0,0 +1 @@ +export * from './dist' \ No newline at end of file diff --git a/packages/config/index.js b/packages/config/index.js new file mode 100644 index 000000000000..2d2f3c0bcb52 --- /dev/null +++ b/packages/config/index.js @@ -0,0 +1 @@ +module.exports = require('./dist') diff --git a/packages/config/lib/index.ts b/packages/config/lib/index.ts index 01660ffa83b3..8640ba3f3b95 100644 --- a/packages/config/lib/index.ts +++ b/packages/config/lib/index.ts @@ -4,6 +4,8 @@ import Debug from 'debug' import { options, breakingOptions, breakingRootOptions, testingTypeBreakingOptions } from './options' import type { BreakingOption } from './options' +export * as validation from './validation' + export { breakingOptions } const debug = Debug('cypress:config:validator') diff --git a/packages/config/lib/options.ts b/packages/config/lib/options.ts index 9f7584b1e4f3..290bdbf382ce 100644 --- a/packages/config/lib/options.ts +++ b/packages/config/lib/options.ts @@ -1,7 +1,8 @@ import os from 'os' -import validate from './validation' +import * as validate from './validation' // @ts-ignore import pkg from '@packages/root' +import type errors from '@packages/errors' type TestingType = 'e2e' | 'component' @@ -29,7 +30,7 @@ interface RuntimeConfigOption { canUpdateDuringTestTime?: boolean } -interface BreakingOption { +export interface BreakingOption { /** * The non-passive configuration option. */ @@ -37,7 +38,7 @@ interface BreakingOption { /** * String to summarize the error messaging that is logged. */ - errorKey: string + errorKey: keyof typeof errors.AllCypressErrors /** * Array of testing types this config option is valid for */ @@ -493,8 +494,23 @@ export const options: Array = [ ...runtimeOptions, ] +/** + * Values not allowed in 10.X+ in the root, e2e and component config + */ export const breakingOptions: Array = [ { + name: 'integrationFolder', + errorKey: 'SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN', + }, { + name: 'componentFolder', + errorKey: 'SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN', + }, { + name: 'testFiles', + errorKey: 'SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN', + }, { + name: 'pluginsFile', + errorKey: 'SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE', + }, { name: 'blacklistHosts', errorKey: 'RENAMED_CONFIG_OPTION', newName: 'blockHosts', diff --git a/packages/config/lib/validation.d.ts b/packages/config/lib/validation.d.ts deleted file mode 100644 index 1d4ebe15477f..000000000000 --- a/packages/config/lib/validation.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -// TODO: Remove this file when we land type-safe @packages/config -type ErrResult = { - key: string - value: any - type: string -} - -export default { - isValidClientCertificatesSet(_key: string, certsForUrls: any[]): ErrResult | true {}, - - isValidBrowser(browser: any): ErrResult | true {}, - - isValidBrowserList(key: string, browsers: any[]): ErrResult | true {}, - - isValidRetriesConfig(key: string, value: any): ErrResult | true {}, - - isPlainObject(key: string, value: any): ErrResult | true {}, - - isNumber(key: string, value: any): ErrResult | true {}, - - isNumberOrFalse(key: string, value: any): ErrResult | true {}, - - isFullyQualifiedUrl(key: string, value: string): ErrResult | true {}, - - isBoolean(key: string, value: any): ErrResult | true {}, - - isString(key: string, value: any): ErrResult | true {}, - - isArray(key: string, value: any): ErrResult | true {}, - - isStringOrFalse(key: string, value: any): ErrResult | true {}, - - isStringOrArrayOfStrings(key: string, value: any): ErrResult | true {}, - - isOneOf(...any: any[]): (key: any, value: any) => boolean {}, -} \ No newline at end of file diff --git a/packages/config/lib/validation.js b/packages/config/lib/validation.ts similarity index 61% rename from packages/config/lib/validation.js rename to packages/config/lib/validation.ts index 75c3ca6ed301..c04433e6cca9 100644 --- a/packages/config/lib/validation.js +++ b/packages/config/lib/validation.ts @@ -1,15 +1,23 @@ -const _ = require('lodash') -const debug = require('debug')('cypress:server:validation') -const is = require('check-more-types') -const { commaListsOr } = require('common-tags') -const path = require('path') +import { + isObject, + isArray, every, isNull, + isString as _isString, + isBoolean as _isBoolean, + isFinite as _isNumber, + isPlainObject as _isPlainObject, +} from 'lodash' +import * as is from 'check-more-types' +import { commaListsOr } from 'common-tags' +import path from 'path' +import Debug from 'debug' + +const debug = Debug('cypress:server:validation') // validation functions take a key and a value and should: // - return true if it passes validation // - return a error message if it fails validation const str = JSON.stringify -const { isArray, isString, isFinite: isNumber } = _ const errMsg = (key, value, type) => { return { @@ -19,12 +27,12 @@ const errMsg = (key, value, type) => { } } -const isFullyQualifiedUrl = (value) => { - return isString(value) && /^https?\:\/\//.test(value) +const _isFullyQualifiedUrl = (value) => { + return _isString(value) && /^https?\:\/\//.test(value) } const isArrayOfStrings = (value) => { - return isArray(value) && _.every(value, isString) + return isArray(value) && every(value, isString) } const isFalse = (value) => { @@ -35,7 +43,7 @@ const isFalse = (value) => { * Validates a single browser object. * @returns {string|true} Returns `true` if the object is matching browser object schema. Returns an error message if it does not. */ -const isValidBrowser = (browser) => { +export const isValidBrowser = (browser): ErrResult | true => { if (!is.unemptyString(browser.name)) { return errMsg('name', browser, 'a non-empty string') } @@ -55,11 +63,11 @@ const isValidBrowser = (browser) => { return errMsg('version', browser, 'a non-empty string') } - if (!is.string(browser.path)) { + if (typeof browser.path !== 'string') { return errMsg('path', browser, 'a string') } - if (!is.string(browser.majorVersion) && !is.positive(browser.majorVersion)) { + if (typeof browser.majorVersion !== 'string' && !(is.number(browser.majorVersion) && browser.majorVersion < 0)) { return errMsg('majorVersion', browser, 'a string or a positive number') } @@ -69,7 +77,7 @@ const isValidBrowser = (browser) => { /** * Validates the list of browsers. */ -const isValidBrowserList = (key, browsers) => { +export const isValidBrowserList = (key: string, browsers: any): ErrResult | true | string => { debug('browsers %o', browsers) if (!browsers) { return 'Missing browsers list' @@ -86,7 +94,7 @@ const isValidBrowserList = (key, browsers) => { } for (let k = 0; k < browsers.length; k += 1) { - const validationResult = isValidBrowser(browsers[k]) + const validationResult: boolean | {key: string, value: string, type: string, list?: string} = isValidBrowser(browsers[k]) if (validationResult !== true) { validationResult.list = 'browsers' @@ -98,31 +106,32 @@ const isValidBrowserList = (key, browsers) => { return true } -const isValidRetriesConfig = (key, value) => { +export const isValidRetriesConfig = (key: string, value: any): ErrResult | true => { const optionalKeys = ['runMode', 'openMode'] - const isValidRetryValue = (val) => _.isNull(val) || (Number.isInteger(val) && val >= 0) + const isValidRetryValue = (val) => isNull(val) || (Number.isInteger(val) && val >= 0) const optionalKeysAreValid = (val, k) => optionalKeys.includes(k) && isValidRetryValue(val) if (isValidRetryValue(value)) { return true } - if (_.isObject(value) && _.every(value, optionalKeysAreValid)) { + if (isObject(value) && every(value, optionalKeysAreValid)) { return true } return errMsg(key, value, 'a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls') } -const isPlainObject = (key, value) => { - if (value == null || _.isPlainObject(value)) { - return true - } - - return errMsg(key, value, 'a plain object') -} - -const isOneOf = (...values) => { +/** + * Checks if given value for a key is equal to one of the provided values. + * @example + ``` + validate = v.isOneOf("foo", "bar") + validate("example", "foo") // true + validate("example", "else") // error message string + ``` + */ +export const isOneOf = (...values: any[]): ((key: string, value: any) => ErrResult | true) => { return (key, value) => { if (values.some((v) => { if (typeof value === 'function') { @@ -134,24 +143,39 @@ const isOneOf = (...values) => { return true } - const strings = values.map(str).join(', ') + const strings = values.map((a) => str(a)).join(', ') return errMsg(key, value, `one of these values: ${strings}`) } } +type ErrResult = { + key: string + value: any + type: string + list?: string +} + /** * Validates whether the supplied set of cert information is valid * @returns {string|true} Returns `true` if the information set is valid. Returns an error message if it is not. */ -const isValidClientCertificatesSet = (_key, certsForUrls) => { +// _key: string, certsForUrls: any[]): ErrResult | true {} +export const isValidClientCertificatesSet = (_key: string, certsForUrls: Array<{ + url: string + ca: string + certs: Array<{ + key: string + cert: string + pfx: string + }>}>): ErrResult | true | string => { debug('clientCerts: %o', certsForUrls) if (!Array.isArray(certsForUrls)) { return errMsg(`clientCertificates.certs`, certsForUrls, 'an array of certs for URLs') } - let urls = [] + let urls: string[] = [] for (let i = 0; i < certsForUrls.length; i++) { debug(`Processing clientCertificates: ${i}`) @@ -230,93 +254,70 @@ const isValidClientCertificatesSet = (_key, certsForUrls) => { return true } -module.exports = { - isValidClientCertificatesSet, - - isValidBrowser, - - isValidBrowserList, - - isValidRetriesConfig, - - isPlainObject, - - isNumber (key, value) { - if (value == null || isNumber(value)) { - return true - } +export const isPlainObject = (key, value) => { + if (value == null || _isPlainObject(value)) { + return true + } - return errMsg(key, value, 'a number') - }, + return errMsg(key, value, 'a plain object') +} - isNumberOrFalse (key, value) { - if (isNumber(value) || isFalse(value)) { - return true - } +export function isBoolean (key, value): ErrResult | true { + if (value == null || _isBoolean(value)) { + return true + } - return errMsg(key, value, 'a number or false') - }, + return errMsg(key, value, 'a boolean') +} - isFullyQualifiedUrl (key, value) { - if (value == null || isFullyQualifiedUrl(value)) { - return true - } +export function isNumber (key, value): ErrResult | true { + if (value == null || _isNumber(value)) { + return true + } - return errMsg( - key, - value, - 'a fully qualified URL (starting with `http://` or `https://`)', - ) - }, + return errMsg(key, value, 'a number') +} - isBoolean (key, value) { - if (value == null || _.isBoolean(value)) { - return true - } +export function isString (key, value): ErrResult | true { + if (value == null || _isString(value)) { + return true + } - return errMsg(key, value, 'a boolean') - }, + return errMsg(key, value, 'a string') +} - isString (key, value) { - if (value == null || isString(value)) { - return true - } +export function isNumberOrFalse (key, value): ErrResult | true { + if (_isNumber(value) || isFalse(value)) { + return true + } - return errMsg(key, value, 'a string') - }, + return errMsg(key, value, 'a number or false') +} - isArray (key, value) { - if (value == null || isArray(value)) { - return true - } +export function isStringOrFalse (key, value): ErrResult | true { + if (_isString(value) || isFalse(value)) { + return true + } - return errMsg(key, value, 'an array') - }, + return errMsg(key, value, 'a string or false') +} - isStringOrFalse (key, value) { - if (isString(value) || isFalse(value)) { - return true - } +export function isFullyQualifiedUrl (key, value): ErrResult | true { + if (value == null || _isFullyQualifiedUrl(value)) { + return true + } - return errMsg(key, value, 'a string or false') - }, + return errMsg( + key, + value, + 'a fully qualified URL (starting with `http://` or `https://`)', + ) +} - isStringOrArrayOfStrings (key, value) { - if (isString(value) || isArrayOfStrings(value)) { - return true - } +export function isStringOrArrayOfStrings (key, value): ErrResult | true { + if (_isString(value) || isArrayOfStrings(value)) { + return true + } - return errMsg(key, value, 'a string or an array of strings') - }, - - /** - * Checks if given value for a key is equal to one of the provided values. - * @example - ``` - validate = v.isOneOf("foo", "bar") - validate("example", "foo") // true - validate("example", "else") // error message string - ``` - */ - isOneOf, + return errMsg(key, value, 'a string or an array of strings') } diff --git a/packages/config/package.json b/packages/config/package.json index e1d374a99b53..d558054406ac 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -3,9 +3,10 @@ "version": "0.0.0-development", "description": "Config contains the configuration types and validation function used in the cypress electron application.", "private": true, - "main": "lib/index.js", + "main": "index.js", "scripts": { - "build-prod": "tsc --project .", + "build": "tsc --project .", + "build-prod": "yarn build", "clean": "rm lib/options.js || echo 'ok'", "test": "yarn test-unit", "test-debug": "yarn test-unit --inspect-brk=5566", @@ -18,8 +19,10 @@ "lodash": "^4.17.21" }, "devDependencies": { + "@packages/errors": "0.0.0-development", "@packages/root": "0.0.0-development", "@packages/ts": "0.0.0-development", + "@types/node": "14.14.31", "chai": "1.10.0", "mocha": "7.0.1", "sinon": "7.3.1", @@ -27,6 +30,8 @@ "snap-shot-it": "7.9.3" }, "files": [ - "lib" + "dist", + "index.js", + "index.d.ts" ] } diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json index a4b49c139f31..1ebdcf5eeeaf 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/tsconfig.json @@ -3,4 +3,11 @@ "include": [ "lib/*", ], + "compilerOptions": { + "outDir": "./dist", + "declaration": true, + "lib": [ + "dom", + ], + }, } diff --git a/packages/data-context/src/util/config-options.ts b/packages/data-context/src/util/config-options.ts index 7d470fe1a1b6..983f4805679b 100644 --- a/packages/data-context/src/util/config-options.ts +++ b/packages/data-context/src/util/config-options.ts @@ -1,4 +1,4 @@ -import { options } from '@packages/config/lib/options' +import { options } from '@packages/config' export const getDefaultSpecPatterns = () => { return { diff --git a/packages/graphql/schemas/schema.graphql b/packages/graphql/schemas/schema.graphql index a5a24bb5698f..a9bfb359fc75 100644 --- a/packages/graphql/schemas/schema.graphql +++ b/packages/graphql/schemas/schema.graphql @@ -575,8 +575,9 @@ enum ErrorTypeEnum { RENDERER_CRASHED RUN_GROUPING_FEATURE_NOT_AVAILABLE_IN_PLAN SETUP_NODE_EVENTS_DO_NOT_SUPPORT_DEV_SERVER + SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE + SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN SETUP_NODE_EVENTS_IS_NOT_FUNCTION - SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID SUPPORT_FILE_NOT_FOUND TESTS_DID_NOT_START_FAILED TESTS_DID_NOT_START_RETRYING diff --git a/packages/server/lib/config.ts b/packages/server/lib/config.ts index 5fd67464e67e..e4fbf2814ed3 100644 --- a/packages/server/lib/config.ts +++ b/packages/server/lib/config.ts @@ -4,7 +4,7 @@ import _ from 'lodash' import path from 'path' import deepDiff from 'return-deep-diff' import type { ResolvedFromConfig, ResolvedConfigurationOptionSource, AllModeOptions, FullConfig } from '@packages/types' -import configUtils from '@packages/config' +import * as configUtils from '@packages/config' import * as errors from './errors' import { getProcessEnvVars, CYPRESS_SPECIAL_ENV_VARS } from './util/config' import { fs } from './util/fs' @@ -128,7 +128,7 @@ export function mergeDefaults ( .chain(configUtils.allowed({ ...cliConfig, ...options })) .omit('env') .omit('browsers') - .each((val, key) => { + .each((val: any, key) => { // If users pass in testing-type specific keys (eg, specPattern), // we want to merge this with what we've read from the config file, // rather than override it entirely. diff --git a/packages/server/lib/plugins/child/run_plugins.js b/packages/server/lib/plugins/child/run_plugins.js index 60b373a5cd1a..19ef70b77d65 100644 --- a/packages/server/lib/plugins/child/run_plugins.js +++ b/packages/server/lib/plugins/child/run_plugins.js @@ -14,6 +14,7 @@ const resolve = require('../../util/resolve') const browserLaunch = require('./browser_launch') const util = require('../util') const validateEvent = require('./validate_event') +const { breakingOptions } = require('@packages/config') const UNDEFINED_SERIALIZED = '__cypress_undefined__' @@ -127,7 +128,6 @@ class RunPlugins { }) .then((modifiedCfg) => { debug('plugins file successfully loaded') - modifiedCfg && validateNonMigratedOptions(modifiedCfg) this.ipc.send('setupTestingType:reply', { setupConfig: modifiedCfg, registrations: this.registrations, @@ -264,58 +264,37 @@ class RunPlugins { } } -/** - * Values not allowed in 10.X+ in the root, e2e and component config - */ -const optionsNonValidFor10Anywhere = ['integrationFolder', 'componentFolder', 'pluginsFile', 'testFiles'] - -function getNonMigratedOptionsErr (key, errInternal) { - return require('@packages/errors').getError('SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID', key, errInternal) +function getNonMigratedOptionsErr (name, errorKey, errInternal) { + return require('@packages/errors').getError(errorKey, { name }, errInternal) } -function throwInvalidOptionError (key) { - debug('throwing err %s', key) +function throwInvalidOptionError (name, errorKey) { + debug('throwing err %s', name) const errInternal = new Error() Error.captureStackTrace(errInternal, throwInvalidOptionError) - const err = getNonMigratedOptionsErr(key, errInternal) + const err = getNonMigratedOptionsErr(errorKey, name, errInternal) throw err } -function setInvalidPropSetterWarning (opts, key, keyForError = key) { - debug('setting invalid property %s', key) - Object.defineProperty(opts, key, { - set: throwInvalidOptionError.bind(null, keyForError), +function setInvalidPropSetterWarning (opts, errorKey, optionName, optionNameForError = optionName) { + debug('setting invalid property %s', optionName) + Object.defineProperty(opts, optionName, { + set: throwInvalidOptionError.bind(null, errorKey, optionNameForError), }) } function wrapNonMigratedOptions (options) { debug('wrapping non-migrated options') - optionsNonValidFor10Anywhere.forEach((key) => { - setInvalidPropSetterWarning(options, key) + breakingOptions.forEach(({ name, errorKey }) => { + setInvalidPropSetterWarning(options, errorKey, name) const testingTypes = ['component', 'e2e'] testingTypes.forEach((testingType) => { options[testingType] = options[testingType] || {} - setInvalidPropSetterWarning(options[testingType], key, `${testingType}.${key}`) - }) - }) -} - -function validateNonMigratedOptions (options) { - optionsNonValidFor10Anywhere.forEach((key) => { - const testingTypes = ['component', 'e2e'] - - if (options[key]) { - throw getNonMigratedOptionsErr(key) - } - - testingTypes.forEach((testingType) => { - if (options[testingType]?.[key]) { - throw getNonMigratedOptionsErr(`${testingType}.${key}`) - } + setInvalidPropSetterWarning(options[testingType], errorKey, name, `${testingType}.${name}`) }) }) } diff --git a/packages/server/test/integration/cypress_spec.js b/packages/server/test/integration/cypress_spec.js index 91beb7b7e980..4d6a0f6ad099 100644 --- a/packages/server/test/integration/cypress_spec.js +++ b/packages/server/test/integration/cypress_spec.js @@ -14,7 +14,7 @@ const pkg = require('@packages/root') const detect = require('@packages/launcher/lib/detect') const launch = require('@packages/launcher/lib/browsers') const extension = require('@packages/extension') -const v = require('@packages/config/lib/validation') +const { validation: v } = require('@packages/config') const argsUtil = require(`../../lib/util/args`) const { fs } = require(`../../lib/util/fs`) From f72c689efd8475bc0b3769d223196a022efffcb1 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 00:04:36 -0600 Subject: [PATCH 24/96] remove pluginsFile from app --- packages/app/cypress.config.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/app/cypress.config.ts b/packages/app/cypress.config.ts index bc92bf5d4434..952ff3d10dc1 100644 --- a/packages/app/cypress.config.ts +++ b/packages/app/cypress.config.ts @@ -38,7 +38,6 @@ export default defineConfig({ }, 'e2e': { baseUrl: 'http://localhost:5555', - pluginsFile: 'cypress/e2e/plugins/index.ts', supportFile: 'cypress/e2e/support/e2eSupport.ts', async setupNodeEvents (on, config) { if (!process.env.HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS) { From 34b7f68fbcb75420a32484a94631f27f80cbb1c5 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 00:05:11 -0600 Subject: [PATCH 25/96] configUtils should be imported properly --- packages/server/lib/makeDataContext.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/lib/makeDataContext.ts b/packages/server/lib/makeDataContext.ts index 025499d89892..07530cbd6067 100644 --- a/packages/server/lib/makeDataContext.ts +++ b/packages/server/lib/makeDataContext.ts @@ -1,7 +1,7 @@ import { DataContext, getCtx, clearCtx, setCtx } from '@packages/data-context' import electron, { OpenDialogOptions, SaveDialogOptions, BrowserWindow } from 'electron' import pkg from '@packages/root' -import configUtils from '@packages/config' +import * as configUtils from '@packages/config' import type { AllModeOptions, From 423387d4e3b6333a39707546c30a294a702052a6 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 00:09:04 -0600 Subject: [PATCH 26/96] move options to config package --- packages/config/index.d.ts | 1 - packages/config/lib/index.ts | 26 ++++++++------- packages/config/lib/options.ts | 33 ++++++++++++------- packages/config/package.json | 11 ++++--- packages/config/tsconfig.json | 11 +++++-- .../src/data/ProjectLifecycleManager.ts | 3 +- packages/types/src/config.ts | 23 ------------- 7 files changed, 53 insertions(+), 55 deletions(-) delete mode 100644 packages/config/index.d.ts diff --git a/packages/config/index.d.ts b/packages/config/index.d.ts deleted file mode 100644 index a25cfd4911fb..000000000000 --- a/packages/config/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './dist' \ No newline at end of file diff --git a/packages/config/lib/index.ts b/packages/config/lib/index.ts index 8640ba3f3b95..02980bb8a183 100644 --- a/packages/config/lib/index.ts +++ b/packages/config/lib/index.ts @@ -1,12 +1,11 @@ import _ from 'lodash' -import type errors from '@packages/errors' import Debug from 'debug' import { options, breakingOptions, breakingRootOptions, testingTypeBreakingOptions } from './options' -import type { BreakingOption } from './options' +import type { BreakingOptionObj, BreakingOption } from './options' export * as validation from './validation' -export { breakingOptions } +export { breakingOptions, BreakingOptionObj, BreakingOption } const debug = Debug('cypress:config:validator') @@ -31,16 +30,19 @@ const testConfigOverrideOptions = createIndex(options, 'name', 'canUpdateDuringT const issuedWarnings = new Set() +export type BreakingErrResult = { + name: string + newName?: string + value?: any + configFile: string +} + type ErrorHandler = ( - key: keyof typeof errors.AllCypressErrors, - options: { - name: string - newName?: string - value?: string - configFile: string - }) => void - -const validateNoBreakingOptions = (breakingCfgOptions: BreakingOption[], cfg, onWarning: ErrorHandler, onErr: ErrorHandler) => { + key: BreakingOption, + options: BreakingErrResult +) => void + +const validateNoBreakingOptions = (breakingCfgOptions: BreakingOptionObj[], cfg, onWarning: ErrorHandler, onErr: ErrorHandler) => { breakingCfgOptions.forEach(({ name, errorKey, newName, isWarning, value }) => { if (_.has(cfg, name)) { if (value && cfg[name] !== value) { diff --git a/packages/config/lib/options.ts b/packages/config/lib/options.ts index 290bdbf382ce..236eee3a0106 100644 --- a/packages/config/lib/options.ts +++ b/packages/config/lib/options.ts @@ -2,7 +2,22 @@ import os from 'os' import * as validate from './validation' // @ts-ignore import pkg from '@packages/root' -import type errors from '@packages/errors' + +export type BreakingOption = + | 'RENAMED_CONFIG_OPTION' + | 'EXPERIMENTAL_COMPONENT_TESTING_REMOVED' + | 'EXPERIMENTAL_SAMESITE_REMOVED' + | 'EXPERIMENTAL_NETWORK_STUBBING_REMOVED' + | 'EXPERIMENTAL_RUN_EVENTS_REMOVED' + | 'EXPERIMENTAL_SHADOW_DOM_REMOVED' + | 'FIREFOX_GC_INTERVAL_REMOVED' + | 'NODE_VERSION_DEPRECATION_SYSTEM' + | 'NODE_VERSION_DEPRECATION_BUNDLED' + | 'CONFIG_FILE_INVALID_ROOT_CONFIG' + | 'CONFIG_FILE_INVALID_ROOT_CONFIG_E2E' + | 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT' + | 'SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN' + | 'SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE' type TestingType = 'e2e' | 'component' @@ -30,7 +45,7 @@ interface RuntimeConfigOption { canUpdateDuringTestTime?: boolean } -export interface BreakingOption { +export interface BreakingOptionObj { /** * The non-passive configuration option. */ @@ -38,7 +53,7 @@ export interface BreakingOption { /** * String to summarize the error messaging that is logged. */ - errorKey: keyof typeof errors.AllCypressErrors + errorKey: BreakingOption /** * Array of testing types this config option is valid for */ @@ -234,12 +249,6 @@ const resolvedOptions: Array = [ defaultValue: 60000, validation: validate.isNumber, canUpdateDuringTestTime: true, - }, { - name: 'pluginsFile', - defaultValue: 'cypress/plugins', - validation: validate.isStringOrFalse, - isFolder: true, - canUpdateDuringTestTime: false, }, { name: 'port', defaultValue: null, @@ -497,7 +506,7 @@ export const options: Array = [ /** * Values not allowed in 10.X+ in the root, e2e and component config */ -export const breakingOptions: Array = [ +export const breakingOptions: Array = [ { name: 'integrationFolder', errorKey: 'SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN', @@ -551,7 +560,7 @@ export const breakingOptions: Array = [ }, ] -export const breakingRootOptions: Array = [ +export const breakingRootOptions: Array = [ { name: 'supportFile', errorKey: 'CONFIG_FILE_INVALID_ROOT_CONFIG', @@ -578,7 +587,7 @@ export const breakingRootOptions: Array = [ }, ] -export const testingTypeBreakingOptions: { e2e: Array, component: Array } = { +export const testingTypeBreakingOptions: { e2e: Array, component: Array } = { e2e: [], component: [ { diff --git a/packages/config/package.json b/packages/config/package.json index d558054406ac..ad6ed81b588b 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -5,9 +5,11 @@ "private": true, "main": "index.js", "scripts": { + "watch": "yarn build --watch", "build": "tsc --project .", "build-prod": "yarn build", - "clean": "rm lib/options.js || echo 'ok'", + "check-ts": "tsc --noEmit", + "clean": "rm lib/*.js || echo 'ok'", "test": "yarn test-unit", "test-debug": "yarn test-unit --inspect-brk=5566", "test-unit": "mocha --configFile=../../mocha-reporter-config.json -r @packages/ts/register -extension=.js,.ts test/unit/*spec.* --exit" @@ -19,9 +21,9 @@ "lodash": "^4.17.21" }, "devDependencies": { - "@packages/errors": "0.0.0-development", "@packages/root": "0.0.0-development", "@packages/ts": "0.0.0-development", + "@packages/types": "0.0.0-development", "@types/node": "14.14.31", "chai": "1.10.0", "mocha": "7.0.1", @@ -30,8 +32,9 @@ "snap-shot-it": "7.9.3" }, "files": [ - "dist", + "lib", "index.js", "index.d.ts" - ] + ], + "types": "lib/index.ts" } diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json index 1ebdcf5eeeaf..49d05085f421 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/tsconfig.json @@ -5,9 +5,16 @@ ], "compilerOptions": { "outDir": "./dist", - "declaration": true, "lib": [ "dom", + "ES2020", ], - }, + "types": [ + "node" + ], + "typeRoots":[ + "../../node_modules/@types", + "./node_modules/@types" + ] + } } diff --git a/packages/data-context/src/data/ProjectLifecycleManager.ts b/packages/data-context/src/data/ProjectLifecycleManager.ts index 0aac66adb6c8..1b1839b2e694 100644 --- a/packages/data-context/src/data/ProjectLifecycleManager.ts +++ b/packages/data-context/src/data/ProjectLifecycleManager.ts @@ -20,8 +20,9 @@ import { getError, CypressError, ConfigValidationFailureInfo } from '@packages/e import type { DataContext } from '..' import { LoadConfigReply, SetupNodeEventsReply, ProjectConfigIpc, IpcHandler } from './ProjectConfigIpc' import assert from 'assert' -import type { AllModeOptions, BreakingErrResult, BreakingOption, FoundBrowser, FullConfig, TestingType } from '@packages/types' +import type { AllModeOptions, FoundBrowser, FullConfig, TestingType } from '@packages/types' import { autoBindDebug } from '../util/autoBindDebug' +import type { BreakingOption, BreakingErrResult } from '@packages/config' const debug = debugLib(`cypress:lifecycle:ProjectLifecycleManager`) diff --git a/packages/types/src/config.ts b/packages/types/src/config.ts index 0f33033396dd..bef12ee623ff 100644 --- a/packages/types/src/config.ts +++ b/packages/types/src/config.ts @@ -44,26 +44,3 @@ export interface SettingsOptions { testingType?: 'component' |'e2e' args?: AllModeOptions } - -// Todo, move to @packages/config when it becomes type-safe - -export type BreakingOption = - | 'RENAMED_CONFIG_OPTION' - | 'EXPERIMENTAL_COMPONENT_TESTING_REMOVED' - | 'EXPERIMENTAL_SAMESITE_REMOVED' - | 'EXPERIMENTAL_NETWORK_STUBBING_REMOVED' - | 'EXPERIMENTAL_RUN_EVENTS_REMOVED' - | 'EXPERIMENTAL_SHADOW_DOM_REMOVED' - | 'FIREFOX_GC_INTERVAL_REMOVED' - | 'NODE_VERSION_DEPRECATION_SYSTEM' - | 'NODE_VERSION_DEPRECATION_BUNDLED' - | 'CONFIG_FILE_INVALID_ROOT_CONFIG' - | 'CONFIG_FILE_INVALID_ROOT_CONFIG_E2E' - | 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT' - -export type BreakingErrResult = { - name: string - newName?: string - value?: any - configFile: string -} From a70e07c74ab7416784d3ccb0e2eba80e1b9997ef Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 00:24:34 -0600 Subject: [PATCH 27/96] fix browser validation --- packages/config/lib/validation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/config/lib/validation.ts b/packages/config/lib/validation.ts index c04433e6cca9..70f60846ecc6 100644 --- a/packages/config/lib/validation.ts +++ b/packages/config/lib/validation.ts @@ -67,7 +67,7 @@ export const isValidBrowser = (browser): ErrResult | true => { return errMsg('path', browser, 'a string') } - if (typeof browser.majorVersion !== 'string' && !(is.number(browser.majorVersion) && browser.majorVersion < 0)) { + if (typeof browser.majorVersion !== 'string' && !(is.number(browser.majorVersion) && browser.majorVersion > 0)) { return errMsg('majorVersion', browser, 'a string or a positive number') } From 72c979746ae6c7aea69dc03e7c455d16e347d403 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 00:28:32 -0600 Subject: [PATCH 28/96] finishing touches --- packages/errors/src/errors.ts | 2 +- packages/server/lib/plugins/child/run_plugins.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index 2e050682d778..4fb1406aad0c 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1324,7 +1324,7 @@ export const AllCypressErrors = { Since 10.X, Cypress no longer supports this option. ${fmt.highlight(name)} was merged with ${fmt.highlight(mergedOptionKey)} into the ${fmt.highlight('specPattern')} option. - **NOTE** ${fmt.highlight('specPattern')} has to be set as a member of the ${fmt.highlight('e2e')} or ${fmt.highlight('component')} property. + **NOTE: ** ${fmt.highlight('specPattern')} has to be set as a member of the ${fmt.highlight('e2e')} or ${fmt.highlight('component')} property. ${stackTrace} ` diff --git a/packages/server/lib/plugins/child/run_plugins.js b/packages/server/lib/plugins/child/run_plugins.js index 19ef70b77d65..4c31bb915109 100644 --- a/packages/server/lib/plugins/child/run_plugins.js +++ b/packages/server/lib/plugins/child/run_plugins.js @@ -287,7 +287,7 @@ function setInvalidPropSetterWarning (opts, errorKey, optionName, optionNameForE function wrapNonMigratedOptions (options) { debug('wrapping non-migrated options') - breakingOptions.forEach(({ name, errorKey }) => { + breakingOptions.filter((opt) => !opt.isWarning).forEach(({ name, errorKey }) => { setInvalidPropSetterWarning(options, errorKey, name) const testingTypes = ['component', 'e2e'] From a45e81ec968375492d82070078a6f715ba6a57b4 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 00:32:40 -0600 Subject: [PATCH 29/96] Add missing error tests --- ..._EVENTS_INVALID_OPTIONS_PLUGINS_FILE.html} | 6 +-- ...TIONS_SPEC_PATTERN - componentFolder.html} | 4 +- ...LID_OPTIONS_SPEC_PATTERN - testFiles.html} | 4 +- ..._EVENTS_INVALID_OPTIONS_SPEC_PATTERN.html} | 4 +- ...VALID - componentFolderPostValidation.html | 43 ----------------- ...ED_CONFIG_INVALID - integrationFolder.html | 47 ------------------- ...LID - integrationFolderPostValidation.html | 43 ----------------- ...G_INVALID - pluginsFilePostValidation.html | 43 ----------------- ...FIG_INVALID - testFilesPostValidation.html | 43 ----------------- .../test/unit/visualSnapshotErrors_spec.ts | 23 +++++---- 10 files changed, 19 insertions(+), 241 deletions(-) rename packages/errors/__snapshot-html__/{SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - pluginsFile.html => SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE.html} (62%) rename packages/errors/__snapshot-html__/{SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - componentFolder.html => SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - componentFolder.html} (74%) rename packages/errors/__snapshot-html__/{SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - testFiles.html => SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - testFiles.html} (74%) rename packages/errors/__snapshot-html__/{SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID.html => SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN.html} (75%) delete mode 100644 packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - componentFolderPostValidation.html delete mode 100644 packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - integrationFolder.html delete mode 100644 packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - integrationFolderPostValidation.html delete mode 100644 packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - pluginsFilePostValidation.html delete mode 100644 packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - testFilesPostValidation.html diff --git a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - pluginsFile.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE.html similarity index 62% rename from packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - pluginsFile.html rename to packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE.html index 4b1fc73df113..3b681eed0352 100644 --- a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - pluginsFile.html +++ b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE.html @@ -37,11 +37,9 @@
Option pluginsFile can't be updated in setupNodeEvents().
 
 Since 10.X, Cypress no longer supports this option.
-pluginsFile was merged with testFiles into the specPattern option.
-
-**NOTE** specPattern has to be set as a member of the e2e or component property.
+Instead, use the setupNodeEvents() function in the config file.
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - componentFolder.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - componentFolder.html similarity index 74% rename from packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - componentFolder.html rename to packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - componentFolder.html index 13f3426b29ea..25ad408ebcf3 100644 --- a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - componentFolder.html +++ b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - componentFolder.html @@ -39,9 +39,9 @@ Since 10.X, Cypress no longer supports this option. componentFolder was merged with testFiles into the specPattern option. -**NOTE** specPattern has to be set as a member of the e2e or component property. +**NOTE: ** specPattern has to be set as a member of the e2e or component property. Error: fail whale at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts) - at SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts) + at SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - testFiles.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - testFiles.html similarity index 74% rename from packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - testFiles.html rename to packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - testFiles.html index 46e2df2aebb2..b88f20e97cdb 100644 --- a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - testFiles.html +++ b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - testFiles.html @@ -39,9 +39,9 @@ Since 10.X, Cypress no longer supports this option. testFiles was merged with integrationFolder into the specPattern option. -**NOTE** specPattern has to be set as a member of the e2e or component property. +**NOTE: ** specPattern has to be set as a member of the e2e or component property. Error: fail whale at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts) - at SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts) + at SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN.html similarity index 75% rename from packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID.html rename to packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN.html index 4b3cbd527959..e44b541415bb 100644 --- a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID.html +++ b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN.html @@ -39,9 +39,9 @@ Since 10.X, Cypress no longer supports this option. integrationFolder was merged with testFiles into the specPattern option. -**NOTE** specPattern has to be set as a member of the e2e or component property. +**NOTE: ** specPattern has to be set as a member of the e2e or component property. Error: fail whale at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts) - at SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts) + at SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - componentFolderPostValidation.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - componentFolderPostValidation.html deleted file mode 100644 index 6352b5a49109..000000000000 --- a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - componentFolderPostValidation.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - -
Option componentFolder can't be updated in setupNodeEvents().
-
-Since 10.X, Cypress no longer supports this option.
-componentFolder was merged with testFiles into the specPattern option.
-
-**NOTE** specPattern has to be set as a member of the e2e or component property.
-
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - integrationFolder.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - integrationFolder.html deleted file mode 100644 index 4b3cbd527959..000000000000 --- a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - integrationFolder.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - -
Option integrationFolder can't be updated in setupNodeEvents().
-
-Since 10.X, Cypress no longer supports this option.
-integrationFolder was merged with testFiles into the specPattern option.
-
-**NOTE** specPattern has to be set as a member of the e2e or component property.
-
-Error: fail whale
-    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - integrationFolderPostValidation.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - integrationFolderPostValidation.html deleted file mode 100644 index 942940697099..000000000000 --- a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - integrationFolderPostValidation.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - -
Option integrationFolder can't be updated in setupNodeEvents().
-
-Since 10.X, Cypress no longer supports this option.
-integrationFolder was merged with testFiles into the specPattern option.
-
-**NOTE** specPattern has to be set as a member of the e2e or component property.
-
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - pluginsFilePostValidation.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - pluginsFilePostValidation.html deleted file mode 100644 index 3edd448ef8a0..000000000000 --- a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - pluginsFilePostValidation.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - -
Option pluginsFile can't be updated in setupNodeEvents().
-
-Since 10.X, Cypress no longer supports this option.
-pluginsFile was merged with testFiles into the specPattern option.
-
-**NOTE** specPattern has to be set as a member of the e2e or component property.
-
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - testFilesPostValidation.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - testFilesPostValidation.html deleted file mode 100644 index 1f3545c331ba..000000000000 --- a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID - testFilesPostValidation.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - -
Option testFiles can't be updated in setupNodeEvents().
-
-Since 10.X, Cypress no longer supports this option.
-testFiles was merged with integrationFolder into the specPattern option.
-
-**NOTE** specPattern has to be set as a member of the e2e or component property.
-
\ No newline at end of file diff --git a/packages/errors/test/unit/visualSnapshotErrors_spec.ts b/packages/errors/test/unit/visualSnapshotErrors_spec.ts index 8397115b6b05..e83d48acc65e 100644 --- a/packages/errors/test/unit/visualSnapshotErrors_spec.ts +++ b/packages/errors/test/unit/visualSnapshotErrors_spec.ts @@ -1096,18 +1096,17 @@ describe('visual error templates', () => { default: [makeErr()], } }, - SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID: () => { - const keyChanging = ['integrationFolder', 'componentFolder', 'testFiles', 'pluginsFile'] - const err = makeErr() - - return keyChanging.reduce((acc: ErrorGenerator<'SETUP_NODE_EVENTS_RESOLVED_CONFIG_INVALID'>, key) => { - acc[key] = [key, err] - acc[`${key}PostValidation`] = [key] - - return acc - }, { - default: ['integrationFolder', makeErr()], - }) + SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE: () => { + return { + default: [{ name: 'pluginsFile' }, makeErr()], + } + }, + SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN: () => { + return { + default: [{ name: 'integrationFolder' }, makeErr()], + testFiles: [{ name: 'testFiles' }, makeErr()], + componentFolder: [{ name: 'componentFolder' }, makeErr()], + } }, }) }) From 91dcf1dca718d6bcd074d9aae9940bb0c680c939 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 01:33:26 -0600 Subject: [PATCH 30/96] cleanup some types --- packages/config/lib/index.ts | 20 ++++++++++--------- packages/config/lib/validation.ts | 32 +++++++++++++++---------------- packages/config/tsconfig.json | 1 + packages/errors/src/errors.ts | 5 +++-- 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/packages/config/lib/index.ts b/packages/config/lib/index.ts index 02980bb8a183..8a33bda3ef25 100644 --- a/packages/config/lib/index.ts +++ b/packages/config/lib/index.ts @@ -12,10 +12,10 @@ const debug = Debug('cypress:config:validator') const dashesOrUnderscoresRe = /^(_-)+/ // takes an array and creates an index object of [keyKey]: [valueKey] -const createIndex = (arr, keyKey, valueKey) => { +function createIndex> (arr: Array, keyKey: keyof T, valueKey: keyof T) { return _.reduce(arr, (memo: Record, item) => { if (item[valueKey] !== undefined) { - memo[item[keyKey]] = item[valueKey] + memo[item[keyKey] as string] = item[valueKey] } return memo @@ -42,7 +42,7 @@ type ErrorHandler = ( options: BreakingErrResult ) => void -const validateNoBreakingOptions = (breakingCfgOptions: BreakingOptionObj[], cfg, onWarning: ErrorHandler, onErr: ErrorHandler) => { +const validateNoBreakingOptions = (breakingCfgOptions: BreakingOptionObj[], cfg: any, onWarning: ErrorHandler, onErr: ErrorHandler) => { breakingCfgOptions.forEach(({ name, errorKey, newName, isWarning, value }) => { if (_.has(cfg, name)) { if (value && cfg[name] !== value) { @@ -101,7 +101,7 @@ export const getPublicConfigKeys = () => { return publicConfigKeys } -export const matchesConfigKey = (key) => { +export const matchesConfigKey = (key: string) => { if (_.has(defaultValues, key)) { return key } @@ -112,11 +112,13 @@ export const matchesConfigKey = (key) => { if (_.has(defaultValues, key)) { return key } + + return } export { options } -export const validate = (cfg, onErr) => { +export const validate = (cfg: any, onErr: (property: string) => void) => { debug('validating configuration', cfg) return _.each(cfg, (value, key) => { @@ -133,21 +135,21 @@ export const validate = (cfg, onErr) => { }) } -export const validateNoBreakingConfigRoot = (cfg, onWarning: ErrorHandler, onErr: ErrorHandler) => { +export const validateNoBreakingConfigRoot = (cfg: any, onWarning: ErrorHandler, onErr: ErrorHandler) => { return validateNoBreakingOptions(breakingRootOptions, cfg, onWarning, onErr) } -export const validateNoBreakingConfig = (cfg, onWarning: ErrorHandler, onErr: ErrorHandler) => { +export const validateNoBreakingConfig = (cfg: any, onWarning: ErrorHandler, onErr: ErrorHandler) => { return validateNoBreakingOptions(breakingOptions, cfg, onWarning, onErr) } -export const validateNoBreakingTestingTypeConfig = (cfg, testingType: keyof typeof testingTypeBreakingOptions, onWarning: ErrorHandler, onErr: ErrorHandler) => { +export const validateNoBreakingTestingTypeConfig = (cfg: any, testingType: keyof typeof testingTypeBreakingOptions, onWarning: ErrorHandler, onErr: ErrorHandler) => { const options = testingTypeBreakingOptions[testingType] return validateNoBreakingOptions(options, cfg, onWarning, onErr) } -export const validateNoReadOnlyConfig = (config, onErr: (property: string) => void) => { +export const validateNoReadOnlyConfig = (config: any, onErr: (property: string) => void) => { let errProperty Object.keys(config).some((option) => { diff --git a/packages/config/lib/validation.ts b/packages/config/lib/validation.ts index 70f60846ecc6..a97a2a6dfe3c 100644 --- a/packages/config/lib/validation.ts +++ b/packages/config/lib/validation.ts @@ -19,7 +19,7 @@ const debug = Debug('cypress:server:validation') const str = JSON.stringify -const errMsg = (key, value, type) => { +const errMsg = (key: string, value: any, type: string) => { return { key, value, @@ -27,15 +27,15 @@ const errMsg = (key, value, type) => { } } -const _isFullyQualifiedUrl = (value) => { +const _isFullyQualifiedUrl = (value: any) => { return _isString(value) && /^https?\:\/\//.test(value) } -const isArrayOfStrings = (value) => { +const isArrayOfStrings = (value: any) => { return isArray(value) && every(value, isString) } -const isFalse = (value) => { +const isFalse = (value: any) => { return value === false } @@ -43,7 +43,7 @@ const isFalse = (value) => { * Validates a single browser object. * @returns {string|true} Returns `true` if the object is matching browser object schema. Returns an error message if it does not. */ -export const isValidBrowser = (browser): ErrResult | true => { +export const isValidBrowser = (browser: any): ErrResult | true => { if (!is.unemptyString(browser.name)) { return errMsg('name', browser, 'a non-empty string') } @@ -108,8 +108,8 @@ export const isValidBrowserList = (key: string, browsers: any): ErrResult | true export const isValidRetriesConfig = (key: string, value: any): ErrResult | true => { const optionalKeys = ['runMode', 'openMode'] - const isValidRetryValue = (val) => isNull(val) || (Number.isInteger(val) && val >= 0) - const optionalKeysAreValid = (val, k) => optionalKeys.includes(k) && isValidRetryValue(val) + const isValidRetryValue = (val: any) => isNull(val) || (Number.isInteger(val) && val >= 0) + const optionalKeysAreValid = (val: any, k: string) => optionalKeys.includes(k) && isValidRetryValue(val) if (isValidRetryValue(value)) { return true @@ -163,7 +163,7 @@ type ErrResult = { // _key: string, certsForUrls: any[]): ErrResult | true {} export const isValidClientCertificatesSet = (_key: string, certsForUrls: Array<{ url: string - ca: string + ca: string[] certs: Array<{ key: string cert: string @@ -254,7 +254,7 @@ export const isValidClientCertificatesSet = (_key: string, certsForUrls: Array<{ return true } -export const isPlainObject = (key, value) => { +export const isPlainObject = (key: string, value: any) => { if (value == null || _isPlainObject(value)) { return true } @@ -262,7 +262,7 @@ export const isPlainObject = (key, value) => { return errMsg(key, value, 'a plain object') } -export function isBoolean (key, value): ErrResult | true { +export function isBoolean (key: string, value: any): ErrResult | true { if (value == null || _isBoolean(value)) { return true } @@ -270,7 +270,7 @@ export function isBoolean (key, value): ErrResult | true { return errMsg(key, value, 'a boolean') } -export function isNumber (key, value): ErrResult | true { +export function isNumber (key: string, value: any): ErrResult | true { if (value == null || _isNumber(value)) { return true } @@ -278,7 +278,7 @@ export function isNumber (key, value): ErrResult | true { return errMsg(key, value, 'a number') } -export function isString (key, value): ErrResult | true { +export function isString (key: string, value: any): ErrResult | true { if (value == null || _isString(value)) { return true } @@ -286,7 +286,7 @@ export function isString (key, value): ErrResult | true { return errMsg(key, value, 'a string') } -export function isNumberOrFalse (key, value): ErrResult | true { +export function isNumberOrFalse (key: string, value: any): ErrResult | true { if (_isNumber(value) || isFalse(value)) { return true } @@ -294,7 +294,7 @@ export function isNumberOrFalse (key, value): ErrResult | true { return errMsg(key, value, 'a number or false') } -export function isStringOrFalse (key, value): ErrResult | true { +export function isStringOrFalse (key: string, value: any): ErrResult | true { if (_isString(value) || isFalse(value)) { return true } @@ -302,7 +302,7 @@ export function isStringOrFalse (key, value): ErrResult | true { return errMsg(key, value, 'a string or false') } -export function isFullyQualifiedUrl (key, value): ErrResult | true { +export function isFullyQualifiedUrl (key: string, value: any): ErrResult | true { if (value == null || _isFullyQualifiedUrl(value)) { return true } @@ -314,7 +314,7 @@ export function isFullyQualifiedUrl (key, value): ErrResult | true { ) } -export function isStringOrArrayOfStrings (key, value): ErrResult | true { +export function isStringOrArrayOfStrings (key: string, value: any): ErrResult | true { if (_isString(value) || isArrayOfStrings(value)) { return true } diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json index 49d05085f421..d4558bbb1d95 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/tsconfig.json @@ -5,6 +5,7 @@ ], "compilerOptions": { "outDir": "./dist", + "noImplicitAny": true, "lib": [ "dom", "ES2020", diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index dc3dac03aa04..6da9c10837a3 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -4,7 +4,8 @@ import chalk from 'chalk' import _ from 'lodash' import path from 'path' import stripAnsi from 'strip-ansi' -import type { BreakingErrResult, TestingType } from '@packages/types' +import type { TestingType } from '@packages/types' +import type { BreakingErrResult } from '@packages/config' import { humanTime, logError, parseResolvedPattern, pluralize } from './errorUtils' import { errPartial, errTemplate, fmt, theme, PartialErr } from './errTemplate' @@ -1324,7 +1325,7 @@ export const AllCypressErrors = { Since 10.X, Cypress no longer supports this option. ${fmt.highlight(name)} was merged with ${fmt.highlight(mergedOptionKey)} into the ${fmt.highlight('specPattern')} option. - **NOTE: ** ${fmt.highlight('specPattern')} has to be set as a member of the ${fmt.highlight('e2e')} or ${fmt.highlight('component')} property. + **NOTE:** ${fmt.highlight('specPattern')} has to be set as a member of the ${fmt.highlight('e2e')} or ${fmt.highlight('component')} property. ${stackTrace} ` From d8b38b0ee633f3e691114afe49d87bbff728453d Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 01:38:22 -0600 Subject: [PATCH 31/96] fix types --- packages/config/lib/validation.ts | 10 +++++++++- packages/config/tsconfig.json | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/config/lib/validation.ts b/packages/config/lib/validation.ts index a97a2a6dfe3c..aa9d6a6c28d8 100644 --- a/packages/config/lib/validation.ts +++ b/packages/config/lib/validation.ts @@ -181,6 +181,10 @@ export const isValidClientCertificatesSet = (_key: string, certsForUrls: Array<{ debug(`Processing clientCertificates: ${i}`) let certsForUrl = certsForUrls[i] + if (!certsForUrl) { + continue + } + if (!certsForUrl.url) { return errMsg(`clientCertificates[${i}].url`, certsForUrl.url, 'a URL matcher') } @@ -214,6 +218,10 @@ export const isValidClientCertificatesSet = (_key: string, certsForUrls: Array<{ for (let j = 0; j < certsForUrl.certs.length; j++) { let certInfo = certsForUrl.certs[j] + if (!certInfo) { + continue + } + // Only one of PEM or PFX cert allowed if (certInfo.cert && certInfo.pfx) { return `\`clientCertificates[${i}].certs[${j}]\` has both PEM and PFX defined` @@ -245,7 +253,7 @@ export const isValidClientCertificatesSet = (_key: string, certsForUrls: Array<{ } for (let k = 0; k < certsForUrl.ca.length; k++) { - if (path.isAbsolute(certsForUrl.ca[k])) { + if (path.isAbsolute(certsForUrl.ca[k] || '')) { return errMsg(`clientCertificates[${k}].ca[${k}]`, certsForUrl.ca[k], 'a relative filepath') } } diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json index d4558bbb1d95..9cdc29f5dc0f 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/tsconfig.json @@ -6,6 +6,13 @@ "compilerOptions": { "outDir": "./dist", "noImplicitAny": true, + "strict": true, + "allowJs": false, + "noUnusedLocals": false, + "resolveJsonModule": true, + "experimentalDecorators": true, + "noUncheckedIndexedAccess": true, + "importsNotUsedAsValues": "error", "lib": [ "dom", "ES2020", From 19aec84710bf0e80c584c7b931e2d692c1e62149 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 09:28:17 -0600 Subject: [PATCH 32/96] fix types --- packages/config/tsconfig.json | 13 +------------ packages/server/lib/config.ts | 2 +- packages/ts/tsconfig.json | 2 +- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json index 9cdc29f5dc0f..183bc8dc5446 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/tsconfig.json @@ -12,17 +12,6 @@ "resolveJsonModule": true, "experimentalDecorators": true, "noUncheckedIndexedAccess": true, - "importsNotUsedAsValues": "error", - "lib": [ - "dom", - "ES2020", - ], - "types": [ - "node" - ], - "typeRoots":[ - "../../node_modules/@types", - "./node_modules/@types" - ] + "importsNotUsedAsValues": "error" } } diff --git a/packages/server/lib/config.ts b/packages/server/lib/config.ts index e4fbf2814ed3..ca413367f942 100644 --- a/packages/server/lib/config.ts +++ b/packages/server/lib/config.ts @@ -511,7 +511,7 @@ export function parseEnv (cfg: Record, envCLI: Record, envCLI = envCLI != null ? envCLI : {} const configFromEnv = _.reduce(envProc, (memo: string[], val, key) => { - let cfgKey: string + let cfgKey: string | undefined cfgKey = configUtils.matchesConfigKey(key) diff --git a/packages/ts/tsconfig.json b/packages/ts/tsconfig.json index 9a1b1089b971..3a420e646393 100644 --- a/packages/ts/tsconfig.json +++ b/packages/ts/tsconfig.json @@ -3,7 +3,7 @@ /* Basic Options */ "target": "ES2018", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ - "lib": ["es2018", "ES2020.Promise"], /* Specify library files to be included in the compilation: */ + "lib": ["es2018", "ES2020.Promise", "DOM"], /* Specify library files to be included in the compilation: */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ From 8572d52ff62e2576ac813fc545535a42927be071 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 10:30:23 -0600 Subject: [PATCH 33/96] nice refactor --- packages/config/lib/index.ts | 6 ++-- packages/config/lib/options.ts | 9 ++---- packages/config/lib/validation.ts | 2 +- packages/config/tsconfig.json | 2 +- packages/errors/src/errors.ts | 28 ++++++------------- .../server/lib/plugins/child/run_plugins.js | 2 +- packages/ts/tsconfig.json | 6 +++- 7 files changed, 22 insertions(+), 33 deletions(-) diff --git a/packages/config/lib/index.ts b/packages/config/lib/index.ts index 8a33bda3ef25..903c71d12fa2 100644 --- a/packages/config/lib/index.ts +++ b/packages/config/lib/index.ts @@ -1,11 +1,11 @@ import _ from 'lodash' import Debug from 'debug' import { options, breakingOptions, breakingRootOptions, testingTypeBreakingOptions } from './options' -import type { BreakingOptionObj, BreakingOption } from './options' +import type { BreakingOptionObj, BreakingOptionErrorKey } from './options' export * as validation from './validation' -export { breakingOptions, BreakingOptionObj, BreakingOption } +export { breakingOptions, BreakingOptionObj, BreakingOptionErrorKey } const debug = Debug('cypress:config:validator') @@ -38,7 +38,7 @@ export type BreakingErrResult = { } type ErrorHandler = ( - key: BreakingOption, + key: BreakingOptionErrorKey, options: BreakingErrResult ) => void diff --git a/packages/config/lib/options.ts b/packages/config/lib/options.ts index 236eee3a0106..ab43252d1b10 100644 --- a/packages/config/lib/options.ts +++ b/packages/config/lib/options.ts @@ -3,7 +3,7 @@ import * as validate from './validation' // @ts-ignore import pkg from '@packages/root' -export type BreakingOption = +export type BreakingOptionErrorKey = | 'RENAMED_CONFIG_OPTION' | 'EXPERIMENTAL_COMPONENT_TESTING_REMOVED' | 'EXPERIMENTAL_SAMESITE_REMOVED' @@ -17,7 +17,6 @@ export type BreakingOption = | 'CONFIG_FILE_INVALID_ROOT_CONFIG_E2E' | 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT' | 'SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN' - | 'SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE' type TestingType = 'e2e' | 'component' @@ -53,7 +52,7 @@ export interface BreakingOptionObj { /** * String to summarize the error messaging that is logged. */ - errorKey: BreakingOption + errorKey: BreakingOptionErrorKey /** * Array of testing types this config option is valid for */ @@ -516,9 +515,6 @@ export const breakingOptions: Array = [ }, { name: 'testFiles', errorKey: 'SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN', - }, { - name: 'pluginsFile', - errorKey: 'SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE', }, { name: 'blacklistHosts', errorKey: 'RENAMED_CONFIG_OPTION', @@ -526,7 +522,6 @@ export const breakingOptions: Array = [ }, { name: 'experimentalComponentTesting', errorKey: 'EXPERIMENTAL_COMPONENT_TESTING_REMOVED', - isWarning: false, }, { name: 'experimentalGetCookiesSameSite', errorKey: 'EXPERIMENTAL_SAMESITE_REMOVED', diff --git a/packages/config/lib/validation.ts b/packages/config/lib/validation.ts index aa9d6a6c28d8..ca7cdb2d7ce8 100644 --- a/packages/config/lib/validation.ts +++ b/packages/config/lib/validation.ts @@ -1,3 +1,4 @@ +import path from 'path' import { isObject, isArray, every, isNull, @@ -8,7 +9,6 @@ import { } from 'lodash' import * as is from 'check-more-types' import { commaListsOr } from 'common-tags' -import path from 'path' import Debug from 'debug' const debug = Debug('cypress:server:validation') diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json index 183bc8dc5446..c6d38692fad2 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/tsconfig.json @@ -12,6 +12,6 @@ "resolveJsonModule": true, "experimentalDecorators": true, "noUncheckedIndexedAccess": true, - "importsNotUsedAsValues": "error" + "importsNotUsedAsValues": "error", } } diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index 6da9c10837a3..14c491d3388e 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1317,33 +1317,23 @@ export const AllCypressErrors = { // in the errors maps with this prefix. strip it out. const rootKey = name.replace(/^(component|e2e)\./, '') - const mergedOptionKey = 'testFiles' === rootKey ? 'integrationFolder' : 'testFiles' + const testingTypePrefix = name.includes('component.') ? 'component.' : name.includes('e2e.') ? 'e2e.' : '' - return errTemplate` - Option ${fmt.highlight(name)} can't be updated in ${fmt.highlight('setupNodeEvents()')}. - - Since 10.X, Cypress no longer supports this option. - ${fmt.highlight(name)} was merged with ${fmt.highlight(mergedOptionKey)} into the ${fmt.highlight('specPattern')} option. - - **NOTE:** ${fmt.highlight('specPattern')} has to be set as a member of the ${fmt.highlight('e2e')} or ${fmt.highlight('component')} property. - - ${stackTrace} - ` - }, - - SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE: ({ name }: {name: string}, err?: Error) => { - const stackTrace = err ? fmt.stackTrace(err) : null + const mergedOptionKey = 'testFiles' === rootKey + ? errPartial`${fmt.highlight('integrationFolder')} or ${fmt.highlight('componentFolder')}` + : errPartial`${fmt.highlight('testFiles')}` return errTemplate` - Option ${fmt.highlight(name)} can't be updated in ${fmt.highlight('setupNodeEvents()')}. + ## Invalid config update in ${fmt.highlight('setupNodeEvents()')} + + Option ${fmt.highlight(name)} is no longer supported. - Since 10.X, Cypress no longer supports this option. - Instead, use the ${fmt.highlight('setupNodeEvents()')} function in the config file. + It was merged with ${mergedOptionKey} into the ${fmt.highlight(`${testingTypePrefix}specPattern`)} option. ${stackTrace} ` }, - + MIGRATION_ALREADY_OCURRED: (configFile: string, legacyConfigFile: string) => { return errTemplate` You are attempting to use Cypress with an older config file: ${fmt.highlight(legacyConfigFile)} diff --git a/packages/server/lib/plugins/child/run_plugins.js b/packages/server/lib/plugins/child/run_plugins.js index 4c31bb915109..21265f209ebf 100644 --- a/packages/server/lib/plugins/child/run_plugins.js +++ b/packages/server/lib/plugins/child/run_plugins.js @@ -287,7 +287,7 @@ function setInvalidPropSetterWarning (opts, errorKey, optionName, optionNameForE function wrapNonMigratedOptions (options) { debug('wrapping non-migrated options') - breakingOptions.filter((opt) => !opt.isWarning).forEach(({ name, errorKey }) => { + breakingOptions.filter(({ isWarning }) => !isWarning).forEach(({ name, errorKey }) => { setInvalidPropSetterWarning(options, errorKey, name) const testingTypes = ['component', 'e2e'] diff --git a/packages/ts/tsconfig.json b/packages/ts/tsconfig.json index 3a420e646393..6844b0c279ed 100644 --- a/packages/ts/tsconfig.json +++ b/packages/ts/tsconfig.json @@ -54,6 +54,10 @@ /* Experimental Options */ "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - "importsNotUsedAsValues": "error" + "importsNotUsedAsValues": "error", + "typeRoots": [ + "../../node_modules/@types", + "./node_modules/@types" + ] } } From 4d5df3c3a7487711bf65576f5593c83ce0444a8e Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 10:48:01 -0600 Subject: [PATCH 34/96] update error and tests --- ...E_EVENTS_INVALID_OPTIONS_PLUGINS_FILE.html | 45 ------------------- ...PTIONS_SPEC_PATTERN - componentFolder.html | 9 ++-- ...ALID_OPTIONS_SPEC_PATTERN - testFiles.html | 9 ++-- ...E_EVENTS_INVALID_OPTIONS_SPEC_PATTERN.html | 9 ++-- packages/errors/src/errors.ts | 8 ++-- .../test/unit/visualSnapshotErrors_spec.ts | 5 --- packages/graphql/schemas/schema.graphql | 1 - 7 files changed, 16 insertions(+), 70 deletions(-) delete mode 100644 packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE.html diff --git a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE.html deleted file mode 100644 index 3b681eed0352..000000000000 --- a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - -
Option pluginsFile can't be updated in setupNodeEvents().
-
-Since 10.X, Cypress no longer supports this option.
-Instead, use the setupNodeEvents() function in the config file.
-
-Error: fail whale
-    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - componentFolder.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - componentFolder.html index 25ad408ebcf3..28b1136500f0 100644 --- a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - componentFolder.html +++ b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - componentFolder.html @@ -34,14 +34,13 @@ -
Option componentFolder can't be updated in setupNodeEvents().
+    
You are attempting to update a configuration value that is no longer supported: componentFolder
 
-Since 10.X, Cypress no longer supports this option.
-componentFolder was merged with testFiles into the specPattern option.
+componentFolder merged with testFiles into the specPattern option.
 
-**NOTE: ** specPattern has to be set as a member of the e2e or component property.
+https://on.cypress.io/migration-guide
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - testFiles.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - testFiles.html index b88f20e97cdb..606ee1b5c083 100644 --- a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - testFiles.html +++ b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - testFiles.html @@ -34,14 +34,13 @@ -
Option testFiles can't be updated in setupNodeEvents().
+    
You are attempting to update a configuration value that is no longer supported: testFiles
 
-Since 10.X, Cypress no longer supports this option.
-testFiles was merged with integrationFolder into the specPattern option.
+testFiles merged with integrationFolder or componentFolder into the specPattern option.
 
-**NOTE: ** specPattern has to be set as a member of the e2e or component property.
+https://on.cypress.io/migration-guide
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN.html b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN.html index e44b541415bb..8f07b4b029d6 100644 --- a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN.html +++ b/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN.html @@ -34,14 +34,13 @@ -
Option integrationFolder can't be updated in setupNodeEvents().
+    
You are attempting to update a configuration value that is no longer supported: integrationFolder
 
-Since 10.X, Cypress no longer supports this option.
-integrationFolder was merged with testFiles into the specPattern option.
+integrationFolder merged with testFiles into the specPattern option.
 
-**NOTE: ** specPattern has to be set as a member of the e2e or component property.
+https://on.cypress.io/migration-guide
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index 14c491d3388e..50c0edb595dc 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1324,11 +1324,11 @@ export const AllCypressErrors = { : errPartial`${fmt.highlight('testFiles')}` return errTemplate` - ## Invalid config update in ${fmt.highlight('setupNodeEvents()')} - - Option ${fmt.highlight(name)} is no longer supported. + You are attempting to update a configuration value that is no longer supported: ${fmt.highlight(name)} - It was merged with ${mergedOptionKey} into the ${fmt.highlight(`${testingTypePrefix}specPattern`)} option. + ${fmt.highlight(name)} merged with ${mergedOptionKey} into the ${fmt.highlight(`${testingTypePrefix}specPattern`)} option. + + https://on.cypress.io/migration-guide ${stackTrace} ` diff --git a/packages/errors/test/unit/visualSnapshotErrors_spec.ts b/packages/errors/test/unit/visualSnapshotErrors_spec.ts index 3e8a0c1a4f30..37cc97d66e85 100644 --- a/packages/errors/test/unit/visualSnapshotErrors_spec.ts +++ b/packages/errors/test/unit/visualSnapshotErrors_spec.ts @@ -1096,11 +1096,6 @@ describe('visual error templates', () => { default: [makeErr()], } }, - SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE: () => { - return { - default: [{ name: 'pluginsFile' }, makeErr()], - } - }, SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN: () => { return { default: [{ name: 'integrationFolder' }, makeErr()], diff --git a/packages/graphql/schemas/schema.graphql b/packages/graphql/schemas/schema.graphql index 09a0f801b8c6..7d8effe72206 100644 --- a/packages/graphql/schemas/schema.graphql +++ b/packages/graphql/schemas/schema.graphql @@ -576,7 +576,6 @@ enum ErrorTypeEnum { RENDERER_CRASHED RUN_GROUPING_FEATURE_NOT_AVAILABLE_IN_PLAN SETUP_NODE_EVENTS_DO_NOT_SUPPORT_DEV_SERVER - SETUP_NODE_EVENTS_INVALID_OPTIONS_PLUGINS_FILE SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN SETUP_NODE_EVENTS_IS_NOT_FUNCTION SUPPORT_FILE_NOT_FOUND From 4470f91540eff470e8261e81342ef48c993685f4 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 10:51:31 -0600 Subject: [PATCH 35/96] simplify BreakingOption Type name --- packages/config/lib/index.ts | 6 +++--- packages/config/lib/options.ts | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/config/lib/index.ts b/packages/config/lib/index.ts index 903c71d12fa2..5bbf35250448 100644 --- a/packages/config/lib/index.ts +++ b/packages/config/lib/index.ts @@ -1,11 +1,11 @@ import _ from 'lodash' import Debug from 'debug' import { options, breakingOptions, breakingRootOptions, testingTypeBreakingOptions } from './options' -import type { BreakingOptionObj, BreakingOptionErrorKey } from './options' +import type { BreakingOption, BreakingOptionErrorKey } from './options' export * as validation from './validation' -export { breakingOptions, BreakingOptionObj, BreakingOptionErrorKey } +export { breakingOptions, BreakingOption, BreakingOptionErrorKey } const debug = Debug('cypress:config:validator') @@ -42,7 +42,7 @@ type ErrorHandler = ( options: BreakingErrResult ) => void -const validateNoBreakingOptions = (breakingCfgOptions: BreakingOptionObj[], cfg: any, onWarning: ErrorHandler, onErr: ErrorHandler) => { +const validateNoBreakingOptions = (breakingCfgOptions: BreakingOption[], cfg: any, onWarning: ErrorHandler, onErr: ErrorHandler) => { breakingCfgOptions.forEach(({ name, errorKey, newName, isWarning, value }) => { if (_.has(cfg, name)) { if (value && cfg[name] !== value) { diff --git a/packages/config/lib/options.ts b/packages/config/lib/options.ts index ab43252d1b10..2ea5e7f1303a 100644 --- a/packages/config/lib/options.ts +++ b/packages/config/lib/options.ts @@ -44,7 +44,7 @@ interface RuntimeConfigOption { canUpdateDuringTestTime?: boolean } -export interface BreakingOptionObj { +export interface BreakingOption { /** * The non-passive configuration option. */ @@ -505,7 +505,7 @@ export const options: Array = [ /** * Values not allowed in 10.X+ in the root, e2e and component config */ -export const breakingOptions: Array = [ +export const breakingOptions: Array = [ { name: 'integrationFolder', errorKey: 'SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN', @@ -555,7 +555,7 @@ export const breakingOptions: Array = [ }, ] -export const breakingRootOptions: Array = [ +export const breakingRootOptions: Array = [ { name: 'supportFile', errorKey: 'CONFIG_FILE_INVALID_ROOT_CONFIG', @@ -582,7 +582,7 @@ export const breakingRootOptions: Array = [ }, ] -export const testingTypeBreakingOptions: { e2e: Array, component: Array } = { +export const testingTypeBreakingOptions: { e2e: Array, component: Array } = { e2e: [], component: [ { From 327b4da05642c62394ce769d3a9a46b1d4d0f144 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 11:15:44 -0600 Subject: [PATCH 36/96] rename and update error to not mention setup --- packages/config/lib/options.ts | 8 ++++---- ...ED_CONFIG_OPTIONS_SPEC_PATTERN - componentFolder.html} | 4 ++-- ...MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html} | 4 ++-- ...ERN.html => MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html} | 4 ++-- packages/errors/src/errors.ts | 4 ++-- packages/errors/test/unit/visualSnapshotErrors_spec.ts | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) rename packages/errors/__snapshot-html__/{SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - componentFolder.html => MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - componentFolder.html} (77%) rename packages/errors/__snapshot-html__/{SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - testFiles.html => MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html} (77%) rename packages/errors/__snapshot-html__/{SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN.html => MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html} (77%) diff --git a/packages/config/lib/options.ts b/packages/config/lib/options.ts index 2ea5e7f1303a..8bf40547f6c7 100644 --- a/packages/config/lib/options.ts +++ b/packages/config/lib/options.ts @@ -16,7 +16,7 @@ export type BreakingOptionErrorKey = | 'CONFIG_FILE_INVALID_ROOT_CONFIG' | 'CONFIG_FILE_INVALID_ROOT_CONFIG_E2E' | 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT' - | 'SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN' + | 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN' type TestingType = 'e2e' | 'component' @@ -508,13 +508,13 @@ export const options: Array = [ export const breakingOptions: Array = [ { name: 'integrationFolder', - errorKey: 'SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN', + errorKey: 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN', }, { name: 'componentFolder', - errorKey: 'SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN', + errorKey: 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN', }, { name: 'testFiles', - errorKey: 'SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN', + errorKey: 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN', }, { name: 'blacklistHosts', errorKey: 'RENAMED_CONFIG_OPTION', diff --git a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - componentFolder.html b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - componentFolder.html similarity index 77% rename from packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - componentFolder.html rename to packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - componentFolder.html index 28b1136500f0..b3e16998b450 100644 --- a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - componentFolder.html +++ b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - componentFolder.html @@ -34,7 +34,7 @@ -
You are attempting to update a configuration value that is no longer supported: componentFolder
+    
You are attempting to use a configuration value that is no longer supported: componentFolder
 
 componentFolder merged with testFiles into the specPattern option.
 
@@ -42,5 +42,5 @@
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - testFiles.html b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html similarity index 77% rename from packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - testFiles.html rename to packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html index 606ee1b5c083..23cb3e8daa68 100644 --- a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN - testFiles.html +++ b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html @@ -34,7 +34,7 @@ -
You are attempting to update a configuration value that is no longer supported: testFiles
+    
You are attempting to use a configuration value that is no longer supported: testFiles
 
 testFiles merged with integrationFolder or componentFolder into the specPattern option.
 
@@ -42,5 +42,5 @@
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN.html b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html similarity index 77% rename from packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN.html rename to packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html index 8f07b4b029d6..d519fcaecf94 100644 --- a/packages/errors/__snapshot-html__/SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN.html +++ b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html @@ -34,7 +34,7 @@ -
You are attempting to update a configuration value that is no longer supported: integrationFolder
+    
You are attempting to use a configuration value that is no longer supported: integrationFolder
 
 integrationFolder merged with testFiles into the specPattern option.
 
@@ -42,5 +42,5 @@
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index 50c0edb595dc..be4983a7c0a1 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1310,7 +1310,7 @@ export const AllCypressErrors = { ` }, - SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN: ({ name }: {name: string}, err?: Error) => { + MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN: ({ name }: {name: string}, err?: Error) => { const stackTrace = err ? fmt.stackTrace(err) : null // some keys come prefixed with a `component.` or `e2e.` but they are not referenced @@ -1324,7 +1324,7 @@ export const AllCypressErrors = { : errPartial`${fmt.highlight('testFiles')}` return errTemplate` - You are attempting to update a configuration value that is no longer supported: ${fmt.highlight(name)} + You are attempting to use a configuration value that is no longer supported: ${fmt.highlight(name)} ${fmt.highlight(name)} merged with ${mergedOptionKey} into the ${fmt.highlight(`${testingTypePrefix}specPattern`)} option. diff --git a/packages/errors/test/unit/visualSnapshotErrors_spec.ts b/packages/errors/test/unit/visualSnapshotErrors_spec.ts index 37cc97d66e85..dd8ed2e52d84 100644 --- a/packages/errors/test/unit/visualSnapshotErrors_spec.ts +++ b/packages/errors/test/unit/visualSnapshotErrors_spec.ts @@ -1096,7 +1096,7 @@ describe('visual error templates', () => { default: [makeErr()], } }, - SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN: () => { + MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN: () => { return { default: [{ name: 'integrationFolder' }, makeErr()], testFiles: [{ name: 'testFiles' }, makeErr()], From be9eca229b95008a4e88a789fd0a57f4b25ca6e9 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 14:03:45 -0600 Subject: [PATCH 37/96] generated error --- packages/graphql/schemas/schema.graphql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/graphql/schemas/schema.graphql b/packages/graphql/schemas/schema.graphql index 7d8effe72206..3c6a9932df34 100644 --- a/packages/graphql/schemas/schema.graphql +++ b/packages/graphql/schemas/schema.graphql @@ -551,6 +551,7 @@ enum ErrorTypeEnum { INVALID_REPORTER_NAME INVOKED_BINARY_OUTSIDE_NPM_MODULE LEGACY_CONFIG_FILE + MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN MIGRATION_ALREADY_OCURRED MULTIPLE_SUPPORT_FILES_FOUND NODE_VERSION_DEPRECATION_BUNDLED @@ -576,7 +577,6 @@ enum ErrorTypeEnum { RENDERER_CRASHED RUN_GROUPING_FEATURE_NOT_AVAILABLE_IN_PLAN SETUP_NODE_EVENTS_DO_NOT_SUPPORT_DEV_SERVER - SETUP_NODE_EVENTS_INVALID_OPTIONS_SPEC_PATTERN SETUP_NODE_EVENTS_IS_NOT_FUNCTION SUPPORT_FILE_NOT_FOUND TESTS_DID_NOT_START_FAILED From 5fd7d94375a9e85f9e9fa6e3c91f1ae5c07a1dc8 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 16:02:52 -0600 Subject: [PATCH 38/96] align version of mocha types --- .../data-context/src/data/ProjectLifecycleManager.ts | 4 ++-- packages/errors/package.json | 2 +- packages/errors/tsconfig.json | 10 +--------- packages/ts/tsconfig.json | 2 +- yarn.lock | 10 +++++----- 5 files changed, 10 insertions(+), 18 deletions(-) diff --git a/packages/data-context/src/data/ProjectLifecycleManager.ts b/packages/data-context/src/data/ProjectLifecycleManager.ts index 69b56774f707..ccc273fbff87 100644 --- a/packages/data-context/src/data/ProjectLifecycleManager.ts +++ b/packages/data-context/src/data/ProjectLifecycleManager.ts @@ -22,7 +22,7 @@ import { LoadConfigReply, SetupNodeEventsReply, ProjectConfigIpc, IpcHandler } f import assert from 'assert' import type { AllModeOptions, FoundBrowser, FullConfig, TestingType } from '@packages/types' import { autoBindDebug } from '../util/autoBindDebug' -import type { BreakingOption, BreakingErrResult } from '@packages/config' +import type { BreakingOptionErrorKey, BreakingErrResult } from '@packages/config' const debug = debugLib(`cypress:lifecycle:ProjectLifecycleManager`) @@ -39,7 +39,7 @@ export interface SetupFullConfigOptions { options: Partial } -type BreakingValidationFn = (type: BreakingOption, val: BreakingErrResult) => T +type BreakingValidationFn = (type: BreakingOptionErrorKey, val: BreakingErrResult) => T /** * All of the APIs injected from @packages/server & @packages/config diff --git a/packages/errors/package.json b/packages/errors/package.json index 38d492e2ccce..561bd2ec20bd 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -23,7 +23,7 @@ "devDependencies": { "@packages/ts": "0.0.0-development", "@types/chai": "4.2.15", - "@types/mocha": "8.2.2", + "@types/mocha": "^8.0.3", "@types/node": "14.14.31", "@types/pixelmatch": "^5.2.4", "@types/pngjs": "^6.0.1", diff --git a/packages/errors/tsconfig.json b/packages/errors/tsconfig.json index 842a64e22c9f..d478d32e34a0 100644 --- a/packages/errors/tsconfig.json +++ b/packages/errors/tsconfig.json @@ -2,10 +2,6 @@ "extends": "../ts/tsconfig.json", "include": [ "src", - "test", - ], - "exclude": [ - "script", ], "compilerOptions": { "strict": true, @@ -15,10 +11,6 @@ "experimentalDecorators": true, "noImplicitReturns": false, "noUncheckedIndexedAccess": true, - "importsNotUsedAsValues": "error", - "types": [ - "node", - "mocha" - ] + "importsNotUsedAsValues": "error" } } \ No newline at end of file diff --git a/packages/ts/tsconfig.json b/packages/ts/tsconfig.json index 6844b0c279ed..6eb416793792 100644 --- a/packages/ts/tsconfig.json +++ b/packages/ts/tsconfig.json @@ -56,8 +56,8 @@ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ "importsNotUsedAsValues": "error", "typeRoots": [ + "./node_modules/@types", "../../node_modules/@types", - "./node_modules/@types" ] } } diff --git a/yarn.lock b/yarn.lock index 893320bce81e..f5c6b396a570 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9893,11 +9893,6 @@ resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.0.3.tgz#51b21b6acb6d1b923bbdc7725c38f9f455166402" integrity sha512-vyxR57nv8NfcU0GZu8EUXZLTbCMupIUwy95LJ6lllN+JRPG25CwMHoB1q5xKh8YKhQnHYRAn4yW2yuHbf/5xgg== -"@types/mocha@8.2.2", "@types/mocha@^8.0.2", "@types/mocha@^8.0.3": - version "8.2.2" - resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.2.2.tgz#91daa226eb8c2ff261e6a8cbf8c7304641e095e0" - integrity sha512-Lwh0lzzqT5Pqh6z61P3c3P5nm6fzQK/MMHl9UKeneAeInVflBSz1O2EkX6gM6xfJd7FBXBY5purtLx7fUiZ7Hw== - "@types/mocha@9.0.0": version "9.0.0" resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.0.0.tgz#3205bcd15ada9bc681ac20bef64e9e6df88fd297" @@ -9908,6 +9903,11 @@ resolved "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.0.tgz#baf17ab2cca3fcce2d322ebc30454bff487efad5" integrity sha512-QCWHkbMv4Y5U9oW10Uxbr45qMMSzl4OzijsozynUAgx3kEHUdXB00udx2dWDQ7f2TU2a2uuiFaRZjCe3unPpeg== +"@types/mocha@^8.0.2", "@types/mocha@^8.0.3": + version "8.2.2" + resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.2.2.tgz#91daa226eb8c2ff261e6a8cbf8c7304641e095e0" + integrity sha512-Lwh0lzzqT5Pqh6z61P3c3P5nm6fzQK/MMHl9UKeneAeInVflBSz1O2EkX6gM6xfJd7FBXBY5purtLx7fUiZ7Hw== + "@types/mock-fs@4.10.0": version "4.10.0" resolved "https://registry.yarnpkg.com/@types/mock-fs/-/mock-fs-4.10.0.tgz#460061b186993d76856f669d5317cda8a007c24b" From 9d1b7a6dc446c56dd68162f71058cdbf8a1cec15 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 16:52:04 -0600 Subject: [PATCH 39/96] clarify what is happening when running setup --- packages/errors/src/errors.ts | 16 +++++++++++----- packages/server/lib/config.ts | 15 +++++++++++++-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index be4983a7c0a1..769460d25f24 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1310,7 +1310,7 @@ export const AllCypressErrors = { ` }, - MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN: ({ name }: {name: string}, err?: Error) => { + MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN: ({ name, setupNodeEvents }: {name: string, setupNodeEvents: boolean}, err?: Error) => { const stackTrace = err ? fmt.stackTrace(err) : null // some keys come prefixed with a `component.` or `e2e.` but they are not referenced @@ -1323,14 +1323,20 @@ export const AllCypressErrors = { ? errPartial`${fmt.highlight('integrationFolder')} or ${fmt.highlight('componentFolder')}` : errPartial`${fmt.highlight('testFiles')}` + const message = setupNodeEvents ? errPartial` + In ${fmt.highlight('setupNodeEvents()')}, you are attempting to update a configuration that is no longer supported: ${fmt.highlight(name)} + ` : errPartial` + You are attempting to use a configuration that is no longer supported: ${fmt.highlight(name)} + ` + return errTemplate` - You are attempting to use a configuration value that is no longer supported: ${fmt.highlight(name)} + ${message} - ${fmt.highlight(name)} merged with ${mergedOptionKey} into the ${fmt.highlight(`${testingTypePrefix}specPattern`)} option. + ${fmt.highlight(name)} merged with ${mergedOptionKey} into the ${fmt.highlight(`${testingTypePrefix}specPattern`)} option. - https://on.cypress.io/migration-guide + https://on.cypress.io/migration-guide - ${stackTrace} + ${stackTrace} ` }, diff --git a/packages/server/lib/config.ts b/packages/server/lib/config.ts index ca413367f942..db590573db1e 100644 --- a/packages/server/lib/config.ts +++ b/packages/server/lib/config.ts @@ -199,6 +199,8 @@ export function mergeDefaults ( config = setNodeBinary(config, options.userNodePath, options.userNodeVersion) + debug('validate that there is no breaking changes before plugins') + configUtils.validateNoBreakingConfig(config, errors.warning, (err, ...args) => { throw errors.get(err, ...args) }) @@ -256,10 +258,19 @@ export function updateWithPluginValues (cfg, overrides) { } return errors.throwErr('CONFIG_VALIDATION_ERROR', 'configFile', configFile, validationResult) - // return errors.throwErr('CONFIG_VALIDATION_ERROR', 'pluginsFile', relativePluginsPath, errMsg) }) - let originalResolvedBrowsers = cfg && cfg.resolved && cfg.resolved.browsers && _.cloneDeep(cfg.resolved.browsers) + configUtils.validateNoBreakingConfig(overrides, errors.warning, (err, options) => { + throw errors.get(err, { + ...options, + setupNodeEvents: true, + }) + }) + + let originalResolvedBrowsers = cfg + && cfg.resolved + && cfg.resolved.browsers + && _.cloneDeep(cfg.resolved.browsers) if (!originalResolvedBrowsers) { // have something to resolve with if plugins return nothing From e42814ee1ac59d96e853a32a35ce168de99bb19c Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 17:19:46 -0600 Subject: [PATCH 40/96] refactor validation imports lodash --- packages/config/lib/validation.ts | 53 ++++++++++++++----------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/packages/config/lib/validation.ts b/packages/config/lib/validation.ts index ca7cdb2d7ce8..8d31336155df 100644 --- a/packages/config/lib/validation.ts +++ b/packages/config/lib/validation.ts @@ -1,12 +1,5 @@ import path from 'path' -import { - isObject, - isArray, every, isNull, - isString as _isString, - isBoolean as _isBoolean, - isFinite as _isNumber, - isPlainObject as _isPlainObject, -} from 'lodash' +import * as _ from 'lodash' import * as is from 'check-more-types' import { commaListsOr } from 'common-tags' import Debug from 'debug' @@ -19,7 +12,14 @@ const debug = Debug('cypress:server:validation') const str = JSON.stringify -const errMsg = (key: string, value: any, type: string) => { +type ErrResult = { + key: string + value: any + type: string + list?: string +} + +const errMsg = (key: string, value: any, type: string): ErrResult => { return { key, value, @@ -27,15 +27,15 @@ const errMsg = (key: string, value: any, type: string) => { } } -const _isFullyQualifiedUrl = (value: any) => { - return _isString(value) && /^https?\:\/\//.test(value) +const _isFullyQualifiedUrl = (value: any): ErrResult | boolean => { + return _.isString(value) && /^https?\:\/\//.test(value) } -const isArrayOfStrings = (value: any) => { - return isArray(value) && every(value, isString) +const isArrayOfStrings = (value: any): ErrResult | boolean => { + return _.isArray(value) && _.every(value, isString) } -const isFalse = (value: any) => { +const isFalse = (value: any): boolean => { return value === false } @@ -108,14 +108,14 @@ export const isValidBrowserList = (key: string, browsers: any): ErrResult | true export const isValidRetriesConfig = (key: string, value: any): ErrResult | true => { const optionalKeys = ['runMode', 'openMode'] - const isValidRetryValue = (val: any) => isNull(val) || (Number.isInteger(val) && val >= 0) + const isValidRetryValue = (val: any) => _.isNull(val) || (Number.isInteger(val) && val >= 0) const optionalKeysAreValid = (val: any, k: string) => optionalKeys.includes(k) && isValidRetryValue(val) if (isValidRetryValue(value)) { return true } - if (isObject(value) && every(value, optionalKeysAreValid)) { + if (_.isObject(value) && _.every(value, optionalKeysAreValid)) { return true } @@ -149,13 +149,6 @@ export const isOneOf = (...values: any[]): ((key: string, value: any) => ErrResu } } -type ErrResult = { - key: string - value: any - type: string - list?: string -} - /** * Validates whether the supplied set of cert information is valid * @returns {string|true} Returns `true` if the information set is valid. Returns an error message if it is not. @@ -263,7 +256,7 @@ export const isValidClientCertificatesSet = (_key: string, certsForUrls: Array<{ } export const isPlainObject = (key: string, value: any) => { - if (value == null || _isPlainObject(value)) { + if (value == null || _.isPlainObject(value)) { return true } @@ -271,7 +264,7 @@ export const isPlainObject = (key: string, value: any) => { } export function isBoolean (key: string, value: any): ErrResult | true { - if (value == null || _isBoolean(value)) { + if (value == null || _.isBoolean(value)) { return true } @@ -279,7 +272,7 @@ export function isBoolean (key: string, value: any): ErrResult | true { } export function isNumber (key: string, value: any): ErrResult | true { - if (value == null || _isNumber(value)) { + if (value == null || _.isNumber(value)) { return true } @@ -287,7 +280,7 @@ export function isNumber (key: string, value: any): ErrResult | true { } export function isString (key: string, value: any): ErrResult | true { - if (value == null || _isString(value)) { + if (value == null || _.isString(value)) { return true } @@ -295,7 +288,7 @@ export function isString (key: string, value: any): ErrResult | true { } export function isNumberOrFalse (key: string, value: any): ErrResult | true { - if (_isNumber(value) || isFalse(value)) { + if (_.isNumber(value) || isFalse(value)) { return true } @@ -303,7 +296,7 @@ export function isNumberOrFalse (key: string, value: any): ErrResult | true { } export function isStringOrFalse (key: string, value: any): ErrResult | true { - if (_isString(value) || isFalse(value)) { + if (_.isString(value) || isFalse(value)) { return true } @@ -323,7 +316,7 @@ export function isFullyQualifiedUrl (key: string, value: any): ErrResult | true } export function isStringOrArrayOfStrings (key: string, value: any): ErrResult | true { - if (_isString(value) || isArrayOfStrings(value)) { + if (_.isString(value) || isArrayOfStrings(value)) { return true } From a5a2fef1b7f0957cb466385190ae111a7a667c91 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 18:50:59 -0600 Subject: [PATCH 41/96] bring back pluginsFile to make tests pass --- packages/config/lib/options.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/config/lib/options.ts b/packages/config/lib/options.ts index 8bf40547f6c7..1fa791875e24 100644 --- a/packages/config/lib/options.ts +++ b/packages/config/lib/options.ts @@ -248,6 +248,12 @@ const resolvedOptions: Array = [ defaultValue: 60000, validation: validate.isNumber, canUpdateDuringTestTime: true, + }, { + name: 'pluginsFile', + defaultValue: 'cypress/plugins', + validation: validate.isStringOrFalse, + isFolder: true, + canUpdateDuringTestTime: false, }, { name: 'port', defaultValue: null, From 0bc6fe66f7b33b64d81cdeb98ddf12a98edf597d Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 19:11:01 -0600 Subject: [PATCH 42/96] repair validation --- packages/config/lib/validation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/config/lib/validation.ts b/packages/config/lib/validation.ts index 8d31336155df..09b6babd73bf 100644 --- a/packages/config/lib/validation.ts +++ b/packages/config/lib/validation.ts @@ -32,7 +32,7 @@ const _isFullyQualifiedUrl = (value: any): ErrResult | boolean => { } const isArrayOfStrings = (value: any): ErrResult | boolean => { - return _.isArray(value) && _.every(value, isString) + return _.isArray(value) && _.every(value, _.isString) } const isFalse = (value: any): boolean => { From 35a81a4fdb3e4c657e0b12a2b1a6a915c1a214dc Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 19:32:21 -0600 Subject: [PATCH 43/96] fix unit tests --- .../config/__snapshots__/index_spec.ts.js | 153 ++++++++++++ .../__snapshots__/validation_spec.ts.js | 226 ++++++++++++++++++ packages/config/lib/validation.ts | 23 +- packages/config/package.json | 1 + .../unit/{index_spec.js => index_spec.ts} | 10 +- ...{validation_spec.js => validation_spec.ts} | 10 +- packages/config/tsconfig.json | 2 +- ...PTIONS_SPEC_PATTERN - componentFolder.html | 2 +- ...NFIG_OPTIONS_SPEC_PATTERN - testFiles.html | 2 +- .../MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html | 2 +- packages/errors/src/errors.ts | 1 - 11 files changed, 411 insertions(+), 21 deletions(-) create mode 100644 packages/config/__snapshots__/index_spec.ts.js create mode 100644 packages/config/__snapshots__/validation_spec.ts.js rename packages/config/test/unit/{index_spec.js => index_spec.ts} (96%) rename packages/config/test/unit/{validation_spec.js => validation_spec.ts} (98%) diff --git a/packages/config/__snapshots__/index_spec.ts.js b/packages/config/__snapshots__/index_spec.ts.js new file mode 100644 index 000000000000..950e55900213 --- /dev/null +++ b/packages/config/__snapshots__/index_spec.ts.js @@ -0,0 +1,153 @@ +exports['src/index .getBreakingKeys returns list of breaking config keys 1'] = [ + "integrationFolder", + "componentFolder", + "testFiles", + "blacklistHosts", + "experimentalComponentTesting", + "experimentalGetCookiesSameSite", + "experimentalNetworkStubbing", + "experimentalRunEvents", + "experimentalShadowDomSupport", + "firefoxGcInterval", + "nodeVersion", + "nodeVersion" +] + +exports['src/index .getDefaultValues returns list of public config keys 1'] = { + "animationDistanceThreshold": 5, + "baseUrl": null, + "blockHosts": null, + "chromeWebSecurity": true, + "clientCertificates": [], + "component": { + "specPattern": "**/*.cy.{js,jsx,ts,tsx}" + }, + "defaultCommandTimeout": 4000, + "downloadsFolder": "cypress/downloads", + "e2e": { + "specPattern": "cypress/e2e/**/*.cy.{js,jsx,ts,tsx}" + }, + "env": {}, + "execTimeout": 60000, + "exit": true, + "experimentalFetchPolyfill": false, + "experimentalInteractiveRunEvents": false, + "experimentalSessionSupport": false, + "experimentalSourceRewriting": false, + "fileServerFolder": "", + "fixturesFolder": "cypress/fixtures", + "excludeSpecPattern": "*.hot-update.js", + "includeShadowDom": false, + "keystrokeDelay": 0, + "modifyObstructiveCode": true, + "numTestsKeptInMemory": 50, + "pageLoadTimeout": 60000, + "pluginsFile": "cypress/plugins", + "port": null, + "projectId": null, + "redirectionLimit": 20, + "reporter": "spec", + "reporterOptions": null, + "requestTimeout": 5000, + "resolvedNodePath": null, + "resolvedNodeVersion": null, + "responseTimeout": 30000, + "retries": { + "runMode": 0, + "openMode": 0 + }, + "screenshotOnRunFailure": true, + "screenshotsFolder": "cypress/screenshots", + "slowTestThreshold": 10000, + "scrollBehavior": "top", + "supportFile": "cypress/support/e2e.{js,jsx,ts,tsx}", + "supportFolder": false, + "taskTimeout": 60000, + "trashAssetsBeforeRuns": true, + "userAgent": null, + "video": true, + "videoCompression": 32, + "videosFolder": "cypress/videos", + "videoUploadOnPasses": true, + "viewportHeight": 660, + "viewportWidth": 1000, + "waitForAnimations": true, + "watchForFileChanges": true, + "autoOpen": false, + "browsers": [], + "clientRoute": "/__/", + "configFile": "cypress.config.js", + "devServerPublicPathRoute": "/__cypress/src", + "hosts": null, + "isInteractive": true, + "isTextTerminal": false, + "morgan": true, + "namespace": "__cypress", + "reporterRoute": "/__cypress/reporter", + "socketId": null, + "socketIoCookie": "__socket.io", + "socketIoRoute": "/__socket.io", + "xhrRoute": "/xhrs/" +} + +exports['src/index .getPublicConfigKeys returns list of public config keys 1'] = [ + "animationDistanceThreshold", + "arch", + "baseUrl", + "blockHosts", + "chromeWebSecurity", + "clientCertificates", + "component", + "defaultCommandTimeout", + "downloadsFolder", + "e2e", + "env", + "execTimeout", + "exit", + "experimentalFetchPolyfill", + "experimentalInteractiveRunEvents", + "experimentalSessionSupport", + "experimentalSourceRewriting", + "fileServerFolder", + "fixturesFolder", + "excludeSpecPattern", + "includeShadowDom", + "keystrokeDelay", + "modifyObstructiveCode", + "nodeVersion", + "numTestsKeptInMemory", + "platform", + "pageLoadTimeout", + "pluginsFile", + "port", + "projectId", + "redirectionLimit", + "reporter", + "reporterOptions", + "requestTimeout", + "resolvedNodePath", + "resolvedNodeVersion", + "responseTimeout", + "retries", + "screenshotOnRunFailure", + "screenshotsFolder", + "slowTestThreshold", + "scrollBehavior", + "supportFile", + "supportFolder", + "taskTimeout", + "trashAssetsBeforeRuns", + "userAgent", + "video", + "videoCompression", + "videosFolder", + "videoUploadOnPasses", + "viewportHeight", + "viewportWidth", + "waitForAnimations", + "watchForFileChanges", + "browsers", + "hosts", + "isInteractive", + "modifyObstructiveCode" +] diff --git a/packages/config/__snapshots__/validation_spec.ts.js b/packages/config/__snapshots__/validation_spec.ts.js new file mode 100644 index 000000000000..1b3d0e62bfce --- /dev/null +++ b/packages/config/__snapshots__/validation_spec.ts.js @@ -0,0 +1,226 @@ +exports['src/validation .isValidClientCertificatesSet returns error message for certs not passed as an array array 1'] = { + "key": "mockConfigKey", + "value": "1", + "type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls" +} + +exports['src/validation .isValidClientCertificatesSet returns error message for certs object without url 1'] = { + "key": "clientCertificates[0].url", + "type": "a URL matcher" +} + +exports['missing https protocol'] = { + "key": "clientCertificates[0].url", + "value": "http://url.com", + "type": "an https protocol" +} + +exports['invalid url'] = { + "key": "clientCertificates[0].url", + "value": "not *", + "type": "a valid URL" +} + +exports['src/validation .isValidBrowser passes valid browsers and forms error messages for invalid ones isValidBrowser 1'] = { + "name": "isValidBrowser", + "behavior": [ + { + "given": { + "name": "Chrome", + "displayName": "Chrome Browser", + "family": "chromium", + "path": "/path/to/chrome", + "version": "1.2.3", + "majorVersion": 1 + }, + "expect": true + }, + { + "given": { + "name": "FF", + "displayName": "Firefox", + "family": "firefox", + "path": "/path/to/firefox", + "version": "1.2.3", + "majorVersion": "1" + }, + "expect": true + }, + { + "given": { + "name": "Electron", + "displayName": "Electron", + "family": "chromium", + "path": "", + "version": "99.101.3", + "majorVersion": 99 + }, + "expect": true + }, + { + "given": { + "name": "No display name", + "family": "chromium" + }, + "expect": { + "key": "displayName", + "value": { + "name": "No display name", + "family": "chromium" + }, + "type": "a non-empty string" + } + }, + { + "given": { + "name": "bad family", + "displayName": "Bad family browser", + "family": "unknown family" + }, + "expect": { + "key": "family", + "value": { + "name": "bad family", + "displayName": "Bad family browser", + "family": "unknown family" + }, + "type": "either chromium or firefox" + } + } + ] +} + +exports['undefined browsers'] = ` +Missing browsers list +` + +exports['empty list of browsers'] = ` +Expected at least one browser +` + +exports['browsers list with a string'] = { + "key": "name", + "value": "foo", + "type": "a non-empty string", + "list": "browsers" +} + +exports['invalid retry value'] = { + "key": "mockConfigKey", + "value": "1", + "type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls" +} + +exports['invalid retry object'] = { + "key": "mockConfigKey", + "value": { + "fakeMode": 1 + }, + "type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls" +} + +exports['src/validation .isPlainObject returns error message when value is a not an object 1'] = { + "key": "mockConfigKey", + "value": 1, + "type": "a plain object" +} + +exports['src/validation .isNumber returns error message when value is a not a number 1'] = { + "key": "mockConfigKey", + "value": "string", + "type": "a number" +} + +exports['src/validation .isNumberOrFalse returns error message when value is a not number or false 1'] = { + "key": "mockConfigKey", + "value": null, + "type": "a number or false" +} + +exports['not qualified url'] = { + "key": "mockConfigKey", + "value": "url.com", + "type": "a fully qualified URL (starting with `http://` or `https://`)" +} + +exports['empty string'] = { + "key": "mockConfigKey", + "value": "", + "type": "a fully qualified URL (starting with `http://` or `https://`)" +} + +exports['src/validation .isBoolean returns error message when value is a not a string 1'] = { + "key": "mockConfigKey", + "value": 1, + "type": "a string" +} + +exports['src/validation .isString returns error message when value is a not a string 1'] = { + "key": "mockConfigKey", + "value": 1, + "type": "a string" +} + +exports['src/validation .isArray returns error message when value is a non-array 1'] = { + "key": "mockConfigKey", + "value": 1, + "type": "an array" +} + +exports['src/validation .isStringOrFalse returns error message when value is neither string nor false 1'] = { + "key": "mockConfigKey", + "value": null, + "type": "a string or false" +} + +exports['not string or array'] = { + "key": "mockConfigKey", + "value": null, + "type": "a string or an array of strings" +} + +exports['array of non-strings'] = { + "key": "mockConfigKey", + "value": [ + 1, + 2, + 3 + ], + "type": "a string or an array of strings" +} + +exports['not one of the strings error message'] = { + "key": "test", + "value": "nope", + "type": "one of these values: \"foo\", \"bar\"" +} + +exports['number instead of string'] = { + "key": "test", + "value": 42, + "type": "one of these values: \"foo\", \"bar\"" +} + +exports['null instead of string'] = { + "key": "test", + "value": null, + "type": "one of these values: \"foo\", \"bar\"" +} + +exports['not one of the numbers error message'] = { + "key": "test", + "value": 4, + "type": "one of these values: 1, 2, 3" +} + +exports['string instead of a number'] = { + "key": "test", + "value": "foo", + "type": "one of these values: 1, 2, 3" +} + +exports['null instead of a number'] = { + "key": "test", + "value": null, + "type": "one of these values: 1, 2, 3" +} diff --git a/packages/config/lib/validation.ts b/packages/config/lib/validation.ts index 09b6babd73bf..e7843512addc 100644 --- a/packages/config/lib/validation.ts +++ b/packages/config/lib/validation.ts @@ -155,9 +155,10 @@ export const isOneOf = (...values: any[]): ((key: string, value: any) => ErrResu */ // _key: string, certsForUrls: any[]): ErrResult | true {} export const isValidClientCertificatesSet = (_key: string, certsForUrls: Array<{ - url: string - ca: string[] - certs: Array<{ + name?: string + url?: string + ca?: string[] + certs?: Array<{ key: string cert: string pfx: string @@ -245,9 +246,11 @@ export const isValidClientCertificatesSet = (_key: string, certsForUrls: Array<{ } } - for (let k = 0; k < certsForUrl.ca.length; k++) { - if (path.isAbsolute(certsForUrl.ca[k] || '')) { - return errMsg(`clientCertificates[${k}].ca[${k}]`, certsForUrl.ca[k], 'a relative filepath') + if (certsForUrl.ca) { + for (let k = 0; k < certsForUrl.ca.length; k++) { + if (path.isAbsolute(certsForUrl.ca[k] || '')) { + return errMsg(`clientCertificates[${k}].ca[${k}]`, certsForUrl.ca[k], 'a relative filepath') + } } } } @@ -287,6 +290,14 @@ export function isString (key: string, value: any): ErrResult | true { return errMsg(key, value, 'a string') } +export function isArray (key: string, value: any) { + if (value == null || _.isArray(value)) { + return true + } + + return errMsg(key, value, 'an array') +} + export function isNumberOrFalse (key: string, value: any): ErrResult | true { if (_.isNumber(value) || isFalse(value)) { return true diff --git a/packages/config/package.json b/packages/config/package.json index ad6ed81b588b..f9000f5ce24f 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -24,6 +24,7 @@ "@packages/root": "0.0.0-development", "@packages/ts": "0.0.0-development", "@packages/types": "0.0.0-development", + "@types/mocha": "^8.0.3", "@types/node": "14.14.31", "chai": "1.10.0", "mocha": "7.0.1", diff --git a/packages/config/test/unit/index_spec.js b/packages/config/test/unit/index_spec.ts similarity index 96% rename from packages/config/test/unit/index_spec.js rename to packages/config/test/unit/index_spec.ts index 526062fcf480..cb1d6b5e48ca 100644 --- a/packages/config/test/unit/index_spec.js +++ b/packages/config/test/unit/index_spec.ts @@ -1,9 +1,9 @@ -const chai = require('chai') -const snapshot = require('snap-shot-it') -const sinon = require('sinon') -const sinonChai = require('sinon-chai') +import chai from 'chai' +import snapshot from 'snap-shot-it' +import sinon from 'sinon' +import sinonChai from 'sinon-chai' -const configUtil = require('../../lib/index') +import * as configUtil from '../../lib/index' chai.use(sinonChai) const { expect } = chai diff --git a/packages/config/test/unit/validation_spec.js b/packages/config/test/unit/validation_spec.ts similarity index 98% rename from packages/config/test/unit/validation_spec.js rename to packages/config/test/unit/validation_spec.ts index b3ecbbeb8b51..8175d1d71768 100644 --- a/packages/config/test/unit/validation_spec.js +++ b/packages/config/test/unit/validation_spec.ts @@ -1,7 +1,7 @@ -const snapshot = require('snap-shot-it') -const { expect } = require('chai') +import snapshot from 'snap-shot-it' +import { expect } from 'chai' -const validation = require('../../lib/validation') +import * as validation from '../../lib/validation' describe('src/validation', () => { const mockKey = 'mockConfigKey' @@ -84,13 +84,13 @@ describe('src/validation', () => { // data-driven testing - computers snapshot value for each item in the list passed through the function // https://github.com/bahmutov/snap-shot-it#data-driven-testing - return snapshot.apply(null, [validation.isValidBrowser].concat(browsers)) + return snapshot.apply(null, [validation.isValidBrowser].concat(browsers as any)) }) }) describe('.isValidBrowserList', () => { it('does not allow empty or not browsers', () => { - snapshot('undefined browsers', validation.isValidBrowserList('browsers')) + snapshot('undefined browsers', validation.isValidBrowserList('browsers', undefined)) snapshot('empty list of browsers', validation.isValidBrowserList('browsers', [])) return snapshot('browsers list with a string', validation.isValidBrowserList('browsers', ['foo'])) diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json index c6d38692fad2..f44bac211ef4 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../ts/tsconfig.json", "include": [ - "lib/*", + "lib", ], "compilerOptions": { "outDir": "./dist", diff --git a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - componentFolder.html b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - componentFolder.html index b3e16998b450..784af1c0e77a 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - componentFolder.html +++ b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - componentFolder.html @@ -34,7 +34,7 @@ -
You are attempting to use a configuration value that is no longer supported: componentFolder
+    
You are attempting to use a configuration that is no longer supported: componentFolder
 
 componentFolder merged with testFiles into the specPattern option.
 
diff --git a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html
index 23cb3e8daa68..0afc4b4ea20f 100644
--- a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html	
+++ b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html	
@@ -34,7 +34,7 @@
     
   
     
-    
You are attempting to use a configuration value that is no longer supported: testFiles
+    
You are attempting to use a configuration that is no longer supported: testFiles
 
 testFiles merged with integrationFolder or componentFolder into the specPattern option.
 
diff --git a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html
index d519fcaecf94..a190d2b0eab8 100644
--- a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html
+++ b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html
@@ -34,7 +34,7 @@
     
   
     
-    
You are attempting to use a configuration value that is no longer supported: integrationFolder
+    
You are attempting to use a configuration that is no longer supported: integrationFolder
 
 integrationFolder merged with testFiles into the specPattern option.
 
diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts
index 769460d25f24..a603ca53d51e 100644
--- a/packages/errors/src/errors.ts
+++ b/packages/errors/src/errors.ts
@@ -1331,7 +1331,6 @@ export const AllCypressErrors = {
 
     return errTemplate`
     ${message}
-      
     ${fmt.highlight(name)} merged with ${mergedOptionKey} into the ${fmt.highlight(`${testingTypePrefix}specPattern`)} option.
 
     https://on.cypress.io/migration-guide

From 08d07e958ced4dada3a35e80800b8585212d802f Mon Sep 17 00:00:00 2001
From: ElevateBart 
Date: Thu, 10 Mar 2022 20:45:01 -0600
Subject: [PATCH 44/96] clean up a little

---
 packages/app/cypress.config.ts                   | 1 +
 packages/config/package.json                     | 6 +++---
 packages/config/tsconfig.json                    | 1 +
 packages/errors/package.json                     | 1 +
 packages/errors/src/errors.ts                    | 4 ++++
 packages/server/lib/plugins/child/run_plugins.js | 8 ++------
 6 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/packages/app/cypress.config.ts b/packages/app/cypress.config.ts
index 952ff3d10dc1..bc92bf5d4434 100644
--- a/packages/app/cypress.config.ts
+++ b/packages/app/cypress.config.ts
@@ -38,6 +38,7 @@ export default defineConfig({
   },
   'e2e': {
     baseUrl: 'http://localhost:5555',
+    pluginsFile: 'cypress/e2e/plugins/index.ts',
     supportFile: 'cypress/e2e/support/e2eSupport.ts',
     async setupNodeEvents (on, config) {
       if (!process.env.HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS) {
diff --git a/packages/config/package.json b/packages/config/package.json
index f9000f5ce24f..d723da674ae7 100644
--- a/packages/config/package.json
+++ b/packages/config/package.json
@@ -34,8 +34,8 @@
   },
   "files": [
     "lib",
-    "index.js",
-    "index.d.ts"
+    "dist",
+    "index.js"
   ],
-  "types": "lib/index.ts"
+  "types": "dist/index.ts"
 }
diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json
index f44bac211ef4..95a3540694c7 100644
--- a/packages/config/tsconfig.json
+++ b/packages/config/tsconfig.json
@@ -13,5 +13,6 @@
     "experimentalDecorators": true,
     "noUncheckedIndexedAccess": true,
     "importsNotUsedAsValues": "error",
+    "sourceMap": true
   }
 }
diff --git a/packages/errors/package.json b/packages/errors/package.json
index 561bd2ec20bd..9f3f255dc6a3 100644
--- a/packages/errors/package.json
+++ b/packages/errors/package.json
@@ -21,6 +21,7 @@
     "strip-ansi": "6.0.0"
   },
   "devDependencies": {
+    "@packages/config": "0.0.0-development",
     "@packages/ts": "0.0.0-development",
     "@types/chai": "4.2.15",
     "@types/mocha": "^8.0.3",
diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts
index a603ca53d51e..92e8f7562774 100644
--- a/packages/errors/src/errors.ts
+++ b/packages/errors/src/errors.ts
@@ -1350,8 +1350,12 @@ export const AllCypressErrors = {
       https://on.cypress.io/migration-guide
     `
   },
+
 } as const
 
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
+const _typeCheck: Record ErrTemplateResult> = AllCypressErrors
+
 type AllCypressErrorObj = typeof AllCypressErrors
 
 export type AllCypressErrorNames = keyof typeof AllCypressErrors
diff --git a/packages/server/lib/plugins/child/run_plugins.js b/packages/server/lib/plugins/child/run_plugins.js
index 21265f209ebf..631614664f14 100644
--- a/packages/server/lib/plugins/child/run_plugins.js
+++ b/packages/server/lib/plugins/child/run_plugins.js
@@ -264,16 +264,12 @@ class RunPlugins {
   }
 }
 
-function getNonMigratedOptionsErr (name, errorKey, errInternal) {
-  return require('@packages/errors').getError(errorKey, { name }, errInternal)
-}
-
-function throwInvalidOptionError (name, errorKey) {
+function throwInvalidOptionError (errorKey, name) {
   debug('throwing err %s', name)
   const errInternal = new Error()
 
   Error.captureStackTrace(errInternal, throwInvalidOptionError)
-  const err = getNonMigratedOptionsErr(errorKey, name, errInternal)
+  const err = require('@packages/errors').getError(errorKey, { name }, errInternal)
 
   throw err
 }

From 44fb35a049e9a2b755c0086580950d678096908b Mon Sep 17 00:00:00 2001
From: ElevateBart 
Date: Thu, 10 Mar 2022 21:20:00 -0600
Subject: [PATCH 45/96] fix types

---
 packages/config/package.json  | 2 +-
 packages/config/tsconfig.json | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/packages/config/package.json b/packages/config/package.json
index d723da674ae7..1802895b5351 100644
--- a/packages/config/package.json
+++ b/packages/config/package.json
@@ -37,5 +37,5 @@
     "dist",
     "index.js"
   ],
-  "types": "dist/index.ts"
+  "types": "dist/index.d.ts"
 }
diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json
index 95a3540694c7..7648e38890e1 100644
--- a/packages/config/tsconfig.json
+++ b/packages/config/tsconfig.json
@@ -13,6 +13,7 @@
     "experimentalDecorators": true,
     "noUncheckedIndexedAccess": true,
     "importsNotUsedAsValues": "error",
+    "declaration": true,
     "sourceMap": true
   }
 }

From 8943951d96dc3fbe11db5de395b4f21728c9e554 Mon Sep 17 00:00:00 2001
From: ElevateBart 
Date: Thu, 10 Mar 2022 22:02:51 -0600
Subject: [PATCH 46/96] fix: replace testfiles error with the 3 errors

---
 packages/config/lib/options.ts                |  5 --
 .../TEST_FILES_DEPRECATION.html               | 53 -------------------
 packages/errors/src/errors.ts                 | 21 --------
 .../test/unit/visualSnapshotErrors_spec.ts    |  5 --
 4 files changed, 84 deletions(-)
 delete mode 100644 packages/errors/__snapshot-html__/TEST_FILES_DEPRECATION.html

diff --git a/packages/config/lib/options.ts b/packages/config/lib/options.ts
index e447ea444d64..1fa791875e24 100644
--- a/packages/config/lib/options.ts
+++ b/packages/config/lib/options.ts
@@ -559,11 +559,6 @@ export const breakingOptions: Array = [
     errorKey: 'NODE_VERSION_DEPRECATION_BUNDLED',
     isWarning: true,
   },
-  {
-    name: 'testFiles',
-    errorKey: 'TEST_FILES_DEPRECATION',
-    isWarning: false,
-  },
 ]
 
 export const breakingRootOptions: Array = [
diff --git a/packages/errors/__snapshot-html__/TEST_FILES_DEPRECATION.html b/packages/errors/__snapshot-html__/TEST_FILES_DEPRECATION.html
deleted file mode 100644
index 3bdd2294d75b..000000000000
--- a/packages/errors/__snapshot-html__/TEST_FILES_DEPRECATION.html
+++ /dev/null
@@ -1,53 +0,0 @@
-
-    
-    
-      
-      
-    
-    
-    
-    
-  
-    
-    
The testFiles configuration option is now invalid when set on the config object in Cypress version 10.0.0.
-
- It is now renamed to specPattern and configured separately as a testing type property: e2e.specPattern and component.specPattern
-
- 
-
-{
-  e2e: {
-    specPattern: '...',
-  },
-  component: {
-    specPattern: '...',
-  },
-}
-
- https://on.cypress.io/migration-guide
-
\ No newline at end of file diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index 3a8adbe79d6b..92e8f7562774 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1351,27 +1351,6 @@ export const AllCypressErrors = { ` }, - TEST_FILES_DEPRECATION: (errShape: BreakingErrResult) => { - const code = errPartial` - { - e2e: { - specPattern: '...', - }, - component: { - specPattern: '...', - }, - }` - - return errTemplate`\ - The ${fmt.highlight(errShape.name)} configuration option is now invalid when set on the config object in ${fmt.cypressVersion(`10.0.0`)}. - - It is now renamed to ${fmt.highlight('specPattern')} and configured separately as a testing type property: ${fmt.highlightSecondary('e2e.specPattern')} and ${fmt.highlightSecondary('component.specPattern')} - - ${fmt.code(code)} - - https://on.cypress.io/migration-guide` - }, - } as const // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/packages/errors/test/unit/visualSnapshotErrors_spec.ts b/packages/errors/test/unit/visualSnapshotErrors_spec.ts index 5c617ac038fc..dd8ed2e52d84 100644 --- a/packages/errors/test/unit/visualSnapshotErrors_spec.ts +++ b/packages/errors/test/unit/visualSnapshotErrors_spec.ts @@ -1108,10 +1108,5 @@ describe('visual error templates', () => { default: ['custom.config.js', 'custom.json'], } }, - TEST_FILES_DEPRECATION: () => { - return { - default: [{ name: 'testFiles', configFile: '/path/to/cypress.config.js.ts' }], - } - }, }) }) From bee32f91e1ab279abb66b9cfac4348da01061b3e Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 22:09:42 -0600 Subject: [PATCH 47/96] use the existing message to make the existing better --- ...PTIONS_SPEC_PATTERN - componentFolder.html | 15 +++++-- ...NFIG_OPTIONS_SPEC_PATTERN - testFiles.html | 15 +++++-- .../MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html | 15 +++++-- packages/errors/src/errors.ts | 43 ++++++++++++------- 4 files changed, 64 insertions(+), 24 deletions(-) diff --git a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - componentFolder.html b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - componentFolder.html index 784af1c0e77a..1ee9646bb1e3 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - componentFolder.html +++ b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - componentFolder.html @@ -34,13 +34,22 @@ -
You are attempting to use a configuration that is no longer supported: componentFolder
+    
The componentFolder configuration option is now invalid when set on the config object in Cypress version 10.0.0.
 
-componentFolder merged with testFiles into the specPattern option.
+It is now merged with testFiles into specPattern option and configured separately as a testing type property
+
+{
+  e2e: {
+    specPattern: '...',
+  },
+  component: {
+    specPattern: '...',
+  },
+}
 
 https://on.cypress.io/migration-guide
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html index 0afc4b4ea20f..4f1180d2e161 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html +++ b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html @@ -34,13 +34,22 @@ -
You are attempting to use a configuration that is no longer supported: testFiles
+    
The testFiles configuration option is now invalid when set on the config object in Cypress version 10.0.0.
 
-testFiles merged with integrationFolder or componentFolder into the specPattern option.
+It is now merged with integrationFolder or componentFolder into specPattern option and configured separately as a testing type property
+
+{
+  e2e: {
+    specPattern: '...',
+  },
+  component: {
+    specPattern: '...',
+  },
+}
 
 https://on.cypress.io/migration-guide
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html index a190d2b0eab8..03d34d21b358 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html +++ b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html @@ -34,13 +34,22 @@ -
You are attempting to use a configuration that is no longer supported: integrationFolder
+    
The integrationFolder configuration option is now invalid when set on the config object in Cypress version 10.0.0.
 
-integrationFolder merged with testFiles into the specPattern option.
+It is now merged with testFiles into specPattern option and configured separately as a testing type property
+
+{
+  e2e: {
+    specPattern: '...',
+  },
+  component: {
+    specPattern: '...',
+  },
+}
 
 https://on.cypress.io/migration-guide
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index 92e8f7562774..523e456320ae 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1310,6 +1310,18 @@ export const AllCypressErrors = { ` }, + MIGRATION_ALREADY_OCURRED: (configFile: string, legacyConfigFile: string) => { + return errTemplate` + You are attempting to use Cypress with an older config file: ${fmt.highlight(legacyConfigFile)} + When you upgraded to Cypress v10.0 the config file was updated and moved to a new location: ${fmt.highlight(configFile)} + + You may need to update any CLI scripts to ensure that they are referring the new version. This would typically look something like: + "${fmt.highlight(`cypress open --config-file=${configFile}`)}" + + https://on.cypress.io/migration-guide + ` + }, + MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN: ({ name, setupNodeEvents }: {name: string, setupNodeEvents: boolean}, err?: Error) => { const stackTrace = err ? fmt.stackTrace(err) : null @@ -1324,14 +1336,27 @@ export const AllCypressErrors = { : errPartial`${fmt.highlight('testFiles')}` const message = setupNodeEvents ? errPartial` - In ${fmt.highlight('setupNodeEvents()')}, you are attempting to update a configuration that is no longer supported: ${fmt.highlight(name)} + In ${fmt.highlight('setupNodeEvents()')}, you are attempting to update a the ${fmt.highlight(name)} configuration option. + Its now invalid on the config object in ${fmt.cypressVersion(`10.0.0`)}. ` : errPartial` - You are attempting to use a configuration that is no longer supported: ${fmt.highlight(name)} + The ${fmt.highlight(name)} configuration option is now invalid when set on the config object in ${fmt.cypressVersion(`10.0.0`)}. ` + const code = errPartial` + { + e2e: { + specPattern: '...', + }, + component: { + specPattern: '...', + }, + }` + return errTemplate` ${message} - ${fmt.highlight(name)} merged with ${mergedOptionKey} into the ${fmt.highlight(`${testingTypePrefix}specPattern`)} option. + It is now merged with ${mergedOptionKey} into ${fmt.highlight(`${testingTypePrefix}specPattern`)} option and configured separately as a testing type property + + ${fmt.code(code)} https://on.cypress.io/migration-guide @@ -1339,18 +1364,6 @@ export const AllCypressErrors = { ` }, - MIGRATION_ALREADY_OCURRED: (configFile: string, legacyConfigFile: string) => { - return errTemplate` - You are attempting to use Cypress with an older config file: ${fmt.highlight(legacyConfigFile)} - When you upgraded to Cypress v10.0 the config file was updated and moved to a new location: ${fmt.highlight(configFile)} - - You may need to update any CLI scripts to ensure that they are referring the new version. This would typically look something like: - "${fmt.highlight(`cypress open --config-file=${configFile}`)}" - - https://on.cypress.io/migration-guide - ` - }, - } as const // eslint-disable-next-line @typescript-eslint/no-unused-vars From 5b67d1240984dba31d374da1a2cefd3611d07958 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 22:15:42 -0600 Subject: [PATCH 48/96] fix error types --- ...TIONS_SPEC_PATTERN - testFilesInSetup.html | 56 +++++++++++++++++++ packages/errors/src/errors.ts | 2 +- .../test/unit/visualSnapshotErrors_spec.ts | 13 +++-- 3 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFilesInSetup.html diff --git a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFilesInSetup.html b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFilesInSetup.html new file mode 100644 index 000000000000..459a6b2c816b --- /dev/null +++ b/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFilesInSetup.html @@ -0,0 +1,56 @@ + + + + + + + + + + + +
In setupNodeEvents(), you are attempting to update a the testFiles configuration option. 
+Its now invalid on the config object in Cypress version 10.0.0.
+
+It is now merged with integrationFolder or componentFolder into specPattern option and configured separately as a testing type property
+
+{
+  e2e: {
+    specPattern: '...',
+  },
+  component: {
+    specPattern: '...',
+  },
+}
+
+https://on.cypress.io/migration-guide
+
+Error: fail whale
+    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+
\ No newline at end of file diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index 523e456320ae..76b9cace5ffd 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1322,7 +1322,7 @@ export const AllCypressErrors = { ` }, - MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN: ({ name, setupNodeEvents }: {name: string, setupNodeEvents: boolean}, err?: Error) => { + MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN: ({ name, setupNodeEvents = false }: {name: string, setupNodeEvents?: boolean}, err?: Error) => { const stackTrace = err ? fmt.stackTrace(err) : null // some keys come prefixed with a `component.` or `e2e.` but they are not referenced diff --git a/packages/errors/test/unit/visualSnapshotErrors_spec.ts b/packages/errors/test/unit/visualSnapshotErrors_spec.ts index dd8ed2e52d84..e955f6c29990 100644 --- a/packages/errors/test/unit/visualSnapshotErrors_spec.ts +++ b/packages/errors/test/unit/visualSnapshotErrors_spec.ts @@ -1096,16 +1096,17 @@ describe('visual error templates', () => { default: [makeErr()], } }, - MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN: () => { + MIGRATION_ALREADY_OCURRED: () => { return { - default: [{ name: 'integrationFolder' }, makeErr()], - testFiles: [{ name: 'testFiles' }, makeErr()], - componentFolder: [{ name: 'componentFolder' }, makeErr()], + default: ['custom.config.js', 'custom.json'], } }, - MIGRATION_ALREADY_OCURRED: () => { + MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN: () => { return { - default: ['custom.config.js', 'custom.json'], + default: [{ name: 'integrationFolder', setupNodeEvents: false }, makeErr()], + testFiles: [{ name: 'testFiles', setupNodeEvents: false }, makeErr()], + componentFolder: [{ name: 'componentFolder', setupNodeEvents: false }, makeErr()], + testFilesInSetup: [{ name: 'testFiles', setupNodeEvents: true }, makeErr()], } }, }) From 139e21df8982e2d82eb6296c2aed6dcb28851b68 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Thu, 10 Mar 2022 22:16:23 -0600 Subject: [PATCH 49/96] make better types --- packages/errors/test/unit/visualSnapshotErrors_spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/errors/test/unit/visualSnapshotErrors_spec.ts b/packages/errors/test/unit/visualSnapshotErrors_spec.ts index e955f6c29990..4b24a1515318 100644 --- a/packages/errors/test/unit/visualSnapshotErrors_spec.ts +++ b/packages/errors/test/unit/visualSnapshotErrors_spec.ts @@ -1103,9 +1103,9 @@ describe('visual error templates', () => { }, MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN: () => { return { - default: [{ name: 'integrationFolder', setupNodeEvents: false }, makeErr()], - testFiles: [{ name: 'testFiles', setupNodeEvents: false }, makeErr()], - componentFolder: [{ name: 'componentFolder', setupNodeEvents: false }, makeErr()], + default: [{ name: 'integrationFolder' }, makeErr()], + testFiles: [{ name: 'testFiles' }, makeErr()], + componentFolder: [{ name: 'componentFolder' }, makeErr()], testFilesInSetup: [{ name: 'testFiles', setupNodeEvents: true }, makeErr()], } }, From 12a7a295d76cc6d6e2bd1fdb5ba369f74dadce61 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 09:30:12 -0600 Subject: [PATCH 50/96] clean up mocha types --- cli/package.json | 2 +- npm/cypress-schematic/package.json | 2 +- .../package.json | 2 +- npm/webpack-preprocessor/package.json | 2 +- package.json | 2 +- packages/ts/tsconfig.json | 6 +----- system-tests/package.json | 2 +- system-tests/tsconfig.json | 8 ++------ yarn.lock | 17 +---------------- 9 files changed, 10 insertions(+), 33 deletions(-) diff --git a/cli/package.json b/cli/package.json index b068831e4755..2137a276c90b 100644 --- a/cli/package.json +++ b/cli/package.json @@ -73,7 +73,7 @@ "@types/jquery": "3.3.31", "@types/lodash": "4.14.168", "@types/minimatch": "3.0.3", - "@types/mocha": "8.0.3", + "@types/mocha": "^8.0.3", "@types/sinon": "9.0.9", "@types/sinon-chai": "3.2.5", "chai": "3.5.0", diff --git a/npm/cypress-schematic/package.json b/npm/cypress-schematic/package.json index de5a50461c22..129bad5cc19c 100644 --- a/npm/cypress-schematic/package.json +++ b/npm/cypress-schematic/package.json @@ -29,7 +29,7 @@ "@angular-devkit/schematics-cli": "^12.2.10", "@angular/cli": "^12", "@types/chai-enzyme": "0.6.7", - "@types/mocha": "8.0.3", + "@types/mocha": "^8.0.3", "@types/node": "^12.11.1", "chai": "4.2.0", "cypress": "0.0.0-development", diff --git a/npm/webpack-batteries-included-preprocessor/package.json b/npm/webpack-batteries-included-preprocessor/package.json index 1844b995deb1..93948ff493f9 100644 --- a/npm/webpack-batteries-included-preprocessor/package.json +++ b/npm/webpack-batteries-included-preprocessor/package.json @@ -27,7 +27,7 @@ "devDependencies": { "@cypress/eslint-plugin-dev": "0.0.0-development", "@cypress/webpack-preprocessor": "0.0.0-development", - "@types/mocha": "^8.0.2", + "@types/mocha": "^8.0.3", "@types/webpack": "^4.41.21", "@typescript-eslint/eslint-plugin": "^4.18.0", "@typescript-eslint/parser": "^4.18.0", diff --git a/npm/webpack-preprocessor/package.json b/npm/webpack-preprocessor/package.json index 5094cca30b70..20c8dfbe992a 100644 --- a/npm/webpack-preprocessor/package.json +++ b/npm/webpack-preprocessor/package.json @@ -29,7 +29,7 @@ "@babel/plugin-proposal-nullish-coalescing-operator": "7.8.3", "@babel/preset-env": "^7.0.0", "@fellow/eslint-plugin-coffee": "0.4.13", - "@types/mocha": "9.0.0", + "@types/mocha": "^8.0.3", "@types/webpack": "^4.41.12", "@typescript-eslint/eslint-plugin": "^4.18.0", "@typescript-eslint/parser": "^4.18.0", diff --git a/package.json b/package.json index d9eef74411aa..3a0ceb99a1d1 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "@types/lodash": "^4.14.168", "@types/markdown-it": "0.0.9", "@types/mini-css-extract-plugin": "1.2.3", - "@types/mocha": "8.0.3", + "@types/mocha": "^8.0.3", "@types/node": "14.14.31", "@types/prismjs": "1.16.0", "@types/react": "16.9.50", diff --git a/packages/ts/tsconfig.json b/packages/ts/tsconfig.json index 6eb416793792..3a420e646393 100644 --- a/packages/ts/tsconfig.json +++ b/packages/ts/tsconfig.json @@ -54,10 +54,6 @@ /* Experimental Options */ "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - "importsNotUsedAsValues": "error", - "typeRoots": [ - "./node_modules/@types", - "../../node_modules/@types", - ] + "importsNotUsedAsValues": "error" } } diff --git a/system-tests/package.json b/system-tests/package.json index 2d8df3a5c906..58df6eafaeca 100644 --- a/system-tests/package.json +++ b/system-tests/package.json @@ -30,7 +30,7 @@ "@packages/ts": "0.0.0-development", "@storybook/testing-vue3": "0.0.1", "@types/chai": "4.2.15", - "@types/mocha": "9.1.0", + "@types/mocha": "^8.0.3", "babel-loader": "8.1.0", "bluebird": "3.7.2", "body-parser": "1.19.0", diff --git a/system-tests/tsconfig.json b/system-tests/tsconfig.json index 07ba654d5fda..d2c2d7186adf 100644 --- a/system-tests/tsconfig.json +++ b/system-tests/tsconfig.json @@ -9,15 +9,11 @@ "./globals.d.ts" ], "compilerOptions": { - "types": [ - "mocha", - "node", - "chai" - ], "noEmit": true, "lib": ["esnext"], "skipLibCheck": true, "noImplicitReturns": false, - "strictNullChecks": false + "strictNullChecks": false, + "typeRoots": ["../node_modules/@types"] } } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index f5c6b396a570..767069405070 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9888,22 +9888,7 @@ resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.1.tgz#283f669ff76d7b8260df8ab7a4262cc83d988256" integrity sha512-fZQQafSREFyuZcdWFAExYjBiCL7AUCdgsk80iO0q4yihYYdcIiH28CcuPTGFgLOCC8RlW49GSQxdHwZP+I7CNg== -"@types/mocha@8.0.3": - version "8.0.3" - resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.0.3.tgz#51b21b6acb6d1b923bbdc7725c38f9f455166402" - integrity sha512-vyxR57nv8NfcU0GZu8EUXZLTbCMupIUwy95LJ6lllN+JRPG25CwMHoB1q5xKh8YKhQnHYRAn4yW2yuHbf/5xgg== - -"@types/mocha@9.0.0": - version "9.0.0" - resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.0.0.tgz#3205bcd15ada9bc681ac20bef64e9e6df88fd297" - integrity sha512-scN0hAWyLVAvLR9AyW7HoFF5sJZglyBsbPuHO4fv7JRvfmPBMfp1ozWqOf/e4wwPNxezBZXRfWzMb6iFLgEVRA== - -"@types/mocha@9.1.0": - version "9.1.0" - resolved "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.0.tgz#baf17ab2cca3fcce2d322ebc30454bff487efad5" - integrity sha512-QCWHkbMv4Y5U9oW10Uxbr45qMMSzl4OzijsozynUAgx3kEHUdXB00udx2dWDQ7f2TU2a2uuiFaRZjCe3unPpeg== - -"@types/mocha@^8.0.2", "@types/mocha@^8.0.3": +"@types/mocha@^8.0.3": version "8.2.2" resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.2.2.tgz#91daa226eb8c2ff261e6a8cbf8c7304641e095e0" integrity sha512-Lwh0lzzqT5Pqh6z61P3c3P5nm6fzQK/MMHl9UKeneAeInVflBSz1O2EkX6gM6xfJd7FBXBY5purtLx7fUiZ7Hw== From a9cc80264a4950d34a598af456f16e4fe20c60a5 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 09:34:31 -0600 Subject: [PATCH 51/96] give a little more time to error test to avoid flake --- packages/driver/cypress/e2e/commands/actions/selectFile.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/driver/cypress/e2e/commands/actions/selectFile.cy.js b/packages/driver/cypress/e2e/commands/actions/selectFile.cy.js index fdcb604a7d8e..d96b3de904e9 100644 --- a/packages/driver/cypress/e2e/commands/actions/selectFile.cy.js +++ b/packages/driver/cypress/e2e/commands/actions/selectFile.cy.js @@ -336,7 +336,7 @@ describe('src/cy/commands/actions/selectFile', () => { }) describe('errors', { - defaultCommandTimeout: 50, + defaultCommandTimeout: 100, }, () => { it('is a child command', (done) => { cy.on('fail', (err) => { From 2b87871f5d574a2376019d37db5ca2ef7e9c7288 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 12:32:38 -0600 Subject: [PATCH 52/96] update patch and remove some folders --- cli/schema/cypress.schema.json | 13 - cli/types/cypress.d.ts | 11 - npm/webpack-preprocessor/cypress.config.js | 10 +- .../cypress/fixtures/config.json | 5 - patches/@types+mocha+8.0.3.dev.patch | 5607 ---------------- patches/@types+mocha+8.2.2.dev.patch | 5727 +++++++++++++++++ 6 files changed, 5733 insertions(+), 5640 deletions(-) delete mode 100644 patches/@types+mocha+8.0.3.dev.patch create mode 100644 patches/@types+mocha+8.2.2.dev.patch diff --git a/cli/schema/cypress.schema.json b/cli/schema/cypress.schema.json index 6a68180aed07..17007f2178f9 100644 --- a/cli/schema/cypress.schema.json +++ b/cli/schema/cypress.schema.json @@ -98,24 +98,11 @@ "default": "cypress/fixtures", "description": "Path to folder containing fixture files (Pass false to disable)" }, - "integrationFolder": { - "type": "string", - "default": "cypress/integration", - "description": "Path to folder containing integration test files" - }, "downloadsFolder": { "type": "string", "default": "cypress/downloads", "description": "Path to folder where files downloaded during a test are saved" }, - "componentFolder": { - "type": [ - "string", - "boolean" - ], - "default": false, - "description": "Path to folder containing component test files (Pass false to disable)" - }, "pluginsFile": { "type": [ "string", diff --git a/cli/types/cypress.d.ts b/cli/types/cypress.d.ts index ec62aaa51048..dab2a9251a8d 100644 --- a/cli/types/cypress.d.ts +++ b/cli/types/cypress.d.ts @@ -2697,12 +2697,6 @@ declare namespace Cypress { * @default "cypress/fixtures" */ fixturesFolder: string | false - /** - * Path to folder containing integration test files - * @default "cypress/integration" - * @deprecated - */ - integrationFolder: string /** * Path to folder where files downloaded during a test are saved * @default "cypress/downloads" @@ -2843,11 +2837,6 @@ declare namespace Cypress { * The list of hosts to be blocked */ blockHosts: null | string | string[] - /** - * Path to folder containing component test files. - * @deprecated - */ - componentFolder: false | string /** * A unique ID for the project used for recording */ diff --git a/npm/webpack-preprocessor/cypress.config.js b/npm/webpack-preprocessor/cypress.config.js index e175544e4e89..42bff476f244 100644 --- a/npm/webpack-preprocessor/cypress.config.js +++ b/npm/webpack-preprocessor/cypress.config.js @@ -1,6 +1,8 @@ -module.exports = { - 'integrationFolder': 'cypress/tests', - 'e2e': { +const { defineConfig } = require('cypress') + +module.exports = defineConfig({ + e2e: { + specPattern: 'cypress/tests/**/*', setupNodeEvents (on, config) { const webpackPreprocessor = require('./index') @@ -9,4 +11,4 @@ module.exports = { return config }, }, -} +}) diff --git a/packages/frontend-shared/cypress/fixtures/config.json b/packages/frontend-shared/cypress/fixtures/config.json index 409cf9176708..3f1f694e0667 100644 --- a/packages/frontend-shared/cypress/fixtures/config.json +++ b/packages/frontend-shared/cypress/fixtures/config.json @@ -133,11 +133,6 @@ "from": "default", "field": "includeShadowDom" }, - { - "value": "cypress/e2e/integration", - "from": "config", - "field": "integrationFolder" - }, { "value": true, "from": "default", diff --git a/patches/@types+mocha+8.0.3.dev.patch b/patches/@types+mocha+8.0.3.dev.patch deleted file mode 100644 index 5081b5c7b859..000000000000 --- a/patches/@types+mocha+8.0.3.dev.patch +++ /dev/null @@ -1,5607 +0,0 @@ -diff --git a/node_modules/@types/mocha/index.d.ts b/node_modules/@types/mocha/index.d.ts -index 8d4c6db..307f232 100644 ---- a/node_modules/@types/mocha/index.d.ts -+++ b/node_modules/@types/mocha/index.d.ts -@@ -1,2801 +1,2801 @@ --// Type definitions for mocha 8.0 --// Project: https://mochajs.org --// Definitions by: Kazi Manzur Rashid --// otiai10 --// Vadim Macagon --// Andrew Bradley --// Dmitrii Sorin --// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped --// TypeScript Version: 2.1 -- --/** -- * Mocha API -- * -- * @see https://mochajs.org/api/mocha -- */ --declare class Mocha { -- private _growl; -- private _reporter; -- private _ui; -- -- constructor(options?: Mocha.MochaOptions); -- -- suite: Mocha.Suite; -- files: string[]; -- options: Mocha.MochaInstanceOptions; -- -- /** -- * Enable or disable bailing on the first failure. -- * -- * @see https://mochajs.org/api/mocha#bail -- */ -- bail(bail?: boolean): this; -- -- /** -- * Add test `file`. -- * -- * @see https://mochajs.org/api/mocha#addFile -- */ -- addFile(file: string): this; -- -- /** -- * Set reporter to one of the built-in reporters. -- * -- * @see https://mochajs.org/api/mocha#reporter -- */ -- reporter(reporter: Mocha.Reporter, reporterOptions?: any): this; -- -- /** -- * Set reporter to the provided constructor, one of the built-in reporters, or loads a reporter -- * from a module path. Defaults to `"spec"`. -- * -- * @see https://mochajs.org/api/mocha#reporter -- */ -- reporter(reporter?: string | Mocha.ReporterConstructor, reporterOptions?: any): this; -- -- /** -- * Set test UI to one of the built-in test interfaces. -- * -- * @see https://mochajs.org/api/mocha#ui -- */ -- ui(name: Mocha.Interface): this; -- -- /** -- * Set test UI to one of the built-in test interfaces or loads a test interface from a module -- * path. Defaults to `"bdd"`. -- * -- * @see https://mochajs.org/api/mocha#ui -- */ -- ui(name?: string): this; -- -- /** -- * Escape string and add it to grep as a RegExp. -- * -- * @see https://mochajs.org/api/mocha#fgrep -- */ -- fgrep(str: string): this; -- -- /** -- * Add regexp to grep, if `re` is a string it is escaped. -- * -- * @see https://mochajs.org/api/mocha#grep -- */ -- grep(re: string | RegExp): this; -- -- /** -- * Invert `.grep()` matches. -- * -- * @see https://mochajs.org/api/mocha#invert -- */ -- invert(): this; -- -- /** -- * Enable global leak checking. -- * -- * @see https://mochajs.org/api/mocha#checkLeaks -- */ -- checkLeaks(): this; -- -- /** -- * Display long stack-trace on failing -- * -- * @see https://mochajs.org/api/mocha#fullTrace -- */ -- fullTrace(): this; -- -- /** -- * Enable growl support. -- * -- * @see https://mochajs.org/api/mocha#growl -- */ -- growl(): this; -- -- /** -- * Ignore `globals` array or string. -- * -- * @see https://mochajs.org/api/mocha#globals -- */ -- globals(globals: string | ReadonlyArray): this; -- -- /** -- * Set the timeout in milliseconds. -- * -- * @see https://mochajs.org/api/mocha#timeout -- */ -- timeout(timeout: string | number): this; -- -- /** -- * Set the number of times to retry failed tests. -- * -- * @see https://mochajs.org/api/mocha#retries -- */ -- retries(n: number): this; -- -- /** -- * Set slowness threshold in milliseconds. -- * -- * @see https://mochajs.org/api/mocha#slow -- */ -- slow(slow: string | number): this; -- -- /** -- * Makes all tests async (accepting a callback) -- * -- * @see https://mochajs.org/api/mocha#asyncOnly. -- */ -- asyncOnly(): this; -- -- /** -- * Disable syntax highlighting (in browser). -- * -- * @see https://mochajs.org/api/mocha#noHighlighting -- */ -- noHighlighting(): this; -- -- /** -- * Enable uncaught errors to propagate (in browser). -- * -- * @see https://mochajs.org/api/mocha#allowUncaught -- */ -- allowUncaught(): boolean; -- -- /** -- * Delay root suite execution. -- * -- * @see https://mochajs.org/api/mocha#delay -- */ -- delay(): boolean; -- -- /** -- * Tests marked only fail the suite -- * -- * @see https://mochajs.org/api/mocha#forbidOnly -- */ -- forbidOnly(): boolean; -- -- /** -- * Pending tests and tests marked skip fail the suite -- * -- * @see https://mochajs.org/api/mocha#forbidPending -- */ -- forbidPending(): boolean; -- -- /** -- * Run tests and invoke `fn()` when complete. -- * -- * Note that `run` relies on Node's `require` to execute -- * the test interface functions and will be subject to the -- * cache - if the files are already in the `require` cache, -- * they will effectively be skipped. Therefore, to run tests -- * multiple times or to run tests in files that are already -- * in the `require` cache, make sure to clear them from the -- * cache first in whichever manner best suits your needs. -- * -- * @see https://mochajs.org/api/mocha#run -- */ -- run(fn?: (failures: number) => void): Mocha.Runner; -- -- /** -- * Loads ESM (and CJS) test files asynchronously. -- * -- * @see https://mochajs.org/api/mocha#loadFilesAsync -- */ -- loadFilesAsync(): Promise; -- -- /** -- * Load registered files. -- * -- * @see https://mochajs.org/api/mocha#loadFiles -- */ -- protected loadFiles(fn?: () => void): void; -- -- /** -- * Unloads `files` from Node's `require` cache. -- * -- * This allows required files to be "freshly" reloaded, providing the ability -- * to reuse a Mocha instance programmatically. -- * Note: does not clear ESM module files from the cache -- */ -- unloadFiles(): this; -- -- /** -- * Toggles parallel mode. -- * -- * Must be run before calling `run`. Changes the `Runner` class to -- * use; also enables lazy file loading if not already done so. -- * -- * @see https://mochajs.org/api/mocha#parallelMode -- */ -- parallelMode(enabled?: boolean): this; -- -- /** -- * Assigns hooks to the root suite. -- * -- * @see https://mochajs.org/api/mocha#rootHooks -- */ -- rootHooks(hooks: Mocha.RootHookObject): this; --} -- --declare namespace Mocha { -- namespace utils { -- /** -- * Compute a slug from the given `str`. -- * -- * @see https://mochajs.org/api/module-utils.html#.slug -- */ -- function slug(str: string): string; -- -- /** -- * Strip the function definition from `str`, and re-indent for pre whitespace. -- * -- * @see https://mochajs.org/api/module-utils.html#.clean -- */ -- function clean(str: string): string; -- -- /** -- * Highlight the given string of `js`. -- */ -- function highlight(js: string): string; -- -- /** -- * Takes some variable and asks `Object.prototype.toString()` what it thinks it is. -- */ -- function type(value: any): string; -- -- /** -- * Stringify `value`. Different behavior depending on type of value: -- * -- * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively. -- * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes. -- * - If `value` is an *empty* object, function, or array, returns `'{}'`, `'[Function]'`, or `'[]'` respectively. -- * - If `value` has properties, call canonicalize} on it, then return result of `JSON.stringify()` -- * -- * @see https://mochajs.org/api/module-utils.html#.stringify -- */ -- function stringify(value: any): string; -- -- /** -- * Return a new Thing that has the keys in sorted order. Recursive. -- * -- * If the Thing... -- * - has already been seen, return string `'[Circular]'` -- * - is `undefined`, return string `'[undefined]'` -- * - is `null`, return value `null` -- * - is some other primitive, return the value -- * - is not a primitive or an `Array`, `Object`, or `Function`, return the value of the Thing's `toString()` method -- * - is a non-empty `Array`, `Object`, or `Function`, return the result of calling this function again. -- * - is an empty `Array`, `Object`, or `Function`, returns `'[]'`, `'{}'`, or `'[Function]'` respectively. -- * -- * @see https://mochajs.org/api/module-utils.html#.canonicalize -- */ -- function canonicalize(value: any, stack: any[], typeHint: string): any; -- -- /** -- * Lookup file names at the given `path`. -- * -- * @see https://mochajs.org/api/Mocha.utils.html#.exports.lookupFiles -- */ -- function lookupFiles(filepath: string, extensions?: string[], recursive?: boolean): string[]; -- -- /** -- * Generate an undefined error with a message warning the user. -- * -- * @see https://mochajs.org/api/module-utils.html#.undefinedError -- */ -- function undefinedError(): Error; -- -- /** -- * Generate an undefined error if `err` is not defined. -- * -- * @see https://mochajs.org/api/module-utils.html#.getError -- */ -- function getError(err: Error | undefined): Error; -- -- /** -- * When invoking this function you get a filter function that get the Error.stack as an -- * input, and return a prettify output. (i.e: strip Mocha and internal node functions from -- * stack trace). -- * -- * @see https://mochajs.org/api/module-utils.html#.stackTraceFilter -- */ -- function stackTraceFilter(): (stack: string) => string; -- } -- -- namespace interfaces { -- function bdd(suite: Suite): void; -- function tdd(suite: Suite): void; -- function qunit(suite: Suite): void; -- function exports(suite: Suite): void; -- } -- -- // #region Test interface augmentations -- -- interface HookFunction { -- /** -- * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the -- * function is used as the name of the hook. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (fn: Func): void; -- -- /** -- * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the -- * function is used as the name of the hook. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (fn: AsyncFunc): void; -- -- /** -- * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (name: string, fn?: Func): void; -- -- /** -- * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (name: string, fn?: AsyncFunc): void; -- } -- -- interface SuiteFunction { -- /** -- * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing -- * nested suites. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string, fn: (this: Suite) => void): Suite; -- -- /** -- * [qunit] Describe a "suite" with the given `title`. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string): Suite; -- -- /** -- * [bdd, tdd, qunit] Indicates this suite should be executed exclusively. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- only: ExclusiveSuiteFunction; -- -- /** -- * [bdd, tdd] Indicates this suite should not be executed. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- skip: PendingSuiteFunction; -- } -- -- interface ExclusiveSuiteFunction { -- /** -- * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing -- * nested suites. Indicates this suite should be executed exclusively. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string, fn: (this: Suite) => void): Suite; -- -- /** -- * [qunit] Describe a "suite" with the given `title`. Indicates this suite should be executed -- * exclusively. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string): Suite; -- } -- -- /** -- * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing -- * nested suites. Indicates this suite should not be executed. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @returns [bdd] `Suite` -- * @returns [tdd] `void` -- */ -- interface PendingSuiteFunction { -- (title: string, fn: (this: Suite) => void): Suite | void; -- } -- -- interface TestFunction { -- /** -- * Describe a specification or test-case with the given callback `fn` acting as a thunk. -- * The name of the function is used as the name of the test. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (fn: Func): Test; -- -- /** -- * Describe a specification or test-case with the given callback `fn` acting as a thunk. -- * The name of the function is used as the name of the test. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (fn: AsyncFunc): Test; -- -- /** -- * Describe a specification or test-case with the given `title` and callback `fn` acting -- * as a thunk. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string, fn?: Func): Test; -- -- /** -- * Describe a specification or test-case with the given `title` and callback `fn` acting -- * as a thunk. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string, fn?: AsyncFunc): Test; -- -- /** -- * Indicates this test should be executed exclusively. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- only: ExclusiveTestFunction; -- -- /** -- * Indicates this test should not be executed. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- skip: PendingTestFunction; -- -- /** -- * Number of attempts to retry. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- retries(n: number): void; -- } -- -- interface ExclusiveTestFunction { -- /** -- * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` -- * acting as a thunk. The name of the function is used as the name of the test. Indicates -- * this test should be executed exclusively. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (fn: Func): Test; -- -- /** -- * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` -- * acting as a thunk. The name of the function is used as the name of the test. Indicates -- * this test should be executed exclusively. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (fn: AsyncFunc): Test; -- -- /** -- * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and -- * callback `fn` acting as a thunk. Indicates this test should be executed exclusively. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string, fn?: Func): Test; -- -- /** -- * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and -- * callback `fn` acting as a thunk. Indicates this test should be executed exclusively. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string, fn?: AsyncFunc): Test; -- } -- -- interface PendingTestFunction { -- /** -- * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` -- * acting as a thunk. The name of the function is used as the name of the test. Indicates -- * this test should not be executed. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (fn: Func): Test; -- -- /** -- * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` -- * acting as a thunk. The name of the function is used as the name of the test. Indicates -- * this test should not be executed. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (fn: AsyncFunc): Test; -- -- /** -- * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and -- * callback `fn` acting as a thunk. Indicates this test should not be executed. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string, fn?: Func): Test; -- -- /** -- * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and -- * callback `fn` acting as a thunk. Indicates this test should not be executed. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string, fn?: AsyncFunc): Test; -- } -- -- /** -- * Execute after each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#afterEach -- */ -- let afterEach: HookFunction; -- -- /** -- * Execute after running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#after -- */ -- let after: HookFunction; -- -- /** -- * Execute before each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#beforeEach -- */ -- let beforeEach: HookFunction; -- -- /** -- * Execute before running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#before -- */ -- let before: HookFunction; -- -- /** -- * Describe a "suite" containing nested suites and tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- let describe: SuiteFunction; -- -- /** -- * Describes a test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- let it: TestFunction; -- -- /** -- * Describes a pending test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- let xit: PendingTestFunction; -- -- /** -- * Execute before each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#beforeEach -- */ -- let setup: HookFunction; -- -- /** -- * Execute before running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#before -- */ -- let suiteSetup: HookFunction; -- -- /** -- * Execute after running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#after -- */ -- let suiteTeardown: HookFunction; -- -- /** -- * Describe a "suite" containing nested suites and tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- let suite: SuiteFunction; -- -- /** -- * Execute after each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#afterEach -- */ -- let teardown: HookFunction; -- -- /** -- * Describes a test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- let test: TestFunction; -- -- /** -- * Triggers root suite execution. -- * -- * - _Only available if flag --delay is passed into Mocha._ -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#runWithSuite -- */ -- function run(): void; -- -- // #endregion Test interface augmentations -- -- namespace reporters { -- /** -- * Initialize a new `Base` reporter. -- * -- * All other reporters generally inherit from this reporter, providing stats such as test duration, -- * number of tests passed / failed, etc. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Base.html -- */ -- class Base { -- constructor(runner: Runner, options?: MochaOptions); -- -- /** -- * Test run statistics -- */ -- stats: Stats; -- -- /** -- * Test failures -- */ -- failures: Test[]; -- -- /** -- * The configured runner -- */ -- runner: Runner; -- -- /** -- * Output common epilogue used by many of the bundled reporters. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Base.html#.Base#epilogue -- */ -- epilogue(): void; -- -- done?(failures: number, fn?: (failures: number) => void): void; -- } -- -- namespace Base { -- /** -- * Enables coloring by default -- * -- * @see https://mochajs.org/api/module-base#.useColors -- */ -- let useColors: boolean; -- -- /** -- * Inline diffs instead of +/- -- * -- * @see https://mochajs.org/api/module-base#.inlineDiffs -- */ -- let inlineDiffs: boolean; -- -- /** -- * Default color map -- * -- * @see https://mochajs.org/api/module-base#.colors -- */ -- const colors: ColorMap; -- -- /** -- * Default color map -- * -- * @see https://mochajs.org/api/module-base#.colors -- */ -- interface ColorMap { -- // added by Base -- pass: number; -- fail: number; -- "bright pass": number; -- "bright fail": number; -- "bright yellow": number; -- pending: number; -- suite: number; -- "error title": number; -- "error message": number; -- "error stack": number; -- checkmark: number; -- fast: number; -- medium: number; -- slow: number; -- green: number; -- light: number; -- "diff gutter": number; -- "diff added": number; -- "diff removed": number; -- -- // added by Progress -- progress: number; -- -- // added by Landing -- plane: number; -- "plane crash": number; -- runway: number; -- -- [key: string]: number; -- } -- -- /** -- * Default symbol map -- * -- * @see https://mochajs.org/api/module-base#.symbols -- */ -- const symbols: SymbolMap; -- -- /** -- * Default symbol map -- * -- * @see https://mochajs.org/api/module-base#.symbols -- */ -- interface SymbolMap { -- ok: string; -- err: string; -- dot: string; -- comma: string; -- bang: string; -- [key: string]: string; -- } -- -- /** -- * Color `str` with the given `type` (from `colors`) -- * -- * @see https://mochajs.org/api/module-base#.color -- */ -- function color(type: string, str: string): string; -- -- /** -- * Expose terminal window size -- * -- * @see https://mochajs.org/api/module-base#.window -- */ -- const window: { -- width: number; -- }; -- -- /** -- * ANSI TTY control sequences common among reporters. -- * -- * @see https://mochajs.org/api/module-base#.cursor -- */ -- namespace cursor { -- /** -- * Hides the cursor -- */ -- function hide(): void; -- -- /** -- * Shows the cursor -- */ -- function show(): void; -- -- /** -- * Deletes the current line -- */ -- function deleteLine(): void; -- -- /** -- * Moves to the beginning of the line -- */ -- function beginningOfLine(): void; -- -- /** -- * Clears the line and moves to the beginning of the line. -- */ -- function CR(): void; -- } -- -- /** -- * Returns a diff between two strings with colored ANSI output. -- * -- * @see https://mochajs.org/api/module-base#.generateDiff -- */ -- function generateDiff(actual: string, expected: string): string; -- -- /** -- * Output the given `failures` as a list. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Base.html#.exports.list1 -- */ -- function list(failures: Test[]): void; -- } -- -- /** -- * Initialize a new `Dot` matrix test reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Dot.html -- */ -- class Dot extends Base { -- } -- -- /** -- * Initialize a new `Doc` reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Doc.html -- */ -- class Doc extends Base { -- } -- -- /** -- * Initialize a new `TAP` test reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.TAP.html -- */ -- class TAP extends Base { -- } -- -- /** -- * Initialize a new `JSON` reporter -- * -- * @see https://mochajs.org/api/Mocha.reporters.JSON.html -- */ -- class JSON extends Base { -- } -- -- /** -- * Initialize a new `HTML` reporter. -- * -- * - _This reporter cannot be used on the console._ -- * -- * @see https://mochajs.org/api/Mocha.reporters.HTML.html -- */ -- class HTML extends Base { -- /** -- * Provide suite URL. -- * -- * @see https://mochajs.org/api/Mocha.reporters.HTML.html#suiteURL -- */ -- suiteURL(suite: Suite): string; -- -- /** -- * Provide test URL. -- * -- * @see https://mochajs.org/api/Mocha.reporters.HTML.html#testURL -- */ -- testURL(test: Test): string; -- -- /** -- * Adds code toggle functionality for the provided test's list element. -- * -- * @see https://mochajs.org/api/Mocha.reporters.HTML.html#addCodeToggle -- */ -- addCodeToggle(el: HTMLLIElement, contents: string): void; -- } -- -- /** -- * Initialize a new `List` test reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.List.html -- */ -- class List extends Base { -- } -- -- /** -- * Initialize a new `Min` minimal test reporter (best used with --watch). -- * -- * @see https://mochajs.org/api/Mocha.reporters.Min.html -- */ -- class Min extends Base { -- } -- -- /** -- * Initialize a new `Spec` test reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Spec.html -- */ -- class Spec extends Base { -- } -- -- /** -- * Initialize a new `NyanCat` test reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Nyan.html -- */ -- class Nyan extends Base { -- private colorIndex; -- private numberOfLines; -- private rainbowColors; -- private scoreboardWidth; -- private tick; -- private trajectories; -- private trajectoryWidthMax; -- private draw; -- private drawScoreboard; -- private appendRainbow; -- private drawRainbow; -- private drawNyanCat; -- private face; -- private cursorUp; -- private cursorDown; -- private generateColors; -- private rainbowify; -- } -- -- /** -- * Initialize a new `XUnit` test reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.XUnit.html -- */ -- class XUnit extends Base { -- constructor(runner: Runner, options?: XUnit.MochaOptions); -- -- /** -- * Override done to close the stream (if it's a file). -- * -- * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#done -- */ -- done(failures: number, fn: (failures: number) => void): void; -- -- /** -- * Write out the given line. -- * -- * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#write -- */ -- write(line: string): void; -- -- /** -- * Output tag for the given `test.` -- * -- * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#test -- */ -- test(test: Test): void; -- } -- -- namespace XUnit { -- interface MochaOptions extends Mocha.MochaOptions { -- reporterOptions?: ReporterOptions; -- } -- -- interface ReporterOptions { -- output?: string; -- suiteName?: string; -- } -- } -- -- /** -- * Initialize a new `Markdown` test reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Markdown.html -- */ -- class Markdown extends Base { -- } -- -- /** -- * Initialize a new `Progress` bar test reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Progress.html -- */ -- class Progress extends Base { -- constructor(runner: Runner, options?: Progress.MochaOptions); -- } -- -- namespace Progress { -- interface MochaOptions extends Mocha.MochaOptions { -- reporterOptions?: ReporterOptions; -- } -- -- interface ReporterOptions { -- open?: string; -- complete?: string; -- incomplete?: string; -- close?: string; -- verbose?: boolean; -- } -- } -- -- /** -- * Initialize a new `Landing` reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Landing.html -- */ -- class Landing extends Base { -- } -- -- /** -- * Initialize a new `JSONStream` test reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.JSONStream.html -- */ -- class JSONStream extends Base { -- } -- -- // value-only aliases -- const base: typeof Base; -- const dot: typeof Dot; -- const doc: typeof Doc; -- const tap: typeof TAP; -- const json: typeof JSON; -- const html: typeof HTML; -- const list: typeof List; -- const spec: typeof Spec; -- const nyan: typeof Nyan; -- const xunit: typeof XUnit; -- const markdown: typeof Markdown; -- const progress: typeof Progress; -- const landing: typeof Landing; -- // NOTE: not possible to type this correctly: -- // const "json-stream": typeof JSONStream; -- } -- -- /** -- * Initialize a new `Runnable` with the given `title` and callback `fn`. -- * -- * @see https://mochajs.org/api/Runnable.html -- */ -- class Runnable { -- private _slow; -- private _retries; -- private _currentRetry; -- private _timeout; -- private _timeoutError; -- -- constructor(title: string, fn?: Func | AsyncFunc); -- -- title: string; -- fn: Func | AsyncFunc | undefined; -- body: string; -- async: boolean; -- sync: boolean; -- timedOut: boolean; -- pending: boolean; -- duration?: number; -- parent?: Suite; -- state?: "failed" | "passed"; -- timer?: any; -- ctx?: Context; -- callback?: Done; -- allowUncaught?: boolean; -- file?: string; -- -- /** -- * Get test timeout. -- * -- * @see https://mochajs.org/api/Runnable.html#timeout -- */ -- timeout(): number; -- -- /** -- * Set test timeout. -- * -- * @see https://mochajs.org/api/Runnable.html#timeout -- */ -- timeout(ms: string | number): this; -- -- /** -- * Get test slowness threshold. -- * -- * @see https://mochajs.org/api/Runnable.html#slow -- */ -- slow(): number; -- -- /** -- * Set test slowness threshold. -- * -- * @see https://mochajs.org/api/Runnable.html#slow -- */ -- slow(ms: string | number): this; -- -- /** -- * Halt and mark as pending. -- */ -- skip(): never; -- -- /** -- * Check if this runnable or its parent suite is marked as pending. -- * -- * @see https://mochajs.org/api/Runnable.html#isPending -- */ -- isPending(): boolean; -- -- /** -- * Return `true` if this Runnable has failed. -- */ -- isFailed(): boolean; -- -- /** -- * Return `true` if this Runnable has passed. -- */ -- isPassed(): boolean; -- -- /** -- * Set or get number of retries. -- * -- * @see https://mochajs.org/api/Runnable.html#retries -- */ -- retries(): number; -- -- /** -- * Set or get number of retries. -- * -- * @see https://mochajs.org/api/Runnable.html#retries -- */ -- retries(n: number): void; -- -- /** -- * Set or get current retry -- * -- * @see https://mochajs.org/api/Runnable.html#currentRetry -- */ -- protected currentRetry(): number; -- -- /** -- * Set or get current retry -- * -- * @see https://mochajs.org/api/Runnable.html#currentRetry -- */ -- protected currentRetry(n: number): void; -- -- /** -- * Return the full title generated by recursively concatenating the parent's full title. -- */ -- fullTitle(): string; -- -- /** -- * Return the title path generated by concatenating the parent's title path with the title. -- */ -- titlePath(): string[]; -- -- /** -- * Clear the timeout. -- * -- * @see https://mochajs.org/api/Runnable.html#clearTimeout -- */ -- clearTimeout(): void; -- -- /** -- * Inspect the runnable void of private properties. -- * -- * @see https://mochajs.org/api/Runnable.html#inspect -- */ -- inspect(): string; -- -- /** -- * Reset the timeout. -- * -- * @see https://mochajs.org/api/Runnable.html#resetTimeout -- */ -- resetTimeout(): void; -- -- /** -- * Get a list of whitelisted globals for this test run. -- * -- * @see https://mochajs.org/api/Runnable.html#globals -- */ -- globals(): string[]; -- -- /** -- * Set a list of whitelisted globals for this test run. -- * -- * @see https://mochajs.org/api/Runnable.html#globals -- */ -- globals(globals: ReadonlyArray): void; -- -- /** -- * Run the test and invoke `fn(err)`. -- * -- * @see https://mochajs.org/api/Runnable.html#run -- */ -- run(fn: Done): void; -- } -- -- // #region Runnable "error" event -- interface Runnable extends NodeJS.EventEmitter { -- on(event: "error", listener: (error: any) => void): this; -- once(event: "error", listener: (error: any) => void): this; -- addListener(event: "error", listener: (error: any) => void): this; -- removeListener(event: "error", listener: (error: any) => void): this; -- prependListener(event: "error", listener: (error: any) => void): this; -- prependOnceListener(event: "error", listener: (error: any) => void): this; -- emit(name: "error", error: any): boolean; -- } -- // #endregion Runnable "error" event -- // #region Runnable untyped events -- interface Runnable extends NodeJS.EventEmitter { -- on(event: string, listener: (...args: any[]) => void): this; -- once(event: string, listener: (...args: any[]) => void): this; -- addListener(event: string, listener: (...args: any[]) => void): this; -- removeListener(event: string, listener: (...args: any[]) => void): this; -- prependListener(event: string, listener: (...args: any[]) => void): this; -- prependOnceListener(event: string, listener: (...args: any[]) => void): this; -- emit(name: string, ...args: any[]): boolean; -- } -- // #endregion Runnable untyped events -- -- /** -- * Test context -- * -- * @see https://mochajs.org/api/module-Context.html#~Context -- */ -- class Context { -- private _runnable; -- -- test?: Runnable; -- currentTest?: Test; -- -- /** -- * Get the context `Runnable`. -- */ -- runnable(): Runnable; -- -- /** -- * Set the context `Runnable`. -- */ -- runnable(runnable: Runnable): this; -- -- /** -- * Get test timeout. -- */ -- timeout(): number; -- -- /** -- * Set test timeout. -- */ -- timeout(ms: string | number): this; -- -- /** -- * Get test slowness threshold. -- */ -- slow(): number; -- -- /** -- * Set test slowness threshold. -- */ -- slow(ms: string | number): this; -- -- /** -- * Mark a test as skipped. -- */ -- skip(): never; -- -- /** -- * Get the number of allowed retries on failed tests. -- */ -- retries(): number; -- -- /** -- * Set the number of allowed retries on failed tests. -- */ -- retries(n: number): this; -- -- [key: string]: any; -- } -- -- interface RunnerConstants { -- readonly EVENT_HOOK_BEGIN: 'hook'; -- readonly EVENT_HOOK_END: 'hook end'; -- readonly EVENT_RUN_BEGIN: 'start'; -- readonly EVENT_DELAY_BEGIN: 'waiting'; -- readonly EVENT_DELAY_END: 'ready'; -- readonly EVENT_RUN_END: 'end'; -- readonly EVENT_SUITE_BEGIN: 'suite'; -- readonly EVENT_SUITE_END: 'suite end'; -- readonly EVENT_TEST_BEGIN: 'test'; -- readonly EVENT_TEST_END: 'test end'; -- readonly EVENT_TEST_FAIL: 'fail'; -- readonly EVENT_TEST_PASS: 'pass'; -- readonly EVENT_TEST_PENDING: 'pending'; -- readonly EVENT_TEST_RETRY: 'retry'; -- } -- -- /** -- * Initialize a `Runner` for the given `suite`. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html -- */ -- class Runner { -- private _globals; -- private _abort; -- private _delay; -- private _defaultGrep; -- private next; -- private hookErr; -- private prevGlobalsLength; -- private nextSuite; -- -- static readonly constants: RunnerConstants; -- -- constructor(suite: Suite, delay: boolean); -- -- suite: Suite; -- started: boolean; -- total: number; -- failures: number; -- asyncOnly?: boolean; -- allowUncaught?: boolean; -- fullStackTrace?: boolean; -- forbidOnly?: boolean; -- forbidPending?: boolean; -- checkLeaks?: boolean; -- test?: Test; -- currentRunnable?: Runnable; -- stats?: Stats; // added by reporters -- -- /** -- * Run tests with full titles matching `re`. Updates runner.total -- * with number of tests matched. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grep -- */ -- grep(re: RegExp, invert: boolean): this; -- -- /** -- * Returns the number of tests matching the grep search for the -- * given suite. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grepTotal -- */ -- grepTotal(suite: Suite): number; -- -- /** -- * Gets the allowed globals. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals -- */ -- globals(): string[]; -- -- /** -- * Allow the given `arr` of globals. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals -- */ -- globals(arr: ReadonlyArray): this; -- -- /** -- * Run the root suite and invoke `fn(failures)` on completion. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#run -- */ -- run(fn?: (failures: number) => void): this; -- -- /** -- * Cleanly abort execution. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#abort -- */ -- abort(): this; -- -- /** -- * Handle uncaught exceptions. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#uncaught -- */ -- uncaught(err: any): void; -- -- /** -- * Wrapper for setImmediate, process.nextTick, or browser polyfill. -- */ -- protected static immediately(callback: Function): void; -- -- /** -- * Return a list of global properties. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#globalProps -- */ -- protected globalProps(): string[]; -- -- /** -- * Check for global variable leaks. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#checkGlobals -- */ -- protected checkGlobals(test: Test): void; -- -- /** -- * Fail the given `test`. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#fail -- */ -- protected fail(test: Test, err: any): void; -- -- /** -- * Fail the given `hook` with `err`. -- * -- * Hook failures work in the following pattern: -- * - If bail, then exit -- * - Failed `before` hook skips all tests in a suite and subsuites, -- * but jumps to corresponding `after` hook -- * - Failed `before each` hook skips remaining tests in a -- * suite and jumps to corresponding `after each` hook, -- * which is run only once -- * - Failed `after` hook does not alter -- * execution order -- * - Failed `after each` hook skips remaining tests in a -- * suite and subsuites, but executes other `after each` -- * hooks -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#failHook -- */ -- protected failHook(hook: Hook, err: any): void; -- -- /** -- * Run hook `name` callbacks and then invoke `fn()`. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#hook -- */ -- protected hook(name: string, fn: () => void): void; -- -- /** -- * Run hook `name` for the given array of `suites` -- * in order, and callback `fn(err, errSuite)`. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#hooks -- */ -- protected hooks(name: string, suites: Suite[], fn: (err?: any, errSuite?: Suite) => void): void; -- -- /** -- * Run hooks from the top level down. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#hookUp -- */ -- protected hookUp(name: string, fn: (err?: any, errSuite?: Suite) => void): void; -- -- /** -- * Run hooks from the bottom up. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#hookDown -- */ -- protected hookDown(name: string, fn: (err?: any, errSuite?: Suite) => void): void; -- -- /** -- * Return an array of parent Suites from closest to furthest. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#parents -- */ -- protected parents(): Suite[]; -- -- /** -- * Run the current test and callback `fn(err)`. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#runTest -- */ -- protected runTest(fn: Done): any; -- -- /** -- * Run tests in the given `suite` and invoke the callback `fn()` when complete. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#runTests -- */ -- protected runTests(suite: Suite, fn: (errSuite?: Suite) => void): void; -- -- /** -- * Run the given `suite` and invoke the callback `fn()` when complete. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#runSuite -- */ -- protected runSuite(suite: Suite, fn: (errSuite?: Suite) => void): void; -- } -- -- // #region Runner "waiting" event -- interface Runner { -- on(event: "waiting", listener: (rootSuite: Suite) => void): this; -- once(event: "waiting", listener: (rootSuite: Suite) => void): this; -- addListener(event: "waiting", listener: (rootSuite: Suite) => void): this; -- removeListener(event: "waiting", listener: (rootSuite: Suite) => void): this; -- prependListener(event: "waiting", listener: (rootSuite: Suite) => void): this; -- prependOnceListener(event: "waiting", listener: (rootSuite: Suite) => void): this; -- emit(name: "waiting", rootSuite: Suite): boolean; -- } -- // #endregion Runner "waiting" event -- // #region Runner "start" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "start", listener: () => void): this; -- once(event: "start", listener: () => void): this; -- addListener(event: "start", listener: () => void): this; -- removeListener(event: "start", listener: () => void): this; -- prependListener(event: "start", listener: () => void): this; -- prependOnceListener(event: "start", listener: () => void): this; -- emit(name: "start"): boolean; -- } -- // #endregion Runner "start" event -- // #region Runner "end" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "end", listener: () => void): this; -- once(event: "end", listener: () => void): this; -- addListener(event: "end", listener: () => void): this; -- removeListener(event: "end", listener: () => void): this; -- prependListener(event: "end", listener: () => void): this; -- prependOnceListener(event: "end", listener: () => void): this; -- emit(name: "end"): boolean; -- } -- // #endregion Runner "end" event -- // #region Runner "suite" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "suite", listener: (suite: Suite) => void): this; -- once(event: "suite", listener: (suite: Suite) => void): this; -- addListener(event: "suite", listener: (suite: Suite) => void): this; -- removeListener(event: "suite", listener: (suite: Suite) => void): this; -- prependListener(event: "suite", listener: (suite: Suite) => void): this; -- prependOnceListener(event: "suite", listener: (suite: Suite) => void): this; -- emit(name: "suite", suite: Suite): boolean; -- } -- // #endregion Runner "suite" event -- // #region Runner "suite end" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "suite end", listener: (suite: Suite) => void): this; -- once(event: "suite end", listener: (suite: Suite) => void): this; -- addListener(event: "suite end", listener: (suite: Suite) => void): this; -- removeListener(event: "suite end", listener: (suite: Suite) => void): this; -- prependListener(event: "suite end", listener: (suite: Suite) => void): this; -- prependOnceListener(event: "suite end", listener: (suite: Suite) => void): this; -- emit(name: "suite end", suite: Suite): boolean; -- } -- // #endregion Runner "suite end" event -- // #region Runner "test" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "test", listener: (test: Test) => void): this; -- once(event: "test", listener: (test: Test) => void): this; -- addListener(event: "test", listener: (test: Test) => void): this; -- removeListener(event: "test", listener: (test: Test) => void): this; -- prependListener(event: "test", listener: (test: Test) => void): this; -- prependOnceListener(event: "test", listener: (test: Test) => void): this; -- emit(name: "test", test: Test): boolean; -- } -- // #endregion Runner "test" event -- // #region Runner "test end" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "test end", listener: (test: Test) => void): this; -- once(event: "test end", listener: (test: Test) => void): this; -- addListener(event: "test end", listener: (test: Test) => void): this; -- removeListener(event: "test end", listener: (test: Test) => void): this; -- prependListener(event: "test end", listener: (test: Test) => void): this; -- prependOnceListener(event: "test end", listener: (test: Test) => void): this; -- emit(name: "test end", test: Test): boolean; -- } -- // #endregion Runner "test end" event -- // #region Runner "hook" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "hook", listener: (hook: Hook) => void): this; -- once(event: "hook", listener: (hook: Hook) => void): this; -- addListener(event: "hook", listener: (hook: Hook) => void): this; -- removeListener(event: "hook", listener: (hook: Hook) => void): this; -- prependListener(event: "hook", listener: (hook: Hook) => void): this; -- prependOnceListener(event: "hook", listener: (hook: Hook) => void): this; -- emit(name: "hook", hook: Hook): boolean; -- } -- // #endregion Runner "hook" event -- // #region Runner "hook end" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "hook end", listener: (hook: Hook) => void): this; -- once(event: "hook end", listener: (hook: Hook) => void): this; -- addListener(event: "hook end", listener: (hook: Hook) => void): this; -- removeListener(event: "hook end", listener: (hook: Hook) => void): this; -- prependListener(event: "hook end", listener: (hook: Hook) => void): this; -- prependOnceListener(event: "hook end", listener: (hook: Hook) => void): this; -- emit(name: "hook end", hook: Hook): boolean; -- } -- // #endregion Runner "hook end" event -- // #region Runner "pass" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "pass", listener: (test: Test) => void): this; -- once(event: "pass", listener: (test: Test) => void): this; -- addListener(event: "pass", listener: (test: Test) => void): this; -- removeListener(event: "pass", listener: (test: Test) => void): this; -- prependListener(event: "pass", listener: (test: Test) => void): this; -- prependOnceListener(event: "pass", listener: (test: Test) => void): this; -- emit(name: "pass", test: Test): boolean; -- } -- // #endregion Runner "pass" event -- // #region Runner "fail" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "fail", listener: (test: Test, err: any) => void): this; -- once(event: "fail", listener: (test: Test, err: any) => void): this; -- addListener(event: "fail", listener: (test: Test, err: any) => void): this; -- removeListener(event: "fail", listener: (test: Test, err: any) => void): this; -- prependListener(event: "fail", listener: (test: Test, err: any) => void): this; -- prependOnceListener(event: "fail", listener: (test: Test, err: any) => void): this; -- emit(name: "fail", test: Test, err: any): boolean; -- } -- // #endregion Runner "fail" event -- // #region Runner "pending" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "pending", listener: (test: Test) => void): this; -- once(event: "pending", listener: (test: Test) => void): this; -- addListener(event: "pending", listener: (test: Test) => void): this; -- removeListener(event: "pending", listener: (test: Test) => void): this; -- prependListener(event: "pending", listener: (test: Test) => void): this; -- prependOnceListener(event: "pending", listener: (test: Test) => void): this; -- emit(name: "pending", test: Test): boolean; -- } -- // #endregion Runner "pending" event -- // #region Runner untyped events -- interface Runner extends NodeJS.EventEmitter { -- on(event: string, listener: (...args: any[]) => void): this; -- once(event: string, listener: (...args: any[]) => void): this; -- addListener(event: string, listener: (...args: any[]) => void): this; -- removeListener(event: string, listener: (...args: any[]) => void): this; -- prependListener(event: string, listener: (...args: any[]) => void): this; -- prependOnceListener(event: string, listener: (...args: any[]) => void): this; -- emit(name: string, ...args: any[]): boolean; -- } -- // #endregion Runner untyped events -- -- interface SuiteConstants { -- readonly EVENT_FILE_POST_REQUIRE: 'post-require'; -- readonly EVENT_FILE_PRE_REQUIRE: 'pre-require'; -- readonly EVENT_FILE_REQUIRE: 'require'; -- readonly EVENT_ROOT_SUITE_RUN: 'run'; -- -- readonly HOOK_TYPE_AFTER_ALL: 'afterAll'; -- readonly HOOK_TYPE_AFTER_EACH: 'afterEach'; -- readonly HOOK_TYPE_BEFORE_ALL: 'beforeAll'; -- readonly HOOK_TYPE_BEFORE_EACH: 'beforeEach'; -- -- readonly EVENT_SUITE_ADD_HOOK_AFTER_ALL: 'afterAll'; -- readonly EVENT_SUITE_ADD_HOOK_AFTER_EACH: 'afterEach'; -- readonly EVENT_SUITE_ADD_HOOK_BEFORE_ALL: 'beforeAll'; -- readonly EVENT_SUITE_ADD_HOOK_BEFORE_EACH: 'beforeEach'; -- readonly EVENT_SUITE_ADD_SUITE: 'suite'; -- readonly EVENT_SUITE_ADD_TEST: 'test'; -- } -- -- /** -- * Initialize a new `Suite` with the given `title` and `ctx`. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html -- */ -- class Suite { -- private _beforeEach; -- private _beforeAll; -- private _afterEach; -- private _afterAll; -- private _timeout; -- private _slow; -- private _bail; -- private _retries; -- private _onlyTests; -- private _onlySuites; -- -- static readonly constants: SuiteConstants; -- -- constructor(title: string, parentContext?: Context); -- -- ctx: Context; -- suites: Suite[]; -- tests: Test[]; -- pending: boolean; -- file?: string; -- root: boolean; -- delayed: boolean; -- parent: Suite | undefined; -- title: string; -- -- /** -- * Create a new `Suite` with the given `title` and parent `Suite`. When a suite -- * with the same title is already present, that suite is returned to provide -- * nicer reporter and more flexible meta-testing. -- * -- * @see https://mochajs.org/api/mocha#.exports.create -- */ -- static create(parent: Suite, title: string): Suite; -- -- /** -- * Return a clone of this `Suite`. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#clone -- */ -- clone(): Suite; -- -- /** -- * Get timeout `ms`. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#timeout -- */ -- timeout(): number; -- -- /** -- * Set timeout `ms` or short-hand such as "2s". -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#timeout -- */ -- timeout(ms: string | number): this; -- -- /** -- * Get number of times to retry a failed test. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#retries -- */ -- retries(): number; -- -- /** -- * Set number of times to retry a failed test. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#retries -- */ -- retries(n: string | number): this; -- -- /** -- * Get slow `ms`. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#slow -- */ -- slow(): number; -- -- /** -- * Set slow `ms` or short-hand such as "2s". -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#slow -- */ -- slow(ms: string | number): this; -- -- /** -- * Get whether to bail after first error. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#bail -- */ -- bail(): boolean; -- -- /** -- * Set whether to bail after first error. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#bail -- */ -- bail(bail: boolean): this; -- -- /** -- * Check if this suite or its parent suite is marked as pending. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#isPending -- */ -- isPending(): boolean; -- -- /** -- * Run `fn(test[, done])` before running tests. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll -- */ -- beforeAll(fn?: Func): this; -- -- /** -- * Run `fn(test[, done])` before running tests. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll -- */ -- beforeAll(fn?: AsyncFunc): this; -- -- /** -- * Run `fn(test[, done])` before running tests. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll -- */ -- beforeAll(title: string, fn?: Func): this; -- -- /** -- * Run `fn(test[, done])` before running tests. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll -- */ -- beforeAll(title: string, fn?: AsyncFunc): this; -- -- /** -- * Run `fn(test[, done])` after running tests. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#afterAll -- */ -- afterAll(fn?: Func): this; -- -- /** -- * Run `fn(test[, done])` after running tests. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#afterAll -- */ -- afterAll(fn?: AsyncFunc): this; -- -- /** -- * Run `fn(test[, done])` after running tests. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#afterAll -- */ -- afterAll(title: string, fn?: Func): this; -- -- /** -- * Run `fn(test[, done])` after running tests. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#afterAll -- */ -- afterAll(title: string, fn?: AsyncFunc): this; -- -- /** -- * Run `fn(test[, done])` before each test case. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach -- */ -- beforeEach(fn?: Func): this; -- -- /** -- * Run `fn(test[, done])` before each test case. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach -- */ -- beforeEach(fn?: AsyncFunc): this; -- -- /** -- * Run `fn(test[, done])` before each test case. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach -- */ -- beforeEach(title: string, fn?: Func): this; -- -- /** -- * Run `fn(test[, done])` before each test case. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach -- */ -- beforeEach(title: string, fn?: AsyncFunc): this; -- -- /** -- * Run `fn(test[, done])` after each test case. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#afterEach -- */ -- afterEach(fn?: Func): this; -- -- /** -- * Run `fn(test[, done])` after each test case. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#afterEach -- */ -- afterEach(fn?: AsyncFunc): this; -- -- /** -- * Run `fn(test[, done])` after each test case. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#afterEach -- */ -- afterEach(title: string, fn?: Func): this; -- -- /** -- * Run `fn(test[, done])` after each test case. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#afterEach -- */ -- afterEach(title: string, fn?: AsyncFunc): this; -- -- /** -- * Add a test `suite`. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#addSuite -- */ -- addSuite(suite: Suite): this; -- -- /** -- * Add a `test` to this suite. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#addTest -- */ -- addTest(test: Test): this; -- -- /** -- * Return the full title generated by recursively concatenating the parent's -- * full title. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#fullTitle -- */ -- fullTitle(): string; -- -- /** -- * Return the title path generated by recursively concatenating the parent's -- * title path. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#titlePath -- */ -- titlePath(): string[]; -- -- /** -- * Return the total number of tests. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#total -- */ -- total(): number; -- -- /** -- * Iterates through each suite recursively to find all tests. Applies a -- * function in the format `fn(test)`. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#eachTest -- */ -- eachTest(fn: (test: Test) => void): this; -- -- /** -- * This will run the root suite if we happen to be running in delayed mode. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#run -- */ -- run(): void; -- -- /** -- * Generic hook-creator. -- */ -- protected _createHook(title: string, fn?: Func | AsyncFunc): Hook; -- } -- -- // #region Suite "beforeAll" event -- interface Suite extends NodeJS.EventEmitter { -- on(event: "beforeAll", listener: (hook: Hook) => void): this; -- once(event: "beforeAll", listener: (hook: Hook) => void): this; -- addListener(event: "beforeAll", listener: (hook: Hook) => void): this; -- removeListener(event: "beforeAll", listener: (hook: Hook) => void): this; -- prependListener(event: "beforeAll", listener: (hook: Hook) => void): this; -- prependOnceListener(event: "beforeAll", listener: (hook: Hook) => void): this; -- emit(name: "beforeAll", hook: Hook): boolean; -- } -- // #endregion Suite "beforeAll" event -- // #region Suite "afterAll" event -- interface Suite extends NodeJS.EventEmitter { -- on(event: "afterAll", listener: (hook: Hook) => void): this; -- once(event: "afterAll", listener: (hook: Hook) => void): this; -- addListener(event: "afterAll", listener: (hook: Hook) => void): this; -- removeListener(event: "afterAll", listener: (hook: Hook) => void): this; -- prependListener(event: "afterAll", listener: (hook: Hook) => void): this; -- prependOnceListener(event: "afterAll", listener: (hook: Hook) => void): this; -- emit(name: "afterAll", hook: Hook): boolean; -- } -- // #endregion Suite "afterAll" event -- // #region Suite "beforeEach" event -- interface Suite extends NodeJS.EventEmitter { -- on(event: "beforeEach", listener: (hook: Hook) => void): this; -- once(event: "beforeEach", listener: (hook: Hook) => void): this; -- addListener(event: "beforeEach", listener: (hook: Hook) => void): this; -- removeListener(event: "beforeEach", listener: (hook: Hook) => void): this; -- prependListener(event: "beforeEach", listener: (hook: Hook) => void): this; -- prependOnceListener(event: "beforeEach", listener: (hook: Hook) => void): this; -- emit(name: "beforeEach", hook: Hook): boolean; -- } -- // #endregion Suite "beforeEach" event -- // #region Suite "afterEach" event -- interface Suite extends NodeJS.EventEmitter { -- on(event: "afterEach", listener: (hook: Hook) => void): this; -- once(event: "afterEach", listener: (hook: Hook) => void): this; -- addListener(event: "afterEach", listener: (hook: Hook) => void): this; -- removeListener(event: "afterEach", listener: (hook: Hook) => void): this; -- prependListener(event: "afterEach", listener: (hook: Hook) => void): this; -- prependOnceListener(event: "afterEach", listener: (hook: Hook) => void): this; -- emit(name: "afterEach", hook: Hook): boolean; -- } -- // #endregion Suite "afterEach" event -- // #region Suite "suite" event -- interface Suite extends NodeJS.EventEmitter { -- on(event: "suite", listener: (suite: Suite) => void): this; -- once(event: "suite", listener: (suite: Suite) => void): this; -- addListener(event: "suite", listener: (suite: Suite) => void): this; -- removeListener(event: "suite", listener: (suite: Suite) => void): this; -- prependListener(event: "suite", listener: (suite: Suite) => void): this; -- prependOnceListener(event: "suite", listener: (suite: Suite) => void): this; -- emit(name: "suite", suite: Suite): boolean; -- } -- // #endregion Suite "suite" event -- // #region Suite "test" event -- interface Suite { -- on(event: "test", listener: (test: Test) => void): this; -- once(event: "test", listener: (test: Test) => void): this; -- addListener(event: "test", listener: (test: Test) => void): this; -- removeListener(event: "test", listener: (test: Test) => void): this; -- prependListener(event: "test", listener: (test: Test) => void): this; -- prependOnceListener(event: "test", listener: (test: Test) => void): this; -- emit(name: "test", test: Test): boolean; -- } -- // #endregion Suite "test" event -- // #region Suite "run" event -- interface Suite extends NodeJS.EventEmitter { -- on(event: "run", listener: () => void): this; -- once(event: "run", listener: () => void): this; -- addListener(event: "run", listener: () => void): this; -- removeListener(event: "run", listener: () => void): this; -- prependListener(event: "run", listener: () => void): this; -- prependOnceListener(event: "run", listener: () => void): this; -- emit(name: "run"): boolean; -- } -- // #endregion Suite "run" event -- // #region Suite "pre-require" event -- interface Suite extends NodeJS.EventEmitter { -- on(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- once(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- addListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- removeListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- prependListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- prependOnceListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- emit(name: "pre-require", context: MochaGlobals, file: string, mocha: Mocha): boolean; -- } -- // #endregion Suite "pre-require" event -- // #region Suite "require" event -- interface Suite extends NodeJS.EventEmitter { -- on(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -- once(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -- addListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -- removeListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -- prependListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -- prependOnceListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -- emit(name: "require", module: any, file: string, mocha: Mocha): boolean; -- } -- // #endregion Suite "require" event -- // #region Suite "post-require" event -- interface Suite extends NodeJS.EventEmitter { -- on(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- once(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- addListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- removeListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- prependListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- prependOnceListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- emit(name: "post-require", context: MochaGlobals, file: string, mocha: Mocha): boolean; -- } -- // #endregion Suite "post-require" event -- // #region Suite untyped events -- interface Suite extends NodeJS.EventEmitter { -- on(event: string, listener: (...args: any[]) => void): this; -- once(event: string, listener: (...args: any[]) => void): this; -- addListener(event: string, listener: (...args: any[]) => void): this; -- removeListener(event: string, listener: (...args: any[]) => void): this; -- prependListener(event: string, listener: (...args: any[]) => void): this; -- prependOnceListener(event: string, listener: (...args: any[]) => void): this; -- emit(name: string, ...args: any[]): boolean; -- } -- // #endregion Runner untyped events -- -- /** -- * Initialize a new `Hook` with the given `title` and callback `fn` -- * -- * @see https://mochajs.org/api/Hook.html -- */ -- class Hook extends Runnable { -- private _error; -- -- type: "hook"; -- originalTitle?: string; // added by Runner -- -- /** -- * Get the test `err`. -- * -- * @see https://mochajs.org/api/Hook.html#error -- */ -- error(): any; -- -- /** -- * Set the test `err`. -- * -- * @see https://mochajs.org/api/Hook.html#error -- */ -- error(err: any): void; -- } -- -- /** -- * An alternative way to define root hooks that works with parallel runs. -- * -- * Root hooks work with any interface, but the property names do not change. -- * In other words, if you are using the tdd interface, suiteSetup maps to beforeAll, and setup maps to beforeEach. -- * -- * As with other hooks, `this` refers to to the current context object. -- * -- * @see https://mochajs.org/#root-hook-plugins -- */ -- interface RootHookObject { -- /** -- * In serial mode, run after all tests end, once only. -- * In parallel mode, run after all tests end, for each file. -- */ -- afterAll?: Func | AsyncFunc | Func[] | AsyncFunc[]; -- /** -- * In serial mode (Mocha's default), before all tests begin, once only. -- * In parallel mode, run before all tests begin, for each file. -- */ -- beforeAll?: Func | AsyncFunc | Func[] | AsyncFunc[]; -- /** -- * In both modes, run after every test. -- */ -- afterEach?: Func | AsyncFunc | Func[] | AsyncFunc[]; -- /** -- * In both modes, run before each test. -- */ -- beforeEach?: Func | AsyncFunc | Func[] | AsyncFunc[]; -- } -- -- /** -- * Initialize a new `Test` with the given `title` and callback `fn`. -- * -- * @see https://mochajs.org/api/Test.html -- */ -- class Test extends Runnable { -- type: "test"; -- speed?: "slow" | "medium" | "fast"; // added by reporters -- err?: Error; // added by reporters -- clone(): Test; -- } -- -- /** -- * Test statistics -- */ -- interface Stats { -- suites: number; -- tests: number; -- passes: number; -- pending: number; -- failures: number; -- start?: Date; -- end?: Date; -- duration?: number; -- } -- -- type TestInterface = (suite: Suite) => void; -- -- interface ReporterConstructor { -- new (runner: Runner, options: MochaOptions): reporters.Base; -- } -- -- type Done = (err?: any) => void; -- -- /** -- * Callback function used for tests and hooks. -- */ -- type Func = (this: Context, done: Done) => void; -- -- /** -- * Async callback function used for tests and hooks. -- */ -- type AsyncFunc = (this: Context) => PromiseLike; -- -- /** -- * Options to pass to Mocha. -- */ -- interface MochaOptions { -- /** Test interfaces ("bdd", "tdd", "exports", etc.). */ -- ui?: Interface; -- -- /** -- * Reporter constructor, built-in reporter name, or reporter module path. Defaults to -- * `"spec"`. -- */ -- reporter?: string | ReporterConstructor; -- -- /** Options to pass to the reporter. */ -- reporterOptions?: any; -- -- /** Array of accepted globals. */ -- globals?: string[]; -- -- /** timeout in milliseconds or time string like '1s'. */ -- timeout?: number | string; -- -- /** number of times to retry failed tests. */ -- retries?: number; -- -- /** bail on the first test failure. */ -- bail?: boolean; -- -- /** milliseconds to wait before considering a test slow. */ -- slow?: number; -- -- /** check for global variable leaks. */ -- checkLeaks?: boolean; -- -- /** display the full stack trace on failure. */ -- fullStackTrace?: boolean; -- -- /** string or regexp to filter tests with. */ -- grep?: string | RegExp; -- -- /** Enable growl support. */ -- growl?: boolean; -- -- /** Color TTY output from reporter */ -- color?: boolean; -- -- /** Use inline diffs rather than +/-. */ -- inlineDiffs?: boolean; -- -- /** Do not show diffs at all. */ -- hideDiff?: boolean; -- -- /** Run job in parallel */ -- parallel?: boolean; -- -- /** Max number of worker processes for parallel runs */ -- jobs?: number; -- -- /** Assigns hooks to the root suite */ -- rootHooks?: RootHookObject; -- -- asyncOnly?: boolean; -- delay?: boolean; -- forbidOnly?: boolean; -- forbidPending?: boolean; -- noHighlighting?: boolean; -- allowUncaught?: boolean; -- fullTrace?: boolean; -- } -- -- interface MochaInstanceOptions extends MochaOptions { -- files?: string[]; -- } -- -- /** -- * Variables added to the global scope by Mocha when run in the CLI. -- */ -- interface MochaGlobals { -- /** -- * Execute before running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#before -- */ -- before: HookFunction; -- -- /** -- * Execute after running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#after -- */ -- after: HookFunction; -- -- /** -- * Execute before each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#beforeEach -- */ -- beforeEach: HookFunction; -- -- /** -- * Execute after each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#afterEach -- */ -- afterEach: HookFunction; -- -- /** -- * Describe a "suite" containing nested suites and tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- describe: SuiteFunction; -- -- /** -- * Describe a "suite" containing nested suites and tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- context: SuiteFunction; -- -- /** -- * Pending suite. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- xdescribe: PendingSuiteFunction; -- -- /** -- * Pending suite. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- xcontext: PendingSuiteFunction; -- -- /** -- * Describes a test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- it: TestFunction; -- -- /** -- * Describes a test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- specify: TestFunction; -- -- /** -- * Describes a pending test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- xit: PendingTestFunction; -- -- /** -- * Describes a pending test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- xspecify: PendingTestFunction; -- -- /** -- * Execute before running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#before -- */ -- suiteSetup: HookFunction; -- -- /** -- * Execute after running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#after -- */ -- suiteTeardown: HookFunction; -- -- /** -- * Execute before each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#beforeEach -- */ -- setup: HookFunction; -- -- /** -- * Execute after each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#afterEach -- */ -- teardown: HookFunction; -- -- /** -- * Describe a "suite" containing nested suites and tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- suite: SuiteFunction; -- -- /** -- * Describes a test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- test: TestFunction; -- -- run: typeof run; -- } -- -- /** -- * Third-party declarations that want to add new entries to the `Reporter` union can -- * contribute names here. -- */ -- interface ReporterContributions { -- Base: never; -- base: never; -- Dot: never; -- dot: never; -- TAP: never; -- tap: never; -- JSON: never; -- json: never; -- HTML: never; -- html: never; -- List: never; -- list: never; -- Min: never; -- min: never; -- Spec: never; -- spec: never; -- Nyan: never; -- nyan: never; -- XUnit: never; -- xunit: never; -- Markdown: never; -- markdown: never; -- Progress: never; -- progress: never; -- Landing: never; -- landing: never; -- JSONStream: never; -- "json-stream": never; -- } -- -- type Reporter = keyof ReporterContributions; -- -- /** -- * Third-party declarations that want to add new entries to the `Interface` union can -- * contribute names here. -- */ -- interface InterfaceContributions { -- bdd: never; -- tdd: never; -- qunit: never; -- exports: never; -- } -- -- type Interface = keyof InterfaceContributions; --} -- --// #region Test interface augmentations -- --/** -- * Triggers root suite execution. -- * -- * - _Only available if flag --delay is passed into Mocha._ -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#runWithSuite -- */ --declare function run(): void; -- --/** -- * Execute before running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#before -- */ --declare var before: Mocha.HookFunction; -- --/** -- * Execute before running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#before -- */ --declare var suiteSetup: Mocha.HookFunction; -- --/** -- * Execute after running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#after -- */ --declare var after: Mocha.HookFunction; -- --/** -- * Execute after running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#after -- */ --declare var suiteTeardown: Mocha.HookFunction; -- --/** -- * Execute before each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#beforeEach -- */ --declare var beforeEach: Mocha.HookFunction; -- --/** -- * Execute before each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#beforeEach -- */ --declare var setup: Mocha.HookFunction; -- --/** -- * Execute after each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#afterEach -- */ --declare var afterEach: Mocha.HookFunction; -- --/** -- * Execute after each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#afterEach -- */ --declare var teardown: Mocha.HookFunction; -- --/** -- * Describe a "suite" containing nested suites and tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var describe: Mocha.SuiteFunction; -- --/** -- * Describe a "suite" containing nested suites and tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var context: Mocha.SuiteFunction; -- --/** -- * Describe a "suite" containing nested suites and tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var suite: Mocha.SuiteFunction; -- --/** -- * Pending suite. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var xdescribe: Mocha.PendingSuiteFunction; -- --/** -- * Pending suite. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var xcontext: Mocha.PendingSuiteFunction; -- --/** -- * Describes a test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var it: Mocha.TestFunction; -- --/** -- * Describes a test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var specify: Mocha.TestFunction; -- --/** -- * Describes a test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var test: Mocha.TestFunction; -- --/** -- * Describes a pending test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var xit: Mocha.PendingTestFunction; -- --/** -- * Describes a pending test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var xspecify: Mocha.PendingTestFunction; -- --// #endregion Test interface augmentations -- --// #region Reporter augmentations -- --// Forward declaration for `HTMLLIElement` from lib.dom.d.ts. --// Required by Mocha.reporters.HTML. --// NOTE: Mocha *must not* have a direct dependency on DOM types. --// tslint:disable-next-line no-empty-interface --interface HTMLLIElement { } -- --// Augments the DOM `Window` object when lib.dom.d.ts is loaded. --// tslint:disable-next-line no-empty-interface --interface Window extends Mocha.MochaGlobals { } -- --declare namespace NodeJS { -- // Forward declaration for `NodeJS.EventEmitter` from node.d.ts. -- // Required by Mocha.Runnable, Mocha.Runner, and Mocha.Suite. -- // NOTE: Mocha *must not* have a direct dependency on @types/node. -- // tslint:disable-next-line no-empty-interface -- interface EventEmitter { } -- -- // Augments NodeJS's `global` object when node.d.ts is loaded -- // tslint:disable-next-line no-empty-interface -- interface Global extends Mocha.MochaGlobals { } --} -- --// #endregion Reporter augmentations -- --// #region Browser augmentations -- --/** -- * Mocha global. -- * -- * - _Only supported in the browser._ -- */ --declare const mocha: BrowserMocha; -- --interface BrowserMocha extends Mocha { -- /** -- * Function to allow assertion libraries to throw errors directly into mocha. -- * This is useful when running tests in a browser because window.onerror will -- * only receive the 'message' attribute of the Error. -- * -- * - _Only supported in the browser._ -- */ -- throwError(err: any): never; -- -- /** -- * Setup mocha with the given settings options. -- * -- * - _Only supported in the browser._ -- */ -- setup(opts?: Mocha.Interface | Mocha.MochaOptions): this; --} -- --// #endregion Browser augmentations -- --declare module "mocha" { -- export = Mocha; --} -- --declare module "mocha/lib/ms" { -- export = milliseconds; -- /** -- * Parse the given `str` and return milliseconds. -- * -- * @see {@link https://mochajs.org/api/module-milliseconds.html} -- * @see {@link https://mochajs.org/api/module-milliseconds.html#~parse} -- */ -- function milliseconds(val: string): number; -- -- /** -- * Format for `ms`. -- * -- * @see {@link https://mochajs.org/api/module-milliseconds.html} -- * @see {@link https://mochajs.org/api/module-milliseconds.html#~format} -- */ -- function milliseconds(val: number): string; --} -- --declare module "mocha/lib/interfaces/common" { -- export = common; -- -- function common(suites: Mocha.Suite[], context: Mocha.MochaGlobals, mocha: Mocha): common.CommonFunctions; -- -- namespace common { -- interface CommonFunctions { -- /** -- * This is only present if flag --delay is passed into Mocha. It triggers -- * root suite execution. -- */ -- runWithSuite(suite: Mocha.Suite): () => void; -- -- /** -- * Execute before running tests. -- */ -- before(fn?: Mocha.Func | Mocha.AsyncFunc): void; -- -- /** -- * Execute before running tests. -- */ -- before(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; -- -- /** -- * Execute after running tests. -- */ -- after(fn?: Mocha.Func | Mocha.AsyncFunc): void; -- -- /** -- * Execute after running tests. -- */ -- after(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; -- -- /** -- * Execute before each test case. -- */ -- beforeEach(fn?: Mocha.Func | Mocha.AsyncFunc): void; -- -- /** -- * Execute before each test case. -- */ -- beforeEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; -- -- /** -- * Execute after each test case. -- */ -- afterEach(fn?: Mocha.Func | Mocha.AsyncFunc): void; -- -- /** -- * Execute after each test case. -- */ -- afterEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; -- -- suite: SuiteFunctions; -- test: TestFunctions; -- } -- -- interface CreateOptions { -- /** Title of suite */ -- title: string; -- -- /** Suite function */ -- fn?: (this: Mocha.Suite) => void; -- -- /** Is suite pending? */ -- pending?: boolean; -- -- /** Filepath where this Suite resides */ -- file?: string; -- -- /** Is suite exclusive? */ -- isOnly?: boolean; -- } -- -- interface SuiteFunctions { -- /** -- * Create an exclusive Suite; convenience function -- */ -- only(opts: CreateOptions): Mocha.Suite; -- -- /** -- * Create a Suite, but skip it; convenience function -- */ -- skip(opts: CreateOptions): Mocha.Suite; -- -- /** -- * Creates a suite. -- */ -- create(opts: CreateOptions): Mocha.Suite; -- } -- -- interface TestFunctions { -- /** -- * Exclusive test-case. -- */ -- only(mocha: Mocha, test: Mocha.Test): Mocha.Test; -- -- /** -- * Pending test case. -- */ -- skip(title: string): void; -- -- /** -- * Number of retry attempts -- */ -- retries(n: number): void; -- } -- } --} -+//z // Type definitions for mocha 8.0 -+//z // Project: https://mochajs.org -+//z // Definitions by: Kazi Manzur Rashid -+//z // otiai10 -+//z // Vadim Macagon -+//z // Andrew Bradley -+//z // Dmitrii Sorin -+//z // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -+//z // TypeScript Version: 2.1 -+ -+//z /** -+//z * Mocha API -+//z * -+//z * @see https://mochajs.org/api/mocha -+//z */ -+//z declare class Mocha { -+//z private _growl; -+//z private _reporter; -+//z private _ui; -+ -+//z constructor(options?: Mocha.MochaOptions); -+ -+//z suite: Mocha.Suite; -+//z files: string[]; -+//z options: Mocha.MochaInstanceOptions; -+ -+//z /** -+//z * Enable or disable bailing on the first failure. -+//z * -+//z * @see https://mochajs.org/api/mocha#bail -+//z */ -+//z bail(bail?: boolean): this; -+ -+//z /** -+//z * Add test `file`. -+//z * -+//z * @see https://mochajs.org/api/mocha#addFile -+//z */ -+//z addFile(file: string): this; -+ -+//z /** -+//z * Set reporter to one of the built-in reporters. -+//z * -+//z * @see https://mochajs.org/api/mocha#reporter -+//z */ -+//z reporter(reporter: Mocha.Reporter, reporterOptions?: any): this; -+ -+//z /** -+//z * Set reporter to the provided constructor, one of the built-in reporters, or loads a reporter -+//z * from a module path. Defaults to `"spec"`. -+//z * -+//z * @see https://mochajs.org/api/mocha#reporter -+//z */ -+//z reporter(reporter?: string | Mocha.ReporterConstructor, reporterOptions?: any): this; -+ -+//z /** -+//z * Set test UI to one of the built-in test interfaces. -+//z * -+//z * @see https://mochajs.org/api/mocha#ui -+//z */ -+//z ui(name: Mocha.Interface): this; -+ -+//z /** -+//z * Set test UI to one of the built-in test interfaces or loads a test interface from a module -+//z * path. Defaults to `"bdd"`. -+//z * -+//z * @see https://mochajs.org/api/mocha#ui -+//z */ -+//z ui(name?: string): this; -+ -+//z /** -+//z * Escape string and add it to grep as a RegExp. -+//z * -+//z * @see https://mochajs.org/api/mocha#fgrep -+//z */ -+//z fgrep(str: string): this; -+ -+//z /** -+//z * Add regexp to grep, if `re` is a string it is escaped. -+//z * -+//z * @see https://mochajs.org/api/mocha#grep -+//z */ -+//z grep(re: string | RegExp): this; -+ -+//z /** -+//z * Invert `.grep()` matches. -+//z * -+//z * @see https://mochajs.org/api/mocha#invert -+//z */ -+//z invert(): this; -+ -+//z /** -+//z * Enable global leak checking. -+//z * -+//z * @see https://mochajs.org/api/mocha#checkLeaks -+//z */ -+//z checkLeaks(): this; -+ -+//z /** -+//z * Display long stack-trace on failing -+//z * -+//z * @see https://mochajs.org/api/mocha#fullTrace -+//z */ -+//z fullTrace(): this; -+ -+//z /** -+//z * Enable growl support. -+//z * -+//z * @see https://mochajs.org/api/mocha#growl -+//z */ -+//z growl(): this; -+ -+//z /** -+//z * Ignore `globals` array or string. -+//z * -+//z * @see https://mochajs.org/api/mocha#globals -+//z */ -+//z globals(globals: string | ReadonlyArray): this; -+ -+//z /** -+//z * Set the timeout in milliseconds. -+//z * -+//z * @see https://mochajs.org/api/mocha#timeout -+//z */ -+//z timeout(timeout: string | number): this; -+ -+//z /** -+//z * Set the number of times to retry failed tests. -+//z * -+//z * @see https://mochajs.org/api/mocha#retries -+//z */ -+//z retries(n: number): this; -+ -+//z /** -+//z * Set slowness threshold in milliseconds. -+//z * -+//z * @see https://mochajs.org/api/mocha#slow -+//z */ -+//z slow(slow: string | number): this; -+ -+//z /** -+//z * Makes all tests async (accepting a callback) -+//z * -+//z * @see https://mochajs.org/api/mocha#asyncOnly. -+//z */ -+//z asyncOnly(): this; -+ -+//z /** -+//z * Disable syntax highlighting (in browser). -+//z * -+//z * @see https://mochajs.org/api/mocha#noHighlighting -+//z */ -+//z noHighlighting(): this; -+ -+//z /** -+//z * Enable uncaught errors to propagate (in browser). -+//z * -+//z * @see https://mochajs.org/api/mocha#allowUncaught -+//z */ -+//z allowUncaught(): boolean; -+ -+//z /** -+//z * Delay root suite execution. -+//z * -+//z * @see https://mochajs.org/api/mocha#delay -+//z */ -+//z delay(): boolean; -+ -+//z /** -+//z * Tests marked only fail the suite -+//z * -+//z * @see https://mochajs.org/api/mocha#forbidOnly -+//z */ -+//z forbidOnly(): boolean; -+ -+//z /** -+//z * Pending tests and tests marked skip fail the suite -+//z * -+//z * @see https://mochajs.org/api/mocha#forbidPending -+//z */ -+//z forbidPending(): boolean; -+ -+//z /** -+//z * Run tests and invoke `fn()` when complete. -+//z * -+//z * Note that `run` relies on Node's `require` to execute -+//z * the test interface functions and will be subject to the -+//z * cache - if the files are already in the `require` cache, -+//z * they will effectively be skipped. Therefore, to run tests -+//z * multiple times or to run tests in files that are already -+//z * in the `require` cache, make sure to clear them from the -+//z * cache first in whichever manner best suits your needs. -+//z * -+//z * @see https://mochajs.org/api/mocha#run -+//z */ -+//z run(fn?: (failures: number) => void): Mocha.Runner; -+ -+//z /** -+//z * Loads ESM (and CJS) test files asynchronously. -+//z * -+//z * @see https://mochajs.org/api/mocha#loadFilesAsync -+//z */ -+//z loadFilesAsync(): Promise; -+ -+//z /** -+//z * Load registered files. -+//z * -+//z * @see https://mochajs.org/api/mocha#loadFiles -+//z */ -+//z protected loadFiles(fn?: () => void): void; -+ -+//z /** -+//z * Unloads `files` from Node's `require` cache. -+//z * -+//z * This allows required files to be "freshly" reloaded, providing the ability -+//z * to reuse a Mocha instance programmatically. -+//z * Note: does not clear ESM module files from the cache -+//z */ -+//z unloadFiles(): this; -+ -+//z /** -+//z * Toggles parallel mode. -+//z * -+//z * Must be run before calling `run`. Changes the `Runner` class to -+//z * use; also enables lazy file loading if not already done so. -+//z * -+//z * @see https://mochajs.org/api/mocha#parallelMode -+//z */ -+//z parallelMode(enabled?: boolean): this; -+ -+//z /** -+//z * Assigns hooks to the root suite. -+//z * -+//z * @see https://mochajs.org/api/mocha#rootHooks -+//z */ -+//z rootHooks(hooks: Mocha.RootHookObject): this; -+//z } -+ -+//z declare namespace Mocha { -+//z namespace utils { -+//z /** -+//z * Compute a slug from the given `str`. -+//z * -+//z * @see https://mochajs.org/api/module-utils.html#.slug -+//z */ -+//z function slug(str: string): string; -+ -+//z /** -+//z * Strip the function definition from `str`, and re-indent for pre whitespace. -+//z * -+//z * @see https://mochajs.org/api/module-utils.html#.clean -+//z */ -+//z function clean(str: string): string; -+ -+//z /** -+//z * Highlight the given string of `js`. -+//z */ -+//z function highlight(js: string): string; -+ -+//z /** -+//z * Takes some variable and asks `Object.prototype.toString()` what it thinks it is. -+//z */ -+//z function type(value: any): string; -+ -+//z /** -+//z * Stringify `value`. Different behavior depending on type of value: -+//z * -+//z * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively. -+//z * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes. -+//z * - If `value` is an *empty* object, function, or array, returns `'{}'`, `'[Function]'`, or `'[]'` respectively. -+//z * - If `value` has properties, call canonicalize} on it, then return result of `JSON.stringify()` -+//z * -+//z * @see https://mochajs.org/api/module-utils.html#.stringify -+//z */ -+//z function stringify(value: any): string; -+ -+//z /** -+//z * Return a new Thing that has the keys in sorted order. Recursive. -+//z * -+//z * If the Thing... -+//z * - has already been seen, return string `'[Circular]'` -+//z * - is `undefined`, return string `'[undefined]'` -+//z * - is `null`, return value `null` -+//z * - is some other primitive, return the value -+//z * - is not a primitive or an `Array`, `Object`, or `Function`, return the value of the Thing's `toString()` method -+//z * - is a non-empty `Array`, `Object`, or `Function`, return the result of calling this function again. -+//z * - is an empty `Array`, `Object`, or `Function`, returns `'[]'`, `'{}'`, or `'[Function]'` respectively. -+//z * -+//z * @see https://mochajs.org/api/module-utils.html#.canonicalize -+//z */ -+//z function canonicalize(value: any, stack: any[], typeHint: string): any; -+ -+//z /** -+//z * Lookup file names at the given `path`. -+//z * -+//z * @see https://mochajs.org/api/Mocha.utils.html#.exports.lookupFiles -+//z */ -+//z function lookupFiles(filepath: string, extensions?: string[], recursive?: boolean): string[]; -+ -+//z /** -+//z * Generate an undefined error with a message warning the user. -+//z * -+//z * @see https://mochajs.org/api/module-utils.html#.undefinedError -+//z */ -+//z function undefinedError(): Error; -+ -+//z /** -+//z * Generate an undefined error if `err` is not defined. -+//z * -+//z * @see https://mochajs.org/api/module-utils.html#.getError -+//z */ -+//z function getError(err: Error | undefined): Error; -+ -+//z /** -+//z * When invoking this function you get a filter function that get the Error.stack as an -+//z * input, and return a prettify output. (i.e: strip Mocha and internal node functions from -+//z * stack trace). -+//z * -+//z * @see https://mochajs.org/api/module-utils.html#.stackTraceFilter -+//z */ -+//z function stackTraceFilter(): (stack: string) => string; -+//z } -+ -+//z namespace interfaces { -+//z function bdd(suite: Suite): void; -+//z function tdd(suite: Suite): void; -+//z function qunit(suite: Suite): void; -+//z function exports(suite: Suite): void; -+//z } -+ -+//z // #region Test interface augmentations -+ -+//z interface HookFunction { -+//z /** -+//z * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the -+//z * function is used as the name of the hook. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (fn: Func): void; -+ -+//z /** -+//z * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the -+//z * function is used as the name of the hook. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (fn: AsyncFunc): void; -+ -+//z /** -+//z * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (name: string, fn?: Func): void; -+ -+//z /** -+//z * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (name: string, fn?: AsyncFunc): void; -+//z } -+ -+//z interface SuiteFunction { -+//z /** -+//z * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing -+//z * nested suites. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (title: string, fn: (this: Suite) => void): Suite; -+ -+//z /** -+//z * [qunit] Describe a "suite" with the given `title`. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (title: string): Suite; -+ -+//z /** -+//z * [bdd, tdd, qunit] Indicates this suite should be executed exclusively. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z only: ExclusiveSuiteFunction; -+ -+//z /** -+//z * [bdd, tdd] Indicates this suite should not be executed. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z skip: PendingSuiteFunction; -+//z } -+ -+//z interface ExclusiveSuiteFunction { -+//z /** -+//z * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing -+//z * nested suites. Indicates this suite should be executed exclusively. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (title: string, fn: (this: Suite) => void): Suite; -+ -+//z /** -+//z * [qunit] Describe a "suite" with the given `title`. Indicates this suite should be executed -+//z * exclusively. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (title: string): Suite; -+//z } -+ -+//z /** -+//z * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing -+//z * nested suites. Indicates this suite should not be executed. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @returns [bdd] `Suite` -+//z * @returns [tdd] `void` -+//z */ -+//z interface PendingSuiteFunction { -+//z (title: string, fn: (this: Suite) => void): Suite | void; -+//z } -+ -+//z interface TestFunction { -+//z /** -+//z * Describe a specification or test-case with the given callback `fn` acting as a thunk. -+//z * The name of the function is used as the name of the test. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (fn: Func): Test; -+ -+//z /** -+//z * Describe a specification or test-case with the given callback `fn` acting as a thunk. -+//z * The name of the function is used as the name of the test. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (fn: AsyncFunc): Test; -+ -+//z /** -+//z * Describe a specification or test-case with the given `title` and callback `fn` acting -+//z * as a thunk. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (title: string, fn?: Func): Test; -+ -+//z /** -+//z * Describe a specification or test-case with the given `title` and callback `fn` acting -+//z * as a thunk. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (title: string, fn?: AsyncFunc): Test; -+ -+//z /** -+//z * Indicates this test should be executed exclusively. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z only: ExclusiveTestFunction; -+ -+//z /** -+//z * Indicates this test should not be executed. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z skip: PendingTestFunction; -+ -+//z /** -+//z * Number of attempts to retry. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z retries(n: number): void; -+//z } -+ -+//z interface ExclusiveTestFunction { -+//z /** -+//z * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` -+//z * acting as a thunk. The name of the function is used as the name of the test. Indicates -+//z * this test should be executed exclusively. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (fn: Func): Test; -+ -+//z /** -+//z * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` -+//z * acting as a thunk. The name of the function is used as the name of the test. Indicates -+//z * this test should be executed exclusively. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (fn: AsyncFunc): Test; -+ -+//z /** -+//z * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and -+//z * callback `fn` acting as a thunk. Indicates this test should be executed exclusively. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (title: string, fn?: Func): Test; -+ -+//z /** -+//z * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and -+//z * callback `fn` acting as a thunk. Indicates this test should be executed exclusively. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (title: string, fn?: AsyncFunc): Test; -+//z } -+ -+//z interface PendingTestFunction { -+//z /** -+//z * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` -+//z * acting as a thunk. The name of the function is used as the name of the test. Indicates -+//z * this test should not be executed. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (fn: Func): Test; -+ -+//z /** -+//z * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` -+//z * acting as a thunk. The name of the function is used as the name of the test. Indicates -+//z * this test should not be executed. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (fn: AsyncFunc): Test; -+ -+//z /** -+//z * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and -+//z * callback `fn` acting as a thunk. Indicates this test should not be executed. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (title: string, fn?: Func): Test; -+ -+//z /** -+//z * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and -+//z * callback `fn` acting as a thunk. Indicates this test should not be executed. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z (title: string, fn?: AsyncFunc): Test; -+//z } -+ -+//z /** -+//z * Execute after each test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#afterEach -+//z */ -+//z let afterEach: HookFunction; -+ -+//z /** -+//z * Execute after running tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#after -+//z */ -+//z let after: HookFunction; -+ -+//z /** -+//z * Execute before each test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#beforeEach -+//z */ -+//z let beforeEach: HookFunction; -+ -+//z /** -+//z * Execute before running tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#before -+//z */ -+//z let before: HookFunction; -+ -+//z /** -+//z * Describe a "suite" containing nested suites and tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z let describe: SuiteFunction; -+ -+//z /** -+//z * Describes a test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z let it: TestFunction; -+ -+//z /** -+//z * Describes a pending test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z let xit: PendingTestFunction; -+ -+//z /** -+//z * Execute before each test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#beforeEach -+//z */ -+//z let setup: HookFunction; -+ -+//z /** -+//z * Execute before running tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#before -+//z */ -+//z let suiteSetup: HookFunction; -+ -+//z /** -+//z * Execute after running tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#after -+//z */ -+//z let suiteTeardown: HookFunction; -+ -+//z /** -+//z * Describe a "suite" containing nested suites and tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z let suite: SuiteFunction; -+ -+//z /** -+//z * Execute after each test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#afterEach -+//z */ -+//z let teardown: HookFunction; -+ -+//z /** -+//z * Describes a test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z let test: TestFunction; -+ -+//z /** -+//z * Triggers root suite execution. -+//z * -+//z * - _Only available if flag --delay is passed into Mocha._ -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#runWithSuite -+//z */ -+//z function run(): void; -+ -+//z // #endregion Test interface augmentations -+ -+//z namespace reporters { -+//z /** -+//z * Initialize a new `Base` reporter. -+//z * -+//z * All other reporters generally inherit from this reporter, providing stats such as test duration, -+//z * number of tests passed / failed, etc. -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.Base.html -+//z */ -+//z class Base { -+//z constructor(runner: Runner, options?: MochaOptions); -+ -+//z /** -+//z * Test run statistics -+//z */ -+//z stats: Stats; -+ -+//z /** -+//z * Test failures -+//z */ -+//z failures: Test[]; -+ -+//z /** -+//z * The configured runner -+//z */ -+//z runner: Runner; -+ -+//z /** -+//z * Output common epilogue used by many of the bundled reporters. -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.Base.html#.Base#epilogue -+//z */ -+//z epilogue(): void; -+ -+//z done?(failures: number, fn?: (failures: number) => void): void; -+//z } -+ -+//z namespace Base { -+//z /** -+//z * Enables coloring by default -+//z * -+//z * @see https://mochajs.org/api/module-base#.useColors -+//z */ -+//z let useColors: boolean; -+ -+//z /** -+//z * Inline diffs instead of +/- -+//z * -+//z * @see https://mochajs.org/api/module-base#.inlineDiffs -+//z */ -+//z let inlineDiffs: boolean; -+ -+//z /** -+//z * Default color map -+//z * -+//z * @see https://mochajs.org/api/module-base#.colors -+//z */ -+//z const colors: ColorMap; -+ -+//z /** -+//z * Default color map -+//z * -+//z * @see https://mochajs.org/api/module-base#.colors -+//z */ -+//z interface ColorMap { -+//z // added by Base -+//z pass: number; -+//z fail: number; -+//z "bright pass": number; -+//z "bright fail": number; -+//z "bright yellow": number; -+//z pending: number; -+//z suite: number; -+//z "error title": number; -+//z "error message": number; -+//z "error stack": number; -+//z checkmark: number; -+//z fast: number; -+//z medium: number; -+//z slow: number; -+//z green: number; -+//z light: number; -+//z "diff gutter": number; -+//z "diff added": number; -+//z "diff removed": number; -+ -+//z // added by Progress -+//z progress: number; -+ -+//z // added by Landing -+//z plane: number; -+//z "plane crash": number; -+//z runway: number; -+ -+//z [key: string]: number; -+//z } -+ -+//z /** -+//z * Default symbol map -+//z * -+//z * @see https://mochajs.org/api/module-base#.symbols -+//z */ -+//z const symbols: SymbolMap; -+ -+//z /** -+//z * Default symbol map -+//z * -+//z * @see https://mochajs.org/api/module-base#.symbols -+//z */ -+//z interface SymbolMap { -+//z ok: string; -+//z err: string; -+//z dot: string; -+//z comma: string; -+//z bang: string; -+//z [key: string]: string; -+//z } -+ -+//z /** -+//z * Color `str` with the given `type` (from `colors`) -+//z * -+//z * @see https://mochajs.org/api/module-base#.color -+//z */ -+//z function color(type: string, str: string): string; -+ -+//z /** -+//z * Expose terminal window size -+//z * -+//z * @see https://mochajs.org/api/module-base#.window -+//z */ -+//z const window: { -+//z width: number; -+//z }; -+ -+//z /** -+//z * ANSI TTY control sequences common among reporters. -+//z * -+//z * @see https://mochajs.org/api/module-base#.cursor -+//z */ -+//z namespace cursor { -+//z /** -+//z * Hides the cursor -+//z */ -+//z function hide(): void; -+ -+//z /** -+//z * Shows the cursor -+//z */ -+//z function show(): void; -+ -+//z /** -+//z * Deletes the current line -+//z */ -+//z function deleteLine(): void; -+ -+//z /** -+//z * Moves to the beginning of the line -+//z */ -+//z function beginningOfLine(): void; -+ -+//z /** -+//z * Clears the line and moves to the beginning of the line. -+//z */ -+//z function CR(): void; -+//z } -+ -+//z /** -+//z * Returns a diff between two strings with colored ANSI output. -+//z * -+//z * @see https://mochajs.org/api/module-base#.generateDiff -+//z */ -+//z function generateDiff(actual: string, expected: string): string; -+ -+//z /** -+//z * Output the given `failures` as a list. -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.Base.html#.exports.list1 -+//z */ -+//z function list(failures: Test[]): void; -+//z } -+ -+//z /** -+//z * Initialize a new `Dot` matrix test reporter. -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.Dot.html -+//z */ -+//z class Dot extends Base { -+//z } -+ -+//z /** -+//z * Initialize a new `Doc` reporter. -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.Doc.html -+//z */ -+//z class Doc extends Base { -+//z } -+ -+//z /** -+//z * Initialize a new `TAP` test reporter. -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.TAP.html -+//z */ -+//z class TAP extends Base { -+//z } -+ -+//z /** -+//z * Initialize a new `JSON` reporter -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.JSON.html -+//z */ -+//z class JSON extends Base { -+//z } -+ -+//z /** -+//z * Initialize a new `HTML` reporter. -+//z * -+//z * - _This reporter cannot be used on the console._ -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.HTML.html -+//z */ -+//z class HTML extends Base { -+//z /** -+//z * Provide suite URL. -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.HTML.html#suiteURL -+//z */ -+//z suiteURL(suite: Suite): string; -+ -+//z /** -+//z * Provide test URL. -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.HTML.html#testURL -+//z */ -+//z testURL(test: Test): string; -+ -+//z /** -+//z * Adds code toggle functionality for the provided test's list element. -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.HTML.html#addCodeToggle -+//z */ -+//z addCodeToggle(el: HTMLLIElement, contents: string): void; -+//z } -+ -+//z /** -+//z * Initialize a new `List` test reporter. -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.List.html -+//z */ -+//z class List extends Base { -+//z } -+ -+//z /** -+//z * Initialize a new `Min` minimal test reporter (best used with --watch). -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.Min.html -+//z */ -+//z class Min extends Base { -+//z } -+ -+//z /** -+//z * Initialize a new `Spec` test reporter. -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.Spec.html -+//z */ -+//z class Spec extends Base { -+//z } -+ -+//z /** -+//z * Initialize a new `NyanCat` test reporter. -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.Nyan.html -+//z */ -+//z class Nyan extends Base { -+//z private colorIndex; -+//z private numberOfLines; -+//z private rainbowColors; -+//z private scoreboardWidth; -+//z private tick; -+//z private trajectories; -+//z private trajectoryWidthMax; -+//z private draw; -+//z private drawScoreboard; -+//z private appendRainbow; -+//z private drawRainbow; -+//z private drawNyanCat; -+//z private face; -+//z private cursorUp; -+//z private cursorDown; -+//z private generateColors; -+//z private rainbowify; -+//z } -+ -+//z /** -+//z * Initialize a new `XUnit` test reporter. -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.XUnit.html -+//z */ -+//z class XUnit extends Base { -+//z constructor(runner: Runner, options?: XUnit.MochaOptions); -+ -+//z /** -+//z * Override done to close the stream (if it's a file). -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#done -+//z */ -+//z done(failures: number, fn: (failures: number) => void): void; -+ -+//z /** -+//z * Write out the given line. -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#write -+//z */ -+//z write(line: string): void; -+ -+//z /** -+//z * Output tag for the given `test.` -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#test -+//z */ -+//z test(test: Test): void; -+//z } -+ -+//z namespace XUnit { -+//z interface MochaOptions extends Mocha.MochaOptions { -+//z reporterOptions?: ReporterOptions; -+//z } -+ -+//z interface ReporterOptions { -+//z output?: string; -+//z suiteName?: string; -+//z } -+//z } -+ -+//z /** -+//z * Initialize a new `Markdown` test reporter. -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.Markdown.html -+//z */ -+//z class Markdown extends Base { -+//z } -+ -+//z /** -+//z * Initialize a new `Progress` bar test reporter. -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.Progress.html -+//z */ -+//z class Progress extends Base { -+//z constructor(runner: Runner, options?: Progress.MochaOptions); -+//z } -+ -+//z namespace Progress { -+//z interface MochaOptions extends Mocha.MochaOptions { -+//z reporterOptions?: ReporterOptions; -+//z } -+ -+//z interface ReporterOptions { -+//z open?: string; -+//z complete?: string; -+//z incomplete?: string; -+//z close?: string; -+//z verbose?: boolean; -+//z } -+//z } -+ -+//z /** -+//z * Initialize a new `Landing` reporter. -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.Landing.html -+//z */ -+//z class Landing extends Base { -+//z } -+ -+//z /** -+//z * Initialize a new `JSONStream` test reporter. -+//z * -+//z * @see https://mochajs.org/api/Mocha.reporters.JSONStream.html -+//z */ -+//z class JSONStream extends Base { -+//z } -+ -+//z // value-only aliases -+//z const base: typeof Base; -+//z const dot: typeof Dot; -+//z const doc: typeof Doc; -+//z const tap: typeof TAP; -+//z const json: typeof JSON; -+//z const html: typeof HTML; -+//z const list: typeof List; -+//z const spec: typeof Spec; -+//z const nyan: typeof Nyan; -+//z const xunit: typeof XUnit; -+//z const markdown: typeof Markdown; -+//z const progress: typeof Progress; -+//z const landing: typeof Landing; -+//z // NOTE: not possible to type this correctly: -+//z // const "json-stream": typeof JSONStream; -+//z } -+ -+//z /** -+//z * Initialize a new `Runnable` with the given `title` and callback `fn`. -+//z * -+//z * @see https://mochajs.org/api/Runnable.html -+//z */ -+//z class Runnable { -+//z private _slow; -+//z private _retries; -+//z private _currentRetry; -+//z private _timeout; -+//z private _timeoutError; -+ -+//z constructor(title: string, fn?: Func | AsyncFunc); -+ -+//z title: string; -+//z fn: Func | AsyncFunc | undefined; -+//z body: string; -+//z async: boolean; -+//z sync: boolean; -+//z timedOut: boolean; -+//z pending: boolean; -+//z duration?: number; -+//z parent?: Suite; -+//z state?: "failed" | "passed"; -+//z timer?: any; -+//z ctx?: Context; -+//z callback?: Done; -+//z allowUncaught?: boolean; -+//z file?: string; -+ -+//z /** -+//z * Get test timeout. -+//z * -+//z * @see https://mochajs.org/api/Runnable.html#timeout -+//z */ -+//z timeout(): number; -+ -+//z /** -+//z * Set test timeout. -+//z * -+//z * @see https://mochajs.org/api/Runnable.html#timeout -+//z */ -+//z timeout(ms: string | number): this; -+ -+//z /** -+//z * Get test slowness threshold. -+//z * -+//z * @see https://mochajs.org/api/Runnable.html#slow -+//z */ -+//z slow(): number; -+ -+//z /** -+//z * Set test slowness threshold. -+//z * -+//z * @see https://mochajs.org/api/Runnable.html#slow -+//z */ -+//z slow(ms: string | number): this; -+ -+//z /** -+//z * Halt and mark as pending. -+//z */ -+//z skip(): never; -+ -+//z /** -+//z * Check if this runnable or its parent suite is marked as pending. -+//z * -+//z * @see https://mochajs.org/api/Runnable.html#isPending -+//z */ -+//z isPending(): boolean; -+ -+//z /** -+//z * Return `true` if this Runnable has failed. -+//z */ -+//z isFailed(): boolean; -+ -+//z /** -+//z * Return `true` if this Runnable has passed. -+//z */ -+//z isPassed(): boolean; -+ -+//z /** -+//z * Set or get number of retries. -+//z * -+//z * @see https://mochajs.org/api/Runnable.html#retries -+//z */ -+//z retries(): number; -+ -+//z /** -+//z * Set or get number of retries. -+//z * -+//z * @see https://mochajs.org/api/Runnable.html#retries -+//z */ -+//z retries(n: number): void; -+ -+//z /** -+//z * Set or get current retry -+//z * -+//z * @see https://mochajs.org/api/Runnable.html#currentRetry -+//z */ -+//z protected currentRetry(): number; -+ -+//z /** -+//z * Set or get current retry -+//z * -+//z * @see https://mochajs.org/api/Runnable.html#currentRetry -+//z */ -+//z protected currentRetry(n: number): void; -+ -+//z /** -+//z * Return the full title generated by recursively concatenating the parent's full title. -+//z */ -+//z fullTitle(): string; -+ -+//z /** -+//z * Return the title path generated by concatenating the parent's title path with the title. -+//z */ -+//z titlePath(): string[]; -+ -+//z /** -+//z * Clear the timeout. -+//z * -+//z * @see https://mochajs.org/api/Runnable.html#clearTimeout -+//z */ -+//z clearTimeout(): void; -+ -+//z /** -+//z * Inspect the runnable void of private properties. -+//z * -+//z * @see https://mochajs.org/api/Runnable.html#inspect -+//z */ -+//z inspect(): string; -+ -+//z /** -+//z * Reset the timeout. -+//z * -+//z * @see https://mochajs.org/api/Runnable.html#resetTimeout -+//z */ -+//z resetTimeout(): void; -+ -+//z /** -+//z * Get a list of whitelisted globals for this test run. -+//z * -+//z * @see https://mochajs.org/api/Runnable.html#globals -+//z */ -+//z globals(): string[]; -+ -+//z /** -+//z * Set a list of whitelisted globals for this test run. -+//z * -+//z * @see https://mochajs.org/api/Runnable.html#globals -+//z */ -+//z globals(globals: ReadonlyArray): void; -+ -+//z /** -+//z * Run the test and invoke `fn(err)`. -+//z * -+//z * @see https://mochajs.org/api/Runnable.html#run -+//z */ -+//z run(fn: Done): void; -+//z } -+ -+//z // #region Runnable "error" event -+//z interface Runnable extends NodeJS.EventEmitter { -+//z on(event: "error", listener: (error: any) => void): this; -+//z once(event: "error", listener: (error: any) => void): this; -+//z addListener(event: "error", listener: (error: any) => void): this; -+//z removeListener(event: "error", listener: (error: any) => void): this; -+//z prependListener(event: "error", listener: (error: any) => void): this; -+//z prependOnceListener(event: "error", listener: (error: any) => void): this; -+//z emit(name: "error", error: any): boolean; -+//z } -+//z // #endregion Runnable "error" event -+//z // #region Runnable untyped events -+//z interface Runnable extends NodeJS.EventEmitter { -+//z on(event: string, listener: (...args: any[]) => void): this; -+//z once(event: string, listener: (...args: any[]) => void): this; -+//z addListener(event: string, listener: (...args: any[]) => void): this; -+//z removeListener(event: string, listener: (...args: any[]) => void): this; -+//z prependListener(event: string, listener: (...args: any[]) => void): this; -+//z prependOnceListener(event: string, listener: (...args: any[]) => void): this; -+//z emit(name: string, ...args: any[]): boolean; -+//z } -+//z // #endregion Runnable untyped events -+ -+//z /** -+//z * Test context -+//z * -+//z * @see https://mochajs.org/api/module-Context.html#~Context -+//z */ -+//z class Context { -+//z private _runnable; -+ -+//z test?: Runnable; -+//z currentTest?: Test; -+ -+//z /** -+//z * Get the context `Runnable`. -+//z */ -+//z runnable(): Runnable; -+ -+//z /** -+//z * Set the context `Runnable`. -+//z */ -+//z runnable(runnable: Runnable): this; -+ -+//z /** -+//z * Get test timeout. -+//z */ -+//z timeout(): number; -+ -+//z /** -+//z * Set test timeout. -+//z */ -+//z timeout(ms: string | number): this; -+ -+//z /** -+//z * Get test slowness threshold. -+//z */ -+//z slow(): number; -+ -+//z /** -+//z * Set test slowness threshold. -+//z */ -+//z slow(ms: string | number): this; -+ -+//z /** -+//z * Mark a test as skipped. -+//z */ -+//z skip(): never; -+ -+//z /** -+//z * Get the number of allowed retries on failed tests. -+//z */ -+//z retries(): number; -+ -+//z /** -+//z * Set the number of allowed retries on failed tests. -+//z */ -+//z retries(n: number): this; -+ -+//z [key: string]: any; -+//z } -+ -+//z interface RunnerConstants { -+//z readonly EVENT_HOOK_BEGIN: 'hook'; -+//z readonly EVENT_HOOK_END: 'hook end'; -+//z readonly EVENT_RUN_BEGIN: 'start'; -+//z readonly EVENT_DELAY_BEGIN: 'waiting'; -+//z readonly EVENT_DELAY_END: 'ready'; -+//z readonly EVENT_RUN_END: 'end'; -+//z readonly EVENT_SUITE_BEGIN: 'suite'; -+//z readonly EVENT_SUITE_END: 'suite end'; -+//z readonly EVENT_TEST_BEGIN: 'test'; -+//z readonly EVENT_TEST_END: 'test end'; -+//z readonly EVENT_TEST_FAIL: 'fail'; -+//z readonly EVENT_TEST_PASS: 'pass'; -+//z readonly EVENT_TEST_PENDING: 'pending'; -+//z readonly EVENT_TEST_RETRY: 'retry'; -+//z } -+ -+//z /** -+//z * Initialize a `Runner` for the given `suite`. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html -+//z */ -+//z class Runner { -+//z private _globals; -+//z private _abort; -+//z private _delay; -+//z private _defaultGrep; -+//z private next; -+//z private hookErr; -+//z private prevGlobalsLength; -+//z private nextSuite; -+ -+//z static readonly constants: RunnerConstants; -+ -+//z constructor(suite: Suite, delay: boolean); -+ -+//z suite: Suite; -+//z started: boolean; -+//z total: number; -+//z failures: number; -+//z asyncOnly?: boolean; -+//z allowUncaught?: boolean; -+//z fullStackTrace?: boolean; -+//z forbidOnly?: boolean; -+//z forbidPending?: boolean; -+//z checkLeaks?: boolean; -+//z test?: Test; -+//z currentRunnable?: Runnable; -+//z stats?: Stats; // added by reporters -+ -+//z /** -+//z * Run tests with full titles matching `re`. Updates runner.total -+//z * with number of tests matched. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grep -+//z */ -+//z grep(re: RegExp, invert: boolean): this; -+ -+//z /** -+//z * Returns the number of tests matching the grep search for the -+//z * given suite. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grepTotal -+//z */ -+//z grepTotal(suite: Suite): number; -+ -+//z /** -+//z * Gets the allowed globals. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals -+//z */ -+//z globals(): string[]; -+ -+//z /** -+//z * Allow the given `arr` of globals. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals -+//z */ -+//z globals(arr: ReadonlyArray): this; -+ -+//z /** -+//z * Run the root suite and invoke `fn(failures)` on completion. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#run -+//z */ -+//z run(fn?: (failures: number) => void): this; -+ -+//z /** -+//z * Cleanly abort execution. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#abort -+//z */ -+//z abort(): this; -+ -+//z /** -+//z * Handle uncaught exceptions. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#uncaught -+//z */ -+//z uncaught(err: any): void; -+ -+//z /** -+//z * Wrapper for setImmediate, process.nextTick, or browser polyfill. -+//z */ -+//z protected static immediately(callback: Function): void; -+ -+//z /** -+//z * Return a list of global properties. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#globalProps -+//z */ -+//z protected globalProps(): string[]; -+ -+//z /** -+//z * Check for global variable leaks. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#checkGlobals -+//z */ -+//z protected checkGlobals(test: Test): void; -+ -+//z /** -+//z * Fail the given `test`. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#fail -+//z */ -+//z protected fail(test: Test, err: any): void; -+ -+//z /** -+//z * Fail the given `hook` with `err`. -+//z * -+//z * Hook failures work in the following pattern: -+//z * - If bail, then exit -+//z * - Failed `before` hook skips all tests in a suite and subsuites, -+//z * but jumps to corresponding `after` hook -+//z * - Failed `before each` hook skips remaining tests in a -+//z * suite and jumps to corresponding `after each` hook, -+//z * which is run only once -+//z * - Failed `after` hook does not alter -+//z * execution order -+//z * - Failed `after each` hook skips remaining tests in a -+//z * suite and subsuites, but executes other `after each` -+//z * hooks -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#failHook -+//z */ -+//z protected failHook(hook: Hook, err: any): void; -+ -+//z /** -+//z * Run hook `name` callbacks and then invoke `fn()`. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#hook -+//z */ -+//z protected hook(name: string, fn: () => void): void; -+ -+//z /** -+//z * Run hook `name` for the given array of `suites` -+//z * in order, and callback `fn(err, errSuite)`. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#hooks -+//z */ -+//z protected hooks(name: string, suites: Suite[], fn: (err?: any, errSuite?: Suite) => void): void; -+ -+//z /** -+//z * Run hooks from the top level down. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#hookUp -+//z */ -+//z protected hookUp(name: string, fn: (err?: any, errSuite?: Suite) => void): void; -+ -+//z /** -+//z * Run hooks from the bottom up. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#hookDown -+//z */ -+//z protected hookDown(name: string, fn: (err?: any, errSuite?: Suite) => void): void; -+ -+//z /** -+//z * Return an array of parent Suites from closest to furthest. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#parents -+//z */ -+//z protected parents(): Suite[]; -+ -+//z /** -+//z * Run the current test and callback `fn(err)`. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#runTest -+//z */ -+//z protected runTest(fn: Done): any; -+ -+//z /** -+//z * Run tests in the given `suite` and invoke the callback `fn()` when complete. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#runTests -+//z */ -+//z protected runTests(suite: Suite, fn: (errSuite?: Suite) => void): void; -+ -+//z /** -+//z * Run the given `suite` and invoke the callback `fn()` when complete. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Runner.html#runSuite -+//z */ -+//z protected runSuite(suite: Suite, fn: (errSuite?: Suite) => void): void; -+//z } -+ -+//z // #region Runner "waiting" event -+//z interface Runner { -+//z on(event: "waiting", listener: (rootSuite: Suite) => void): this; -+//z once(event: "waiting", listener: (rootSuite: Suite) => void): this; -+//z addListener(event: "waiting", listener: (rootSuite: Suite) => void): this; -+//z removeListener(event: "waiting", listener: (rootSuite: Suite) => void): this; -+//z prependListener(event: "waiting", listener: (rootSuite: Suite) => void): this; -+//z prependOnceListener(event: "waiting", listener: (rootSuite: Suite) => void): this; -+//z emit(name: "waiting", rootSuite: Suite): boolean; -+//z } -+//z // #endregion Runner "waiting" event -+//z // #region Runner "start" event -+//z interface Runner extends NodeJS.EventEmitter { -+//z on(event: "start", listener: () => void): this; -+//z once(event: "start", listener: () => void): this; -+//z addListener(event: "start", listener: () => void): this; -+//z removeListener(event: "start", listener: () => void): this; -+//z prependListener(event: "start", listener: () => void): this; -+//z prependOnceListener(event: "start", listener: () => void): this; -+//z emit(name: "start"): boolean; -+//z } -+//z // #endregion Runner "start" event -+//z // #region Runner "end" event -+//z interface Runner extends NodeJS.EventEmitter { -+//z on(event: "end", listener: () => void): this; -+//z once(event: "end", listener: () => void): this; -+//z addListener(event: "end", listener: () => void): this; -+//z removeListener(event: "end", listener: () => void): this; -+//z prependListener(event: "end", listener: () => void): this; -+//z prependOnceListener(event: "end", listener: () => void): this; -+//z emit(name: "end"): boolean; -+//z } -+//z // #endregion Runner "end" event -+//z // #region Runner "suite" event -+//z interface Runner extends NodeJS.EventEmitter { -+//z on(event: "suite", listener: (suite: Suite) => void): this; -+//z once(event: "suite", listener: (suite: Suite) => void): this; -+//z addListener(event: "suite", listener: (suite: Suite) => void): this; -+//z removeListener(event: "suite", listener: (suite: Suite) => void): this; -+//z prependListener(event: "suite", listener: (suite: Suite) => void): this; -+//z prependOnceListener(event: "suite", listener: (suite: Suite) => void): this; -+//z emit(name: "suite", suite: Suite): boolean; -+//z } -+//z // #endregion Runner "suite" event -+//z // #region Runner "suite end" event -+//z interface Runner extends NodeJS.EventEmitter { -+//z on(event: "suite end", listener: (suite: Suite) => void): this; -+//z once(event: "suite end", listener: (suite: Suite) => void): this; -+//z addListener(event: "suite end", listener: (suite: Suite) => void): this; -+//z removeListener(event: "suite end", listener: (suite: Suite) => void): this; -+//z prependListener(event: "suite end", listener: (suite: Suite) => void): this; -+//z prependOnceListener(event: "suite end", listener: (suite: Suite) => void): this; -+//z emit(name: "suite end", suite: Suite): boolean; -+//z } -+//z // #endregion Runner "suite end" event -+//z // #region Runner "test" event -+//z interface Runner extends NodeJS.EventEmitter { -+//z on(event: "test", listener: (test: Test) => void): this; -+//z once(event: "test", listener: (test: Test) => void): this; -+//z addListener(event: "test", listener: (test: Test) => void): this; -+//z removeListener(event: "test", listener: (test: Test) => void): this; -+//z prependListener(event: "test", listener: (test: Test) => void): this; -+//z prependOnceListener(event: "test", listener: (test: Test) => void): this; -+//z emit(name: "test", test: Test): boolean; -+//z } -+//z // #endregion Runner "test" event -+//z // #region Runner "test end" event -+//z interface Runner extends NodeJS.EventEmitter { -+//z on(event: "test end", listener: (test: Test) => void): this; -+//z once(event: "test end", listener: (test: Test) => void): this; -+//z addListener(event: "test end", listener: (test: Test) => void): this; -+//z removeListener(event: "test end", listener: (test: Test) => void): this; -+//z prependListener(event: "test end", listener: (test: Test) => void): this; -+//z prependOnceListener(event: "test end", listener: (test: Test) => void): this; -+//z emit(name: "test end", test: Test): boolean; -+//z } -+//z // #endregion Runner "test end" event -+//z // #region Runner "hook" event -+//z interface Runner extends NodeJS.EventEmitter { -+//z on(event: "hook", listener: (hook: Hook) => void): this; -+//z once(event: "hook", listener: (hook: Hook) => void): this; -+//z addListener(event: "hook", listener: (hook: Hook) => void): this; -+//z removeListener(event: "hook", listener: (hook: Hook) => void): this; -+//z prependListener(event: "hook", listener: (hook: Hook) => void): this; -+//z prependOnceListener(event: "hook", listener: (hook: Hook) => void): this; -+//z emit(name: "hook", hook: Hook): boolean; -+//z } -+//z // #endregion Runner "hook" event -+//z // #region Runner "hook end" event -+//z interface Runner extends NodeJS.EventEmitter { -+//z on(event: "hook end", listener: (hook: Hook) => void): this; -+//z once(event: "hook end", listener: (hook: Hook) => void): this; -+//z addListener(event: "hook end", listener: (hook: Hook) => void): this; -+//z removeListener(event: "hook end", listener: (hook: Hook) => void): this; -+//z prependListener(event: "hook end", listener: (hook: Hook) => void): this; -+//z prependOnceListener(event: "hook end", listener: (hook: Hook) => void): this; -+//z emit(name: "hook end", hook: Hook): boolean; -+//z } -+//z // #endregion Runner "hook end" event -+//z // #region Runner "pass" event -+//z interface Runner extends NodeJS.EventEmitter { -+//z on(event: "pass", listener: (test: Test) => void): this; -+//z once(event: "pass", listener: (test: Test) => void): this; -+//z addListener(event: "pass", listener: (test: Test) => void): this; -+//z removeListener(event: "pass", listener: (test: Test) => void): this; -+//z prependListener(event: "pass", listener: (test: Test) => void): this; -+//z prependOnceListener(event: "pass", listener: (test: Test) => void): this; -+//z emit(name: "pass", test: Test): boolean; -+//z } -+//z // #endregion Runner "pass" event -+//z // #region Runner "fail" event -+//z interface Runner extends NodeJS.EventEmitter { -+//z on(event: "fail", listener: (test: Test, err: any) => void): this; -+//z once(event: "fail", listener: (test: Test, err: any) => void): this; -+//z addListener(event: "fail", listener: (test: Test, err: any) => void): this; -+//z removeListener(event: "fail", listener: (test: Test, err: any) => void): this; -+//z prependListener(event: "fail", listener: (test: Test, err: any) => void): this; -+//z prependOnceListener(event: "fail", listener: (test: Test, err: any) => void): this; -+//z emit(name: "fail", test: Test, err: any): boolean; -+//z } -+//z // #endregion Runner "fail" event -+//z // #region Runner "pending" event -+//z interface Runner extends NodeJS.EventEmitter { -+//z on(event: "pending", listener: (test: Test) => void): this; -+//z once(event: "pending", listener: (test: Test) => void): this; -+//z addListener(event: "pending", listener: (test: Test) => void): this; -+//z removeListener(event: "pending", listener: (test: Test) => void): this; -+//z prependListener(event: "pending", listener: (test: Test) => void): this; -+//z prependOnceListener(event: "pending", listener: (test: Test) => void): this; -+//z emit(name: "pending", test: Test): boolean; -+//z } -+//z // #endregion Runner "pending" event -+//z // #region Runner untyped events -+//z interface Runner extends NodeJS.EventEmitter { -+//z on(event: string, listener: (...args: any[]) => void): this; -+//z once(event: string, listener: (...args: any[]) => void): this; -+//z addListener(event: string, listener: (...args: any[]) => void): this; -+//z removeListener(event: string, listener: (...args: any[]) => void): this; -+//z prependListener(event: string, listener: (...args: any[]) => void): this; -+//z prependOnceListener(event: string, listener: (...args: any[]) => void): this; -+//z emit(name: string, ...args: any[]): boolean; -+//z } -+//z // #endregion Runner untyped events -+ -+//z interface SuiteConstants { -+//z readonly EVENT_FILE_POST_REQUIRE: 'post-require'; -+//z readonly EVENT_FILE_PRE_REQUIRE: 'pre-require'; -+//z readonly EVENT_FILE_REQUIRE: 'require'; -+//z readonly EVENT_ROOT_SUITE_RUN: 'run'; -+ -+//z readonly HOOK_TYPE_AFTER_ALL: 'afterAll'; -+//z readonly HOOK_TYPE_AFTER_EACH: 'afterEach'; -+//z readonly HOOK_TYPE_BEFORE_ALL: 'beforeAll'; -+//z readonly HOOK_TYPE_BEFORE_EACH: 'beforeEach'; -+ -+//z readonly EVENT_SUITE_ADD_HOOK_AFTER_ALL: 'afterAll'; -+//z readonly EVENT_SUITE_ADD_HOOK_AFTER_EACH: 'afterEach'; -+//z readonly EVENT_SUITE_ADD_HOOK_BEFORE_ALL: 'beforeAll'; -+//z readonly EVENT_SUITE_ADD_HOOK_BEFORE_EACH: 'beforeEach'; -+//z readonly EVENT_SUITE_ADD_SUITE: 'suite'; -+//z readonly EVENT_SUITE_ADD_TEST: 'test'; -+//z } -+ -+//z /** -+//z * Initialize a new `Suite` with the given `title` and `ctx`. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html -+//z */ -+//z class Suite { -+//z private _beforeEach; -+//z private _beforeAll; -+//z private _afterEach; -+//z private _afterAll; -+//z private _timeout; -+//z private _slow; -+//z private _bail; -+//z private _retries; -+//z private _onlyTests; -+//z private _onlySuites; -+ -+//z static readonly constants: SuiteConstants; -+ -+//z constructor(title: string, parentContext?: Context); -+ -+//z ctx: Context; -+//z suites: Suite[]; -+//z tests: Test[]; -+//z pending: boolean; -+//z file?: string; -+//z root: boolean; -+//z delayed: boolean; -+//z parent: Suite | undefined; -+//z title: string; -+ -+//z /** -+//z * Create a new `Suite` with the given `title` and parent `Suite`. When a suite -+//z * with the same title is already present, that suite is returned to provide -+//z * nicer reporter and more flexible meta-testing. -+//z * -+//z * @see https://mochajs.org/api/mocha#.exports.create -+//z */ -+//z static create(parent: Suite, title: string): Suite; -+ -+//z /** -+//z * Return a clone of this `Suite`. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#clone -+//z */ -+//z clone(): Suite; -+ -+//z /** -+//z * Get timeout `ms`. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#timeout -+//z */ -+//z timeout(): number; -+ -+//z /** -+//z * Set timeout `ms` or short-hand such as "2s". -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#timeout -+//z */ -+//z timeout(ms: string | number): this; -+ -+//z /** -+//z * Get number of times to retry a failed test. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#retries -+//z */ -+//z retries(): number; -+ -+//z /** -+//z * Set number of times to retry a failed test. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#retries -+//z */ -+//z retries(n: string | number): this; -+ -+//z /** -+//z * Get slow `ms`. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#slow -+//z */ -+//z slow(): number; -+ -+//z /** -+//z * Set slow `ms` or short-hand such as "2s". -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#slow -+//z */ -+//z slow(ms: string | number): this; -+ -+//z /** -+//z * Get whether to bail after first error. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#bail -+//z */ -+//z bail(): boolean; -+ -+//z /** -+//z * Set whether to bail after first error. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#bail -+//z */ -+//z bail(bail: boolean): this; -+ -+//z /** -+//z * Check if this suite or its parent suite is marked as pending. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#isPending -+//z */ -+//z isPending(): boolean; -+ -+//z /** -+//z * Run `fn(test[, done])` before running tests. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll -+//z */ -+//z beforeAll(fn?: Func): this; -+ -+//z /** -+//z * Run `fn(test[, done])` before running tests. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll -+//z */ -+//z beforeAll(fn?: AsyncFunc): this; -+ -+//z /** -+//z * Run `fn(test[, done])` before running tests. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll -+//z */ -+//z beforeAll(title: string, fn?: Func): this; -+ -+//z /** -+//z * Run `fn(test[, done])` before running tests. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll -+//z */ -+//z beforeAll(title: string, fn?: AsyncFunc): this; -+ -+//z /** -+//z * Run `fn(test[, done])` after running tests. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#afterAll -+//z */ -+//z afterAll(fn?: Func): this; -+ -+//z /** -+//z * Run `fn(test[, done])` after running tests. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#afterAll -+//z */ -+//z afterAll(fn?: AsyncFunc): this; -+ -+//z /** -+//z * Run `fn(test[, done])` after running tests. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#afterAll -+//z */ -+//z afterAll(title: string, fn?: Func): this; -+ -+//z /** -+//z * Run `fn(test[, done])` after running tests. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#afterAll -+//z */ -+//z afterAll(title: string, fn?: AsyncFunc): this; -+ -+//z /** -+//z * Run `fn(test[, done])` before each test case. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach -+//z */ -+//z beforeEach(fn?: Func): this; -+ -+//z /** -+//z * Run `fn(test[, done])` before each test case. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach -+//z */ -+//z beforeEach(fn?: AsyncFunc): this; -+ -+//z /** -+//z * Run `fn(test[, done])` before each test case. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach -+//z */ -+//z beforeEach(title: string, fn?: Func): this; -+ -+//z /** -+//z * Run `fn(test[, done])` before each test case. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach -+//z */ -+//z beforeEach(title: string, fn?: AsyncFunc): this; -+ -+//z /** -+//z * Run `fn(test[, done])` after each test case. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#afterEach -+//z */ -+//z afterEach(fn?: Func): this; -+ -+//z /** -+//z * Run `fn(test[, done])` after each test case. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#afterEach -+//z */ -+//z afterEach(fn?: AsyncFunc): this; -+ -+//z /** -+//z * Run `fn(test[, done])` after each test case. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#afterEach -+//z */ -+//z afterEach(title: string, fn?: Func): this; -+ -+//z /** -+//z * Run `fn(test[, done])` after each test case. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#afterEach -+//z */ -+//z afterEach(title: string, fn?: AsyncFunc): this; -+ -+//z /** -+//z * Add a test `suite`. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#addSuite -+//z */ -+//z addSuite(suite: Suite): this; -+ -+//z /** -+//z * Add a `test` to this suite. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#addTest -+//z */ -+//z addTest(test: Test): this; -+ -+//z /** -+//z * Return the full title generated by recursively concatenating the parent's -+//z * full title. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#fullTitle -+//z */ -+//z fullTitle(): string; -+ -+//z /** -+//z * Return the title path generated by recursively concatenating the parent's -+//z * title path. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#titlePath -+//z */ -+//z titlePath(): string[]; -+ -+//z /** -+//z * Return the total number of tests. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#total -+//z */ -+//z total(): number; -+ -+//z /** -+//z * Iterates through each suite recursively to find all tests. Applies a -+//z * function in the format `fn(test)`. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#eachTest -+//z */ -+//z eachTest(fn: (test: Test) => void): this; -+ -+//z /** -+//z * This will run the root suite if we happen to be running in delayed mode. -+//z * -+//z * @see https://mochajs.org/api/Mocha.Suite.html#run -+//z */ -+//z run(): void; -+ -+//z /** -+//z * Generic hook-creator. -+//z */ -+//z protected _createHook(title: string, fn?: Func | AsyncFunc): Hook; -+//z } -+ -+//z // #region Suite "beforeAll" event -+//z interface Suite extends NodeJS.EventEmitter { -+//z on(event: "beforeAll", listener: (hook: Hook) => void): this; -+//z once(event: "beforeAll", listener: (hook: Hook) => void): this; -+//z addListener(event: "beforeAll", listener: (hook: Hook) => void): this; -+//z removeListener(event: "beforeAll", listener: (hook: Hook) => void): this; -+//z prependListener(event: "beforeAll", listener: (hook: Hook) => void): this; -+//z prependOnceListener(event: "beforeAll", listener: (hook: Hook) => void): this; -+//z emit(name: "beforeAll", hook: Hook): boolean; -+//z } -+//z // #endregion Suite "beforeAll" event -+//z // #region Suite "afterAll" event -+//z interface Suite extends NodeJS.EventEmitter { -+//z on(event: "afterAll", listener: (hook: Hook) => void): this; -+//z once(event: "afterAll", listener: (hook: Hook) => void): this; -+//z addListener(event: "afterAll", listener: (hook: Hook) => void): this; -+//z removeListener(event: "afterAll", listener: (hook: Hook) => void): this; -+//z prependListener(event: "afterAll", listener: (hook: Hook) => void): this; -+//z prependOnceListener(event: "afterAll", listener: (hook: Hook) => void): this; -+//z emit(name: "afterAll", hook: Hook): boolean; -+//z } -+//z // #endregion Suite "afterAll" event -+//z // #region Suite "beforeEach" event -+//z interface Suite extends NodeJS.EventEmitter { -+//z on(event: "beforeEach", listener: (hook: Hook) => void): this; -+//z once(event: "beforeEach", listener: (hook: Hook) => void): this; -+//z addListener(event: "beforeEach", listener: (hook: Hook) => void): this; -+//z removeListener(event: "beforeEach", listener: (hook: Hook) => void): this; -+//z prependListener(event: "beforeEach", listener: (hook: Hook) => void): this; -+//z prependOnceListener(event: "beforeEach", listener: (hook: Hook) => void): this; -+//z emit(name: "beforeEach", hook: Hook): boolean; -+//z } -+//z // #endregion Suite "beforeEach" event -+//z // #region Suite "afterEach" event -+//z interface Suite extends NodeJS.EventEmitter { -+//z on(event: "afterEach", listener: (hook: Hook) => void): this; -+//z once(event: "afterEach", listener: (hook: Hook) => void): this; -+//z addListener(event: "afterEach", listener: (hook: Hook) => void): this; -+//z removeListener(event: "afterEach", listener: (hook: Hook) => void): this; -+//z prependListener(event: "afterEach", listener: (hook: Hook) => void): this; -+//z prependOnceListener(event: "afterEach", listener: (hook: Hook) => void): this; -+//z emit(name: "afterEach", hook: Hook): boolean; -+//z } -+//z // #endregion Suite "afterEach" event -+//z // #region Suite "suite" event -+//z interface Suite extends NodeJS.EventEmitter { -+//z on(event: "suite", listener: (suite: Suite) => void): this; -+//z once(event: "suite", listener: (suite: Suite) => void): this; -+//z addListener(event: "suite", listener: (suite: Suite) => void): this; -+//z removeListener(event: "suite", listener: (suite: Suite) => void): this; -+//z prependListener(event: "suite", listener: (suite: Suite) => void): this; -+//z prependOnceListener(event: "suite", listener: (suite: Suite) => void): this; -+//z emit(name: "suite", suite: Suite): boolean; -+//z } -+//z // #endregion Suite "suite" event -+//z // #region Suite "test" event -+//z interface Suite { -+//z on(event: "test", listener: (test: Test) => void): this; -+//z once(event: "test", listener: (test: Test) => void): this; -+//z addListener(event: "test", listener: (test: Test) => void): this; -+//z removeListener(event: "test", listener: (test: Test) => void): this; -+//z prependListener(event: "test", listener: (test: Test) => void): this; -+//z prependOnceListener(event: "test", listener: (test: Test) => void): this; -+//z emit(name: "test", test: Test): boolean; -+//z } -+//z // #endregion Suite "test" event -+//z // #region Suite "run" event -+//z interface Suite extends NodeJS.EventEmitter { -+//z on(event: "run", listener: () => void): this; -+//z once(event: "run", listener: () => void): this; -+//z addListener(event: "run", listener: () => void): this; -+//z removeListener(event: "run", listener: () => void): this; -+//z prependListener(event: "run", listener: () => void): this; -+//z prependOnceListener(event: "run", listener: () => void): this; -+//z emit(name: "run"): boolean; -+//z } -+//z // #endregion Suite "run" event -+//z // #region Suite "pre-require" event -+//z interface Suite extends NodeJS.EventEmitter { -+//z on(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+//z once(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+//z addListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+//z removeListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+//z prependListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+//z prependOnceListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+//z emit(name: "pre-require", context: MochaGlobals, file: string, mocha: Mocha): boolean; -+//z } -+//z // #endregion Suite "pre-require" event -+//z // #region Suite "require" event -+//z interface Suite extends NodeJS.EventEmitter { -+//z on(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -+//z once(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -+//z addListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -+//z removeListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -+//z prependListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -+//z prependOnceListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -+//z emit(name: "require", module: any, file: string, mocha: Mocha): boolean; -+//z } -+//z // #endregion Suite "require" event -+//z // #region Suite "post-require" event -+//z interface Suite extends NodeJS.EventEmitter { -+//z on(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+//z once(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+//z addListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+//z removeListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+//z prependListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+//z prependOnceListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+//z emit(name: "post-require", context: MochaGlobals, file: string, mocha: Mocha): boolean; -+//z } -+//z // #endregion Suite "post-require" event -+//z // #region Suite untyped events -+//z interface Suite extends NodeJS.EventEmitter { -+//z on(event: string, listener: (...args: any[]) => void): this; -+//z once(event: string, listener: (...args: any[]) => void): this; -+//z addListener(event: string, listener: (...args: any[]) => void): this; -+//z removeListener(event: string, listener: (...args: any[]) => void): this; -+//z prependListener(event: string, listener: (...args: any[]) => void): this; -+//z prependOnceListener(event: string, listener: (...args: any[]) => void): this; -+//z emit(name: string, ...args: any[]): boolean; -+//z } -+//z // #endregion Runner untyped events -+ -+//z /** -+//z * Initialize a new `Hook` with the given `title` and callback `fn` -+//z * -+//z * @see https://mochajs.org/api/Hook.html -+//z */ -+//z class Hook extends Runnable { -+//z private _error; -+ -+//z type: "hook"; -+//z originalTitle?: string; // added by Runner -+ -+//z /** -+//z * Get the test `err`. -+//z * -+//z * @see https://mochajs.org/api/Hook.html#error -+//z */ -+//z error(): any; -+ -+//z /** -+//z * Set the test `err`. -+//z * -+//z * @see https://mochajs.org/api/Hook.html#error -+//z */ -+//z error(err: any): void; -+//z } -+ -+//z /** -+//z * An alternative way to define root hooks that works with parallel runs. -+//z * -+//z * Root hooks work with any interface, but the property names do not change. -+//z * In other words, if you are using the tdd interface, suiteSetup maps to beforeAll, and setup maps to beforeEach. -+//z * -+//z * As with other hooks, `this` refers to to the current context object. -+//z * -+//z * @see https://mochajs.org/#root-hook-plugins -+//z */ -+//z interface RootHookObject { -+//z /** -+//z * In serial mode, run after all tests end, once only. -+//z * In parallel mode, run after all tests end, for each file. -+//z */ -+//z afterAll?: Func | AsyncFunc | Func[] | AsyncFunc[]; -+//z /** -+//z * In serial mode (Mocha's default), before all tests begin, once only. -+//z * In parallel mode, run before all tests begin, for each file. -+//z */ -+//z beforeAll?: Func | AsyncFunc | Func[] | AsyncFunc[]; -+//z /** -+//z * In both modes, run after every test. -+//z */ -+//z afterEach?: Func | AsyncFunc | Func[] | AsyncFunc[]; -+//z /** -+//z * In both modes, run before each test. -+//z */ -+//z beforeEach?: Func | AsyncFunc | Func[] | AsyncFunc[]; -+//z } -+ -+//z /** -+//z * Initialize a new `Test` with the given `title` and callback `fn`. -+//z * -+//z * @see https://mochajs.org/api/Test.html -+//z */ -+//z class Test extends Runnable { -+//z type: "test"; -+//z speed?: "slow" | "medium" | "fast"; // added by reporters -+//z err?: Error; // added by reporters -+//z clone(): Test; -+//z } -+ -+//z /** -+//z * Test statistics -+//z */ -+//z interface Stats { -+//z suites: number; -+//z tests: number; -+//z passes: number; -+//z pending: number; -+//z failures: number; -+//z start?: Date; -+//z end?: Date; -+//z duration?: number; -+//z } -+ -+//z type TestInterface = (suite: Suite) => void; -+ -+//z interface ReporterConstructor { -+//z new (runner: Runner, options: MochaOptions): reporters.Base; -+//z } -+ -+//z type Done = (err?: any) => void; -+ -+//z /** -+//z * Callback function used for tests and hooks. -+//z */ -+//z type Func = (this: Context, done: Done) => void; -+ -+//z /** -+//z * Async callback function used for tests and hooks. -+//z */ -+//z type AsyncFunc = (this: Context) => PromiseLike; -+ -+//z /** -+//z * Options to pass to Mocha. -+//z */ -+//z interface MochaOptions { -+//z /** Test interfaces ("bdd", "tdd", "exports", etc.). */ -+//z ui?: Interface; -+ -+//z /** -+//z * Reporter constructor, built-in reporter name, or reporter module path. Defaults to -+//z * `"spec"`. -+//z */ -+//z reporter?: string | ReporterConstructor; -+ -+//z /** Options to pass to the reporter. */ -+//z reporterOptions?: any; -+ -+//z /** Array of accepted globals. */ -+//z globals?: string[]; -+ -+//z /** timeout in milliseconds or time string like '1s'. */ -+//z timeout?: number | string; -+ -+//z /** number of times to retry failed tests. */ -+//z retries?: number; -+ -+//z /** bail on the first test failure. */ -+//z bail?: boolean; -+ -+//z /** milliseconds to wait before considering a test slow. */ -+//z slow?: number; -+ -+//z /** check for global variable leaks. */ -+//z checkLeaks?: boolean; -+ -+//z /** display the full stack trace on failure. */ -+//z fullStackTrace?: boolean; -+ -+//z /** string or regexp to filter tests with. */ -+//z grep?: string | RegExp; -+ -+//z /** Enable growl support. */ -+//z growl?: boolean; -+ -+//z /** Color TTY output from reporter */ -+//z color?: boolean; -+ -+//z /** Use inline diffs rather than +/-. */ -+//z inlineDiffs?: boolean; -+ -+//z /** Do not show diffs at all. */ -+//z hideDiff?: boolean; -+ -+//z /** Run job in parallel */ -+//z parallel?: boolean; -+ -+//z /** Max number of worker processes for parallel runs */ -+//z jobs?: number; -+ -+//z /** Assigns hooks to the root suite */ -+//z rootHooks?: RootHookObject; -+ -+//z asyncOnly?: boolean; -+//z delay?: boolean; -+//z forbidOnly?: boolean; -+//z forbidPending?: boolean; -+//z noHighlighting?: boolean; -+//z allowUncaught?: boolean; -+//z fullTrace?: boolean; -+//z } -+ -+//z interface MochaInstanceOptions extends MochaOptions { -+//z files?: string[]; -+//z } -+ -+//z /** -+//z * Variables added to the global scope by Mocha when run in the CLI. -+//z */ -+//z interface MochaGlobals { -+//z /** -+//z * Execute before running tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#before -+//z */ -+//z before: HookFunction; -+ -+//z /** -+//z * Execute after running tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#after -+//z */ -+//z after: HookFunction; -+ -+//z /** -+//z * Execute before each test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#beforeEach -+//z */ -+//z beforeEach: HookFunction; -+ -+//z /** -+//z * Execute after each test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#afterEach -+//z */ -+//z afterEach: HookFunction; -+ -+//z /** -+//z * Describe a "suite" containing nested suites and tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z describe: SuiteFunction; -+ -+//z /** -+//z * Describe a "suite" containing nested suites and tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z context: SuiteFunction; -+ -+//z /** -+//z * Pending suite. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z xdescribe: PendingSuiteFunction; -+ -+//z /** -+//z * Pending suite. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z xcontext: PendingSuiteFunction; -+ -+//z /** -+//z * Describes a test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z it: TestFunction; -+ -+//z /** -+//z * Describes a test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z specify: TestFunction; -+ -+//z /** -+//z * Describes a pending test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z xit: PendingTestFunction; -+ -+//z /** -+//z * Describes a pending test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z xspecify: PendingTestFunction; -+ -+//z /** -+//z * Execute before running tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#before -+//z */ -+//z suiteSetup: HookFunction; -+ -+//z /** -+//z * Execute after running tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#after -+//z */ -+//z suiteTeardown: HookFunction; -+ -+//z /** -+//z * Execute before each test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#beforeEach -+//z */ -+//z setup: HookFunction; -+ -+//z /** -+//z * Execute after each test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#afterEach -+//z */ -+//z teardown: HookFunction; -+ -+//z /** -+//z * Describe a "suite" containing nested suites and tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z suite: SuiteFunction; -+ -+//z /** -+//z * Describes a test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z test: TestFunction; -+ -+//z run: typeof run; -+//z } -+ -+//z /** -+//z * Third-party declarations that want to add new entries to the `Reporter` union can -+//z * contribute names here. -+//z */ -+//z interface ReporterContributions { -+//z Base: never; -+//z base: never; -+//z Dot: never; -+//z dot: never; -+//z TAP: never; -+//z tap: never; -+//z JSON: never; -+//z json: never; -+//z HTML: never; -+//z html: never; -+//z List: never; -+//z list: never; -+//z Min: never; -+//z min: never; -+//z Spec: never; -+//z spec: never; -+//z Nyan: never; -+//z nyan: never; -+//z XUnit: never; -+//z xunit: never; -+//z Markdown: never; -+//z markdown: never; -+//z Progress: never; -+//z progress: never; -+//z Landing: never; -+//z landing: never; -+//z JSONStream: never; -+//z "json-stream": never; -+//z } -+ -+//z type Reporter = keyof ReporterContributions; -+ -+//z /** -+//z * Third-party declarations that want to add new entries to the `Interface` union can -+//z * contribute names here. -+//z */ -+//z interface InterfaceContributions { -+//z bdd: never; -+//z tdd: never; -+//z qunit: never; -+//z exports: never; -+//z } -+ -+//z type Interface = keyof InterfaceContributions; -+//z } -+ -+//z // #region Test interface augmentations -+ -+//z /** -+//z * Triggers root suite execution. -+//z * -+//z * - _Only available if flag --delay is passed into Mocha._ -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#runWithSuite -+//z */ -+//z declare function run(): void; -+ -+//z /** -+//z * Execute before running tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#before -+//z */ -+//z declare var before: Mocha.HookFunction; -+ -+//z /** -+//z * Execute before running tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#before -+//z */ -+//z declare var suiteSetup: Mocha.HookFunction; -+ -+//z /** -+//z * Execute after running tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#after -+//z */ -+//z declare var after: Mocha.HookFunction; -+ -+//z /** -+//z * Execute after running tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#after -+//z */ -+//z declare var suiteTeardown: Mocha.HookFunction; -+ -+//z /** -+//z * Execute before each test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#beforeEach -+//z */ -+//z declare var beforeEach: Mocha.HookFunction; -+ -+//z /** -+//z * Execute before each test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#beforeEach -+//z */ -+//z declare var setup: Mocha.HookFunction; -+ -+//z /** -+//z * Execute after each test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#afterEach -+//z */ -+//z declare var afterEach: Mocha.HookFunction; -+ -+//z /** -+//z * Execute after each test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z * -+//z * @see https://mochajs.org/api/global.html#afterEach -+//z */ -+//z declare var teardown: Mocha.HookFunction; -+ -+//z /** -+//z * Describe a "suite" containing nested suites and tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z declare var describe: Mocha.SuiteFunction; -+ -+//z /** -+//z * Describe a "suite" containing nested suites and tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z declare var context: Mocha.SuiteFunction; -+ -+//z /** -+//z * Describe a "suite" containing nested suites and tests. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z declare var suite: Mocha.SuiteFunction; -+ -+//z /** -+//z * Pending suite. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z declare var xdescribe: Mocha.PendingSuiteFunction; -+ -+//z /** -+//z * Pending suite. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z declare var xcontext: Mocha.PendingSuiteFunction; -+ -+//z /** -+//z * Describes a test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z declare var it: Mocha.TestFunction; -+ -+//z /** -+//z * Describes a test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z declare var specify: Mocha.TestFunction; -+ -+//z /** -+//z * Describes a test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z declare var test: Mocha.TestFunction; -+ -+//z /** -+//z * Describes a pending test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z declare var xit: Mocha.PendingTestFunction; -+ -+//z /** -+//z * Describes a pending test case. -+//z * -+//z * - _Only available when invoked via the mocha CLI._ -+//z */ -+//z declare var xspecify: Mocha.PendingTestFunction; -+ -+//z // #endregion Test interface augmentations -+ -+//z // #region Reporter augmentations -+ -+//z // Forward declaration for `HTMLLIElement` from lib.dom.d.ts. -+//z // Required by Mocha.reporters.HTML. -+//z // NOTE: Mocha *must not* have a direct dependency on DOM types. -+//z // tslint:disable-next-line no-empty-interface -+//z interface HTMLLIElement { } -+ -+//z // Augments the DOM `Window` object when lib.dom.d.ts is loaded. -+//z // tslint:disable-next-line no-empty-interface -+//z interface Window extends Mocha.MochaGlobals { } -+ -+//z declare namespace NodeJS { -+//z // Forward declaration for `NodeJS.EventEmitter` from node.d.ts. -+//z // Required by Mocha.Runnable, Mocha.Runner, and Mocha.Suite. -+//z // NOTE: Mocha *must not* have a direct dependency on @types/node. -+//z // tslint:disable-next-line no-empty-interface -+//z interface EventEmitter { } -+ -+//z // Augments NodeJS's `global` object when node.d.ts is loaded -+//z // tslint:disable-next-line no-empty-interface -+//z interface Global extends Mocha.MochaGlobals { } -+//z } -+ -+//z // #endregion Reporter augmentations -+ -+//z // #region Browser augmentations -+ -+//z /** -+//z * Mocha global. -+//z * -+//z * - _Only supported in the browser._ -+//z */ -+//z declare const mocha: BrowserMocha; -+ -+//z interface BrowserMocha extends Mocha { -+//z /** -+//z * Function to allow assertion libraries to throw errors directly into mocha. -+//z * This is useful when running tests in a browser because window.onerror will -+//z * only receive the 'message' attribute of the Error. -+//z * -+//z * - _Only supported in the browser._ -+//z */ -+//z throwError(err: any): never; -+ -+//z /** -+//z * Setup mocha with the given settings options. -+//z * -+//z * - _Only supported in the browser._ -+//z */ -+//z setup(opts?: Mocha.Interface | Mocha.MochaOptions): this; -+//z } -+ -+//z // #endregion Browser augmentations -+ -+//z declare module "mocha" { -+//z export = Mocha; -+//z } -+ -+//z declare module "mocha/lib/ms" { -+//z export = milliseconds; -+//z /** -+//z * Parse the given `str` and return milliseconds. -+//z * -+//z * @see {@link https://mochajs.org/api/module-milliseconds.html} -+//z * @see {@link https://mochajs.org/api/module-milliseconds.html#~parse} -+//z */ -+//z function milliseconds(val: string): number; -+ -+//z /** -+//z * Format for `ms`. -+//z * -+//z * @see {@link https://mochajs.org/api/module-milliseconds.html} -+//z * @see {@link https://mochajs.org/api/module-milliseconds.html#~format} -+//z */ -+//z function milliseconds(val: number): string; -+//z } -+ -+//z declare module "mocha/lib/interfaces/common" { -+//z export = common; -+ -+//z function common(suites: Mocha.Suite[], context: Mocha.MochaGlobals, mocha: Mocha): common.CommonFunctions; -+ -+//z namespace common { -+//z interface CommonFunctions { -+//z /** -+//z * This is only present if flag --delay is passed into Mocha. It triggers -+//z * root suite execution. -+//z */ -+//z runWithSuite(suite: Mocha.Suite): () => void; -+ -+//z /** -+//z * Execute before running tests. -+//z */ -+//z before(fn?: Mocha.Func | Mocha.AsyncFunc): void; -+ -+//z /** -+//z * Execute before running tests. -+//z */ -+//z before(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; -+ -+//z /** -+//z * Execute after running tests. -+//z */ -+//z after(fn?: Mocha.Func | Mocha.AsyncFunc): void; -+ -+//z /** -+//z * Execute after running tests. -+//z */ -+//z after(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; -+ -+//z /** -+//z * Execute before each test case. -+//z */ -+//z beforeEach(fn?: Mocha.Func | Mocha.AsyncFunc): void; -+ -+//z /** -+//z * Execute before each test case. -+//z */ -+//z beforeEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; -+ -+//z /** -+//z * Execute after each test case. -+//z */ -+//z afterEach(fn?: Mocha.Func | Mocha.AsyncFunc): void; -+ -+//z /** -+//z * Execute after each test case. -+//z */ -+//z afterEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; -+ -+//z suite: SuiteFunctions; -+//z test: TestFunctions; -+//z } -+ -+//z interface CreateOptions { -+//z /** Title of suite */ -+//z title: string; -+ -+//z /** Suite function */ -+//z fn?: (this: Mocha.Suite) => void; -+ -+//z /** Is suite pending? */ -+//z pending?: boolean; -+ -+//z /** Filepath where this Suite resides */ -+//z file?: string; -+ -+//z /** Is suite exclusive? */ -+//z isOnly?: boolean; -+//z } -+ -+//z interface SuiteFunctions { -+//z /** -+//z * Create an exclusive Suite; convenience function -+//z */ -+//z only(opts: CreateOptions): Mocha.Suite; -+ -+//z /** -+//z * Create a Suite, but skip it; convenience function -+//z */ -+//z skip(opts: CreateOptions): Mocha.Suite; -+ -+//z /** -+//z * Creates a suite. -+//z */ -+//z create(opts: CreateOptions): Mocha.Suite; -+//z } -+ -+//z interface TestFunctions { -+//z /** -+//z * Exclusive test-case. -+//z */ -+//z only(mocha: Mocha, test: Mocha.Test): Mocha.Test; -+ -+//z /** -+//z * Pending test case. -+//z */ -+//z skip(title: string): void; -+ -+//z /** -+//z * Number of retry attempts -+//z */ -+//z retries(n: number): void; -+//z } -+//z } -+//z } diff --git a/patches/@types+mocha+8.2.2.dev.patch b/patches/@types+mocha+8.2.2.dev.patch new file mode 100644 index 000000000000..4255ec648827 --- /dev/null +++ b/patches/@types+mocha+8.2.2.dev.patch @@ -0,0 +1,5727 @@ +diff --git a/node_modules/@types/mocha/index.d.ts b/node_modules/@types/mocha/index.d.ts +index 52a15fa..485198f 100644 +--- a/node_modules/@types/mocha/index.d.ts ++++ b/node_modules/@types/mocha/index.d.ts +@@ -1,2861 +1,2861 @@ +-// Type definitions for mocha 8.2 +-// Project: https://mochajs.org +-// Definitions by: Kazi Manzur Rashid +-// otiai10 +-// Vadim Macagon +-// Andrew Bradley +-// Dmitrii Sorin +-// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +-// TypeScript Version: 2.1 +- +-/** +- * Mocha API +- * +- * @see https://mochajs.org/api/mocha +- */ +-declare class Mocha { +- private _growl; +- private _reporter; +- private _ui; +- +- constructor(options?: Mocha.MochaOptions); +- +- suite: Mocha.Suite; +- files: string[]; +- options: Mocha.MochaInstanceOptions; +- +- /** +- * Add test `file`. +- * +- * @see https://mochajs.org/api/mocha#addFile +- */ +- addFile(file: string): this; +- +- /** +- * Enable or disable bailing on the first failure. +- * +- * @see https://mochajs.org/api/mocha#bail +- */ +- bail(bail?: boolean): this; +- +- /** +- * Manually dispose this mocha instance. Mark this instance as `disposed` and unable to run more tests. +- * It also removes function references to tests functions and hooks, so variables trapped in closures can be cleaned by the garbage collector. +- * +- * @see https://mochajs.org/api/mocha#dispose +- */ +- dispose(): void; +- +- /** +- * Set reporter to one of the built-in reporters. +- * +- * @see https://mochajs.org/api/mocha#reporter +- */ +- reporter(reporter: Mocha.Reporter, reporterOptions?: any): this; +- +- /** +- * Set reporter to the provided constructor, one of the built-in reporters, or loads a reporter +- * from a module path. Defaults to `"spec"`. +- * +- * @see https://mochajs.org/api/mocha#reporter +- */ +- reporter(reporter?: string | Mocha.ReporterConstructor, reporterOptions?: any): this; +- +- /** +- * Set test UI to one of the built-in test interfaces. +- * +- * @see https://mochajs.org/api/mocha#ui +- */ +- ui(name: Mocha.Interface): this; +- +- /** +- * Set test UI to one of the built-in test interfaces or loads a test interface from a module +- * path. Defaults to `"bdd"`. +- * +- * @see https://mochajs.org/api/mocha#ui +- */ +- ui(name?: string): this; +- +- /** +- * Escape string and add it to grep as a RegExp. +- * +- * @see https://mochajs.org/api/mocha#fgrep +- */ +- fgrep(str: string): this; +- +- /** +- * Add regexp to grep, if `re` is a string it is escaped. +- * +- * @see https://mochajs.org/api/mocha#grep +- */ +- grep(re: string | RegExp): this; +- +- /** +- * Invert `.grep()` matches. +- * +- * @see https://mochajs.org/api/mocha#invert +- */ +- invert(): this; +- +- /** +- * Enable global leak checking. +- * +- * @see https://mochajs.org/api/mocha#checkLeaks +- */ +- checkLeaks(): this; +- +- /** +- * Display long stack-trace on failing +- * +- * @see https://mochajs.org/api/mocha#fullTrace +- */ +- fullTrace(): this; +- +- /** +- * Enable growl support. +- * +- * @see https://mochajs.org/api/mocha#growl +- */ +- growl(): this; +- +- /** +- * Ignore `globals` array or string. +- * +- * @see https://mochajs.org/api/mocha#globals +- */ +- globals(globals: string | ReadonlyArray): this; +- +- /** +- * Set the timeout in milliseconds. +- * +- * @see https://mochajs.org/api/mocha#timeout +- */ +- timeout(timeout: string | number): this; +- +- /** +- * Set the number of times to retry failed tests. +- * +- * @see https://mochajs.org/api/mocha#retries +- */ +- retries(n: number): this; +- +- /** +- * Set slowness threshold in milliseconds. +- * +- * @see https://mochajs.org/api/mocha#slow +- */ +- slow(slow: string | number): this; +- +- /** +- * Makes all tests async (accepting a callback) +- * +- * @see https://mochajs.org/api/mocha#asyncOnly. +- */ +- asyncOnly(): this; +- +- /** +- * Disable syntax highlighting (in browser). +- * +- * @see https://mochajs.org/api/mocha#noHighlighting +- */ +- noHighlighting(): this; +- +- /** +- * Enable uncaught errors to propagate (in browser). +- * +- * @see https://mochajs.org/api/mocha#allowUncaught +- */ +- allowUncaught(): boolean; +- +- /** +- * Delay root suite execution. +- * +- * @see https://mochajs.org/api/mocha#delay +- */ +- delay(): boolean; +- +- /** +- * Tests marked only fail the suite +- * +- * @see https://mochajs.org/api/mocha#forbidOnly +- */ +- forbidOnly(): boolean; +- +- /** +- * Pending tests and tests marked skip fail the suite +- * +- * @see https://mochajs.org/api/mocha#forbidPending +- */ +- forbidPending(): boolean; +- +- /** +- * Run tests and invoke `fn()` when complete. +- * +- * Note that `run` relies on Node's `require` to execute +- * the test interface functions and will be subject to the +- * cache - if the files are already in the `require` cache, +- * they will effectively be skipped. Therefore, to run tests +- * multiple times or to run tests in files that are already +- * in the `require` cache, make sure to clear them from the +- * cache first in whichever manner best suits your needs. +- * +- * @see https://mochajs.org/api/mocha#run +- */ +- run(fn?: (failures: number) => void): Mocha.Runner; +- +- /** +- * Loads ESM (and CJS) test files asynchronously. +- * +- * @see https://mochajs.org/api/mocha#loadFilesAsync +- */ +- loadFilesAsync(): Promise; +- +- /** +- * Load registered files. +- * +- * @see https://mochajs.org/api/mocha#loadFiles +- */ +- protected loadFiles(fn?: () => void): void; +- +- /** +- * Unloads `files` from Node's `require` cache. +- * +- * This allows required files to be "freshly" reloaded, providing the ability +- * to reuse a Mocha instance programmatically. +- * Note: does not clear ESM module files from the cache +- */ +- unloadFiles(): this; +- +- /** +- * Toggles parallel mode. +- * +- * Must be run before calling `run`. Changes the `Runner` class to +- * use; also enables lazy file loading if not already done so. +- * +- * @see https://mochajs.org/api/mocha#parallelMode +- */ +- parallelMode(enabled?: boolean): this; +- +- /** +- * Assigns hooks to the root suite. +- * +- * @see https://mochajs.org/api/mocha#rootHooks +- */ +- rootHooks(hooks: Mocha.RootHookObject): this; +- +- /** +- * Configures one or more global setup fixtures. +- * If given no parameters, unsets any previously-set fixtures. +- * +- * @see https://mochajs.org/api/mocha#globalSetup +- */ +- globalSetup: Mocha.HookFunction; +- +- /** +- * Configures one or more global teardown fixtures. +- * If given no parameters, unsets any previously-set fixtures. +- * +- * @see https://mochajs.org/api/mocha#globalTeardown +- */ +- globalTeardown: Mocha.HookFunction; +- +- /** +- * Returns `true` if one or more global setup fixtures have been supplied +- * +- * @see https://mochajs.org/api/mocha#hasGlobalSetupFixtures +- */ +- hasGlobalSetupFixtures(): boolean; +- +- /** +- * Returns `true` if one or more global teardown fixtures have been supplied +- * +- * @see https://mochajs.org/api/mocha#hasGlobalTeardownFixtures +- */ +- hasGlobalTeardownFixtures(): boolean; +- +- /** +- * Toggle execution of any global setup fixture(s) +- * +- * @see https://mochajs.org/api/mocha#enableGlobalSetup +- */ +- enableGlobalSetup(enabled: boolean): this; +- +- /** +- * Toggle execution of any global teardown fixture(s) +- * +- * @see https://mochajs.org/api/mocha#enableGlobalTeardown +- */ +- enableGlobalTeardown(enabled: boolean): this; +-} +- +-declare namespace Mocha { +- namespace utils { +- /** +- * Compute a slug from the given `str`. +- * +- * @see https://mochajs.org/api/module-utils.html#.slug +- */ +- function slug(str: string): string; +- +- /** +- * Strip the function definition from `str`, and re-indent for pre whitespace. +- * +- * @see https://mochajs.org/api/module-utils.html#.clean +- */ +- function clean(str: string): string; +- +- /** +- * Highlight the given string of `js`. +- */ +- function highlight(js: string): string; +- +- /** +- * Takes some variable and asks `Object.prototype.toString()` what it thinks it is. +- */ +- function type(value: any): string; +- +- /** +- * Stringify `value`. Different behavior depending on type of value: +- * +- * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively. +- * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes. +- * - If `value` is an *empty* object, function, or array, returns `'{}'`, `'[Function]'`, or `'[]'` respectively. +- * - If `value` has properties, call canonicalize} on it, then return result of `JSON.stringify()` +- * +- * @see https://mochajs.org/api/module-utils.html#.stringify +- */ +- function stringify(value: any): string; +- +- /** +- * Return a new Thing that has the keys in sorted order. Recursive. +- * +- * If the Thing... +- * - has already been seen, return string `'[Circular]'` +- * - is `undefined`, return string `'[undefined]'` +- * - is `null`, return value `null` +- * - is some other primitive, return the value +- * - is not a primitive or an `Array`, `Object`, or `Function`, return the value of the Thing's `toString()` method +- * - is a non-empty `Array`, `Object`, or `Function`, return the result of calling this function again. +- * - is an empty `Array`, `Object`, or `Function`, returns `'[]'`, `'{}'`, or `'[Function]'` respectively. +- * +- * @see https://mochajs.org/api/module-utils.html#.canonicalize +- */ +- function canonicalize(value: any, stack: any[], typeHint: string): any; +- +- /** +- * Lookup file names at the given `path`. +- * +- * @see https://mochajs.org/api/Mocha.utils.html#.exports.lookupFiles +- */ +- function lookupFiles(filepath: string, extensions?: string[], recursive?: boolean): string[]; +- +- /** +- * Generate an undefined error with a message warning the user. +- * +- * @see https://mochajs.org/api/module-utils.html#.undefinedError +- */ +- function undefinedError(): Error; +- +- /** +- * Generate an undefined error if `err` is not defined. +- * +- * @see https://mochajs.org/api/module-utils.html#.getError +- */ +- function getError(err: Error | undefined): Error; +- +- /** +- * When invoking this function you get a filter function that get the Error.stack as an +- * input, and return a prettify output. (i.e: strip Mocha and internal node functions from +- * stack trace). +- * +- * @see https://mochajs.org/api/module-utils.html#.stackTraceFilter +- */ +- function stackTraceFilter(): (stack: string) => string; +- } +- +- namespace interfaces { +- function bdd(suite: Suite): void; +- function tdd(suite: Suite): void; +- function qunit(suite: Suite): void; +- function exports(suite: Suite): void; +- } +- +- // #region Test interface augmentations +- +- interface HookFunction { +- /** +- * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the +- * function is used as the name of the hook. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (fn: Func): void; +- +- /** +- * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the +- * function is used as the name of the hook. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (fn: AsyncFunc): void; +- +- /** +- * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (name: string, fn?: Func): void; +- +- /** +- * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (name: string, fn?: AsyncFunc): void; +- } +- +- interface SuiteFunction { +- /** +- * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing +- * nested suites. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string, fn: (this: Suite) => void): Suite; +- +- /** +- * [qunit] Describe a "suite" with the given `title`. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string): Suite; +- +- /** +- * [bdd, tdd, qunit] Indicates this suite should be executed exclusively. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- only: ExclusiveSuiteFunction; +- +- /** +- * [bdd, tdd] Indicates this suite should not be executed. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- skip: PendingSuiteFunction; +- } +- +- interface ExclusiveSuiteFunction { +- /** +- * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing +- * nested suites. Indicates this suite should be executed exclusively. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string, fn: (this: Suite) => void): Suite; +- +- /** +- * [qunit] Describe a "suite" with the given `title`. Indicates this suite should be executed +- * exclusively. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string): Suite; +- } +- +- /** +- * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing +- * nested suites. Indicates this suite should not be executed. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @returns [bdd] `Suite` +- * @returns [tdd] `void` +- */ +- interface PendingSuiteFunction { +- (title: string, fn: (this: Suite) => void): Suite | void; +- } +- +- interface TestFunction { +- /** +- * Describe a specification or test-case with the given callback `fn` acting as a thunk. +- * The name of the function is used as the name of the test. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (fn: Func): Test; +- +- /** +- * Describe a specification or test-case with the given callback `fn` acting as a thunk. +- * The name of the function is used as the name of the test. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (fn: AsyncFunc): Test; +- +- /** +- * Describe a specification or test-case with the given `title` and callback `fn` acting +- * as a thunk. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string, fn?: Func): Test; +- +- /** +- * Describe a specification or test-case with the given `title` and callback `fn` acting +- * as a thunk. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string, fn?: AsyncFunc): Test; +- +- /** +- * Indicates this test should be executed exclusively. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- only: ExclusiveTestFunction; +- +- /** +- * Indicates this test should not be executed. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- skip: PendingTestFunction; +- +- /** +- * Number of attempts to retry. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- retries(n: number): void; +- } +- +- interface ExclusiveTestFunction { +- /** +- * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` +- * acting as a thunk. The name of the function is used as the name of the test. Indicates +- * this test should be executed exclusively. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (fn: Func): Test; +- +- /** +- * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` +- * acting as a thunk. The name of the function is used as the name of the test. Indicates +- * this test should be executed exclusively. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (fn: AsyncFunc): Test; +- +- /** +- * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and +- * callback `fn` acting as a thunk. Indicates this test should be executed exclusively. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string, fn?: Func): Test; +- +- /** +- * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and +- * callback `fn` acting as a thunk. Indicates this test should be executed exclusively. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string, fn?: AsyncFunc): Test; +- } +- +- interface PendingTestFunction { +- /** +- * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` +- * acting as a thunk. The name of the function is used as the name of the test. Indicates +- * this test should not be executed. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (fn: Func): Test; +- +- /** +- * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` +- * acting as a thunk. The name of the function is used as the name of the test. Indicates +- * this test should not be executed. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (fn: AsyncFunc): Test; +- +- /** +- * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and +- * callback `fn` acting as a thunk. Indicates this test should not be executed. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string, fn?: Func): Test; +- +- /** +- * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and +- * callback `fn` acting as a thunk. Indicates this test should not be executed. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string, fn?: AsyncFunc): Test; +- } +- +- /** +- * Execute after each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#afterEach +- */ +- let afterEach: HookFunction; +- +- /** +- * Execute after running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#after +- */ +- let after: HookFunction; +- +- /** +- * Execute before each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#beforeEach +- */ +- let beforeEach: HookFunction; +- +- /** +- * Execute before running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#before +- */ +- let before: HookFunction; +- +- /** +- * Describe a "suite" containing nested suites and tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- let describe: SuiteFunction; +- +- /** +- * Describes a test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- let it: TestFunction; +- +- /** +- * Describes a pending test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- let xit: PendingTestFunction; +- +- /** +- * Execute before each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#beforeEach +- */ +- let setup: HookFunction; +- +- /** +- * Execute before running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#before +- */ +- let suiteSetup: HookFunction; +- +- /** +- * Execute after running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#after +- */ +- let suiteTeardown: HookFunction; +- +- /** +- * Describe a "suite" containing nested suites and tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- let suite: SuiteFunction; +- +- /** +- * Execute after each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#afterEach +- */ +- let teardown: HookFunction; +- +- /** +- * Describes a test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- let test: TestFunction; +- +- /** +- * Triggers root suite execution. +- * +- * - _Only available if flag --delay is passed into Mocha._ +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#runWithSuite +- */ +- function run(): void; +- +- // #endregion Test interface augmentations +- +- namespace reporters { +- /** +- * Initialize a new `Base` reporter. +- * +- * All other reporters generally inherit from this reporter, providing stats such as test duration, +- * number of tests passed / failed, etc. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Base.html +- */ +- class Base { +- constructor(runner: Runner, options?: MochaOptions); +- +- /** +- * Test run statistics +- */ +- stats: Stats; +- +- /** +- * Test failures +- */ +- failures: Test[]; +- +- /** +- * The configured runner +- */ +- runner: Runner; +- +- /** +- * Output common epilogue used by many of the bundled reporters. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Base.html#.Base#epilogue +- */ +- epilogue(): void; +- +- done?(failures: number, fn?: (failures: number) => void): void; +- } +- +- namespace Base { +- /** +- * Enables coloring by default +- * +- * @see https://mochajs.org/api/module-base#.useColors +- */ +- let useColors: boolean; +- +- /** +- * Inline diffs instead of +/- +- * +- * @see https://mochajs.org/api/module-base#.inlineDiffs +- */ +- let inlineDiffs: boolean; +- +- /** +- * Default color map +- * +- * @see https://mochajs.org/api/module-base#.colors +- */ +- const colors: ColorMap; +- +- /** +- * Default color map +- * +- * @see https://mochajs.org/api/module-base#.colors +- */ +- interface ColorMap { +- // added by Base +- pass: number; +- fail: number; +- "bright pass": number; +- "bright fail": number; +- "bright yellow": number; +- pending: number; +- suite: number; +- "error title": number; +- "error message": number; +- "error stack": number; +- checkmark: number; +- fast: number; +- medium: number; +- slow: number; +- green: number; +- light: number; +- "diff gutter": number; +- "diff added": number; +- "diff removed": number; +- +- // added by Progress +- progress: number; +- +- // added by Landing +- plane: number; +- "plane crash": number; +- runway: number; +- +- [key: string]: number; +- } +- +- /** +- * Default symbol map +- * +- * @see https://mochajs.org/api/module-base#.symbols +- */ +- const symbols: SymbolMap; +- +- /** +- * Default symbol map +- * +- * @see https://mochajs.org/api/module-base#.symbols +- */ +- interface SymbolMap { +- ok: string; +- err: string; +- dot: string; +- comma: string; +- bang: string; +- [key: string]: string; +- } +- +- /** +- * Color `str` with the given `type` (from `colors`) +- * +- * @see https://mochajs.org/api/module-base#.color +- */ +- function color(type: string, str: string): string; +- +- /** +- * Expose terminal window size +- * +- * @see https://mochajs.org/api/module-base#.window +- */ +- const window: { +- width: number; +- }; +- +- /** +- * ANSI TTY control sequences common among reporters. +- * +- * @see https://mochajs.org/api/module-base#.cursor +- */ +- namespace cursor { +- /** +- * Hides the cursor +- */ +- function hide(): void; +- +- /** +- * Shows the cursor +- */ +- function show(): void; +- +- /** +- * Deletes the current line +- */ +- function deleteLine(): void; +- +- /** +- * Moves to the beginning of the line +- */ +- function beginningOfLine(): void; +- +- /** +- * Clears the line and moves to the beginning of the line. +- */ +- function CR(): void; +- } +- +- /** +- * Returns a diff between two strings with colored ANSI output. +- * +- * @see https://mochajs.org/api/module-base#.generateDiff +- */ +- function generateDiff(actual: string, expected: string): string; +- +- /** +- * Output the given `failures` as a list. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Base.html#.exports.list1 +- */ +- function list(failures: Test[]): void; +- } +- +- /** +- * Initialize a new `Dot` matrix test reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Dot.html +- */ +- class Dot extends Base { +- } +- +- /** +- * Initialize a new `Doc` reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Doc.html +- */ +- class Doc extends Base { +- } +- +- /** +- * Initialize a new `TAP` test reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.TAP.html +- */ +- class TAP extends Base { +- } +- +- /** +- * Initialize a new `JSON` reporter +- * +- * @see https://mochajs.org/api/Mocha.reporters.JSON.html +- */ +- class JSON extends Base { +- } +- +- /** +- * Initialize a new `HTML` reporter. +- * +- * - _This reporter cannot be used on the console._ +- * +- * @see https://mochajs.org/api/Mocha.reporters.HTML.html +- */ +- class HTML extends Base { +- /** +- * Provide suite URL. +- * +- * @see https://mochajs.org/api/Mocha.reporters.HTML.html#suiteURL +- */ +- suiteURL(suite: Suite): string; +- +- /** +- * Provide test URL. +- * +- * @see https://mochajs.org/api/Mocha.reporters.HTML.html#testURL +- */ +- testURL(test: Test): string; +- +- /** +- * Adds code toggle functionality for the provided test's list element. +- * +- * @see https://mochajs.org/api/Mocha.reporters.HTML.html#addCodeToggle +- */ +- addCodeToggle(el: HTMLLIElement, contents: string): void; +- } +- +- /** +- * Initialize a new `List` test reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.List.html +- */ +- class List extends Base { +- } +- +- /** +- * Initialize a new `Min` minimal test reporter (best used with --watch). +- * +- * @see https://mochajs.org/api/Mocha.reporters.Min.html +- */ +- class Min extends Base { +- } +- +- /** +- * Initialize a new `Spec` test reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Spec.html +- */ +- class Spec extends Base { +- } +- +- /** +- * Initialize a new `NyanCat` test reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Nyan.html +- */ +- class Nyan extends Base { +- private colorIndex; +- private numberOfLines; +- private rainbowColors; +- private scoreboardWidth; +- private tick; +- private trajectories; +- private trajectoryWidthMax; +- private draw; +- private drawScoreboard; +- private appendRainbow; +- private drawRainbow; +- private drawNyanCat; +- private face; +- private cursorUp; +- private cursorDown; +- private generateColors; +- private rainbowify; +- } +- +- /** +- * Initialize a new `XUnit` test reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.XUnit.html +- */ +- class XUnit extends Base { +- constructor(runner: Runner, options?: XUnit.MochaOptions); +- +- /** +- * Override done to close the stream (if it's a file). +- * +- * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#done +- */ +- done(failures: number, fn: (failures: number) => void): void; +- +- /** +- * Write out the given line. +- * +- * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#write +- */ +- write(line: string): void; +- +- /** +- * Output tag for the given `test.` +- * +- * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#test +- */ +- test(test: Test): void; +- } +- +- namespace XUnit { +- interface MochaOptions extends Mocha.MochaOptions { +- reporterOptions?: ReporterOptions; +- } +- +- interface ReporterOptions { +- output?: string; +- suiteName?: string; +- } +- } +- +- /** +- * Initialize a new `Markdown` test reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Markdown.html +- */ +- class Markdown extends Base { +- } +- +- /** +- * Initialize a new `Progress` bar test reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Progress.html +- */ +- class Progress extends Base { +- constructor(runner: Runner, options?: Progress.MochaOptions); +- } +- +- namespace Progress { +- interface MochaOptions extends Mocha.MochaOptions { +- reporterOptions?: ReporterOptions; +- } +- +- interface ReporterOptions { +- open?: string; +- complete?: string; +- incomplete?: string; +- close?: string; +- verbose?: boolean; +- } +- } +- +- /** +- * Initialize a new `Landing` reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Landing.html +- */ +- class Landing extends Base { +- } +- +- /** +- * Initialize a new `JSONStream` test reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.JSONStream.html +- */ +- class JSONStream extends Base { +- } +- +- // value-only aliases +- const base: typeof Base; +- const dot: typeof Dot; +- const doc: typeof Doc; +- const tap: typeof TAP; +- const json: typeof JSON; +- const html: typeof HTML; +- const list: typeof List; +- const spec: typeof Spec; +- const nyan: typeof Nyan; +- const xunit: typeof XUnit; +- const markdown: typeof Markdown; +- const progress: typeof Progress; +- const landing: typeof Landing; +- // NOTE: not possible to type this correctly: +- // const "json-stream": typeof JSONStream; +- } +- +- /** +- * Initialize a new `Runnable` with the given `title` and callback `fn`. +- * +- * @see https://mochajs.org/api/Runnable.html +- */ +- class Runnable { +- private _slow; +- private _retries; +- private _currentRetry; +- private _timeout; +- private _timeoutError; +- +- constructor(title: string, fn?: Func | AsyncFunc); +- +- title: string; +- fn: Func | AsyncFunc | undefined; +- body: string; +- async: boolean; +- sync: boolean; +- timedOut: boolean; +- pending: boolean; +- duration?: number; +- parent?: Suite; +- state?: "failed" | "passed"; +- timer?: any; +- ctx?: Context; +- callback?: Done; +- allowUncaught?: boolean; +- file?: string; +- +- /** +- * Get test timeout. +- * +- * @see https://mochajs.org/api/Runnable.html#timeout +- */ +- timeout(): number; +- +- /** +- * Set test timeout. +- * +- * @see https://mochajs.org/api/Runnable.html#timeout +- */ +- timeout(ms: string | number): this; +- +- /** +- * Get test slowness threshold. +- * +- * @see https://mochajs.org/api/Runnable.html#slow +- */ +- slow(): number; +- +- /** +- * Set test slowness threshold. +- * +- * @see https://mochajs.org/api/Runnable.html#slow +- */ +- slow(ms: string | number): this; +- +- /** +- * Halt and mark as pending. +- */ +- skip(): never; +- +- /** +- * Check if this runnable or its parent suite is marked as pending. +- * +- * @see https://mochajs.org/api/Runnable.html#isPending +- */ +- isPending(): boolean; +- +- /** +- * Return `true` if this Runnable has failed. +- */ +- isFailed(): boolean; +- +- /** +- * Return `true` if this Runnable has passed. +- */ +- isPassed(): boolean; +- +- /** +- * Set or get number of retries. +- * +- * @see https://mochajs.org/api/Runnable.html#retries +- */ +- retries(): number; +- +- /** +- * Set or get number of retries. +- * +- * @see https://mochajs.org/api/Runnable.html#retries +- */ +- retries(n: number): void; +- +- /** +- * Set or get current retry +- * +- * @see https://mochajs.org/api/Runnable.html#currentRetry +- */ +- protected currentRetry(): number; +- +- /** +- * Set or get current retry +- * +- * @see https://mochajs.org/api/Runnable.html#currentRetry +- */ +- protected currentRetry(n: number): void; +- +- /** +- * Return the full title generated by recursively concatenating the parent's full title. +- */ +- fullTitle(): string; +- +- /** +- * Return the title path generated by concatenating the parent's title path with the title. +- */ +- titlePath(): string[]; +- +- /** +- * Clear the timeout. +- * +- * @see https://mochajs.org/api/Runnable.html#clearTimeout +- */ +- clearTimeout(): void; +- +- /** +- * Inspect the runnable void of private properties. +- * +- * @see https://mochajs.org/api/Runnable.html#inspect +- */ +- inspect(): string; +- +- /** +- * Reset the timeout. +- * +- * @see https://mochajs.org/api/Runnable.html#resetTimeout +- */ +- resetTimeout(): void; +- +- /** +- * Get a list of whitelisted globals for this test run. +- * +- * @see https://mochajs.org/api/Runnable.html#globals +- */ +- globals(): string[]; +- +- /** +- * Set a list of whitelisted globals for this test run. +- * +- * @see https://mochajs.org/api/Runnable.html#globals +- */ +- globals(globals: ReadonlyArray): void; +- +- /** +- * Run the test and invoke `fn(err)`. +- * +- * @see https://mochajs.org/api/Runnable.html#run +- */ +- run(fn: Done): void; +- } +- +- // #region Runnable "error" event +- interface Runnable extends NodeJS.EventEmitter { +- on(event: "error", listener: (error: any) => void): this; +- once(event: "error", listener: (error: any) => void): this; +- addListener(event: "error", listener: (error: any) => void): this; +- removeListener(event: "error", listener: (error: any) => void): this; +- prependListener(event: "error", listener: (error: any) => void): this; +- prependOnceListener(event: "error", listener: (error: any) => void): this; +- emit(name: "error", error: any): boolean; +- } +- // #endregion Runnable "error" event +- // #region Runnable untyped events +- interface Runnable extends NodeJS.EventEmitter { +- on(event: string, listener: (...args: any[]) => void): this; +- once(event: string, listener: (...args: any[]) => void): this; +- addListener(event: string, listener: (...args: any[]) => void): this; +- removeListener(event: string, listener: (...args: any[]) => void): this; +- prependListener(event: string, listener: (...args: any[]) => void): this; +- prependOnceListener(event: string, listener: (...args: any[]) => void): this; +- emit(name: string, ...args: any[]): boolean; +- } +- // #endregion Runnable untyped events +- +- /** +- * Test context +- * +- * @see https://mochajs.org/api/module-Context.html#~Context +- */ +- class Context { +- private _runnable; +- +- test?: Runnable; +- currentTest?: Test; +- +- /** +- * Get the context `Runnable`. +- */ +- runnable(): Runnable; +- +- /** +- * Set the context `Runnable`. +- */ +- runnable(runnable: Runnable): this; +- +- /** +- * Get test timeout. +- */ +- timeout(): number; +- +- /** +- * Set test timeout. +- */ +- timeout(ms: string | number): this; +- +- /** +- * Get test slowness threshold. +- */ +- slow(): number; +- +- /** +- * Set test slowness threshold. +- */ +- slow(ms: string | number): this; +- +- /** +- * Mark a test as skipped. +- */ +- skip(): never; +- +- /** +- * Get the number of allowed retries on failed tests. +- */ +- retries(): number; +- +- /** +- * Set the number of allowed retries on failed tests. +- */ +- retries(n: number): this; +- +- [key: string]: any; +- } +- +- interface RunnerConstants { +- readonly EVENT_HOOK_BEGIN: 'hook'; +- readonly EVENT_HOOK_END: 'hook end'; +- readonly EVENT_RUN_BEGIN: 'start'; +- readonly EVENT_DELAY_BEGIN: 'waiting'; +- readonly EVENT_DELAY_END: 'ready'; +- readonly EVENT_RUN_END: 'end'; +- readonly EVENT_SUITE_BEGIN: 'suite'; +- readonly EVENT_SUITE_END: 'suite end'; +- readonly EVENT_TEST_BEGIN: 'test'; +- readonly EVENT_TEST_END: 'test end'; +- readonly EVENT_TEST_FAIL: 'fail'; +- readonly EVENT_TEST_PASS: 'pass'; +- readonly EVENT_TEST_PENDING: 'pending'; +- readonly EVENT_TEST_RETRY: 'retry'; +- readonly STATE_IDLE: 'idle'; +- readonly STATE_RUNNING: 'running'; +- readonly STATE_STOPPED: 'stopped'; +- } +- +- /** +- * Initialize a `Runner` for the given `suite`. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html +- */ +- class Runner { +- private _globals; +- private _abort; +- private _delay; +- private _defaultGrep; +- private next; +- private hookErr; +- private prevGlobalsLength; +- private nextSuite; +- +- static readonly constants: RunnerConstants; +- +- constructor(suite: Suite, delay: boolean); +- +- suite: Suite; +- started: boolean; +- total: number; +- failures: number; +- asyncOnly?: boolean; +- allowUncaught?: boolean; +- fullStackTrace?: boolean; +- forbidOnly?: boolean; +- forbidPending?: boolean; +- checkLeaks?: boolean; +- test?: Test; +- currentRunnable?: Runnable; +- stats?: Stats; // added by reporters +- +- /** +- * Removes all event handlers set during a run on this instance. +- * Remark: this does *not* clean/dispose the tests or suites themselves. +- * +- * @see https://mochajs.org/api/runner#dispose +- */ +- dispose(): void; +- +- /** +- * Run tests with full titles matching `re`. Updates runner.total +- * with number of tests matched. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grep +- */ +- grep(re: RegExp, invert: boolean): this; +- +- /** +- * Returns the number of tests matching the grep search for the +- * given suite. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grepTotal +- */ +- grepTotal(suite: Suite): number; +- +- /** +- * Gets the allowed globals. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals +- */ +- globals(): string[]; +- +- /** +- * Allow the given `arr` of globals. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals +- */ +- globals(arr: ReadonlyArray): this; +- +- /** +- * Run the root suite and invoke `fn(failures)` on completion. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#run +- */ +- run(fn?: (failures: number) => void): this; +- +- /** +- * Cleanly abort execution. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#abort +- */ +- abort(): this; +- +- /** +- * Handle uncaught exceptions. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#uncaught +- */ +- uncaught(err: any): void; +- +- /** +- * Wrapper for setImmediate, process.nextTick, or browser polyfill. +- */ +- protected static immediately(callback: Function): void; +- +- /** +- * Return a list of global properties. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#globalProps +- */ +- protected globalProps(): string[]; +- +- /** +- * Check for global variable leaks. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#checkGlobals +- */ +- protected checkGlobals(test: Test): void; +- +- /** +- * Fail the given `test`. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#fail +- */ +- protected fail(test: Test, err: any): void; +- +- /** +- * Fail the given `hook` with `err`. +- * +- * Hook failures work in the following pattern: +- * - If bail, then exit +- * - Failed `before` hook skips all tests in a suite and subsuites, +- * but jumps to corresponding `after` hook +- * - Failed `before each` hook skips remaining tests in a +- * suite and jumps to corresponding `after each` hook, +- * which is run only once +- * - Failed `after` hook does not alter +- * execution order +- * - Failed `after each` hook skips remaining tests in a +- * suite and subsuites, but executes other `after each` +- * hooks +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#failHook +- */ +- protected failHook(hook: Hook, err: any): void; +- +- /** +- * Run hook `name` callbacks and then invoke `fn()`. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#hook +- */ +- protected hook(name: string, fn: () => void): void; +- +- /** +- * Run hook `name` for the given array of `suites` +- * in order, and callback `fn(err, errSuite)`. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#hooks +- */ +- protected hooks(name: string, suites: Suite[], fn: (err?: any, errSuite?: Suite) => void): void; +- +- /** +- * Run hooks from the top level down. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#hookUp +- */ +- protected hookUp(name: string, fn: (err?: any, errSuite?: Suite) => void): void; +- +- /** +- * Run hooks from the bottom up. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#hookDown +- */ +- protected hookDown(name: string, fn: (err?: any, errSuite?: Suite) => void): void; +- +- /** +- * Return an array of parent Suites from closest to furthest. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#parents +- */ +- protected parents(): Suite[]; +- +- /** +- * Run the current test and callback `fn(err)`. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#runTest +- */ +- protected runTest(fn: Done): any; +- +- /** +- * Run tests in the given `suite` and invoke the callback `fn()` when complete. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#runTests +- */ +- protected runTests(suite: Suite, fn: (errSuite?: Suite) => void): void; +- +- /** +- * Run the given `suite` and invoke the callback `fn()` when complete. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#runSuite +- */ +- protected runSuite(suite: Suite, fn: (errSuite?: Suite) => void): void; +- } +- +- // #region Runner "waiting" event +- interface Runner { +- on(event: "waiting", listener: (rootSuite: Suite) => void): this; +- once(event: "waiting", listener: (rootSuite: Suite) => void): this; +- addListener(event: "waiting", listener: (rootSuite: Suite) => void): this; +- removeListener(event: "waiting", listener: (rootSuite: Suite) => void): this; +- prependListener(event: "waiting", listener: (rootSuite: Suite) => void): this; +- prependOnceListener(event: "waiting", listener: (rootSuite: Suite) => void): this; +- emit(name: "waiting", rootSuite: Suite): boolean; +- } +- // #endregion Runner "waiting" event +- // #region Runner "start" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "start", listener: () => void): this; +- once(event: "start", listener: () => void): this; +- addListener(event: "start", listener: () => void): this; +- removeListener(event: "start", listener: () => void): this; +- prependListener(event: "start", listener: () => void): this; +- prependOnceListener(event: "start", listener: () => void): this; +- emit(name: "start"): boolean; +- } +- // #endregion Runner "start" event +- // #region Runner "end" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "end", listener: () => void): this; +- once(event: "end", listener: () => void): this; +- addListener(event: "end", listener: () => void): this; +- removeListener(event: "end", listener: () => void): this; +- prependListener(event: "end", listener: () => void): this; +- prependOnceListener(event: "end", listener: () => void): this; +- emit(name: "end"): boolean; +- } +- // #endregion Runner "end" event +- // #region Runner "suite" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "suite", listener: (suite: Suite) => void): this; +- once(event: "suite", listener: (suite: Suite) => void): this; +- addListener(event: "suite", listener: (suite: Suite) => void): this; +- removeListener(event: "suite", listener: (suite: Suite) => void): this; +- prependListener(event: "suite", listener: (suite: Suite) => void): this; +- prependOnceListener(event: "suite", listener: (suite: Suite) => void): this; +- emit(name: "suite", suite: Suite): boolean; +- } +- // #endregion Runner "suite" event +- // #region Runner "suite end" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "suite end", listener: (suite: Suite) => void): this; +- once(event: "suite end", listener: (suite: Suite) => void): this; +- addListener(event: "suite end", listener: (suite: Suite) => void): this; +- removeListener(event: "suite end", listener: (suite: Suite) => void): this; +- prependListener(event: "suite end", listener: (suite: Suite) => void): this; +- prependOnceListener(event: "suite end", listener: (suite: Suite) => void): this; +- emit(name: "suite end", suite: Suite): boolean; +- } +- // #endregion Runner "suite end" event +- // #region Runner "test" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "test", listener: (test: Test) => void): this; +- once(event: "test", listener: (test: Test) => void): this; +- addListener(event: "test", listener: (test: Test) => void): this; +- removeListener(event: "test", listener: (test: Test) => void): this; +- prependListener(event: "test", listener: (test: Test) => void): this; +- prependOnceListener(event: "test", listener: (test: Test) => void): this; +- emit(name: "test", test: Test): boolean; +- } +- // #endregion Runner "test" event +- // #region Runner "test end" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "test end", listener: (test: Test) => void): this; +- once(event: "test end", listener: (test: Test) => void): this; +- addListener(event: "test end", listener: (test: Test) => void): this; +- removeListener(event: "test end", listener: (test: Test) => void): this; +- prependListener(event: "test end", listener: (test: Test) => void): this; +- prependOnceListener(event: "test end", listener: (test: Test) => void): this; +- emit(name: "test end", test: Test): boolean; +- } +- // #endregion Runner "test end" event +- // #region Runner "hook" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "hook", listener: (hook: Hook) => void): this; +- once(event: "hook", listener: (hook: Hook) => void): this; +- addListener(event: "hook", listener: (hook: Hook) => void): this; +- removeListener(event: "hook", listener: (hook: Hook) => void): this; +- prependListener(event: "hook", listener: (hook: Hook) => void): this; +- prependOnceListener(event: "hook", listener: (hook: Hook) => void): this; +- emit(name: "hook", hook: Hook): boolean; +- } +- // #endregion Runner "hook" event +- // #region Runner "hook end" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "hook end", listener: (hook: Hook) => void): this; +- once(event: "hook end", listener: (hook: Hook) => void): this; +- addListener(event: "hook end", listener: (hook: Hook) => void): this; +- removeListener(event: "hook end", listener: (hook: Hook) => void): this; +- prependListener(event: "hook end", listener: (hook: Hook) => void): this; +- prependOnceListener(event: "hook end", listener: (hook: Hook) => void): this; +- emit(name: "hook end", hook: Hook): boolean; +- } +- // #endregion Runner "hook end" event +- // #region Runner "pass" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "pass", listener: (test: Test) => void): this; +- once(event: "pass", listener: (test: Test) => void): this; +- addListener(event: "pass", listener: (test: Test) => void): this; +- removeListener(event: "pass", listener: (test: Test) => void): this; +- prependListener(event: "pass", listener: (test: Test) => void): this; +- prependOnceListener(event: "pass", listener: (test: Test) => void): this; +- emit(name: "pass", test: Test): boolean; +- } +- // #endregion Runner "pass" event +- // #region Runner "fail" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "fail", listener: (test: Test, err: any) => void): this; +- once(event: "fail", listener: (test: Test, err: any) => void): this; +- addListener(event: "fail", listener: (test: Test, err: any) => void): this; +- removeListener(event: "fail", listener: (test: Test, err: any) => void): this; +- prependListener(event: "fail", listener: (test: Test, err: any) => void): this; +- prependOnceListener(event: "fail", listener: (test: Test, err: any) => void): this; +- emit(name: "fail", test: Test, err: any): boolean; +- } +- // #endregion Runner "fail" event +- // #region Runner "pending" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "pending", listener: (test: Test) => void): this; +- once(event: "pending", listener: (test: Test) => void): this; +- addListener(event: "pending", listener: (test: Test) => void): this; +- removeListener(event: "pending", listener: (test: Test) => void): this; +- prependListener(event: "pending", listener: (test: Test) => void): this; +- prependOnceListener(event: "pending", listener: (test: Test) => void): this; +- emit(name: "pending", test: Test): boolean; +- } +- // #endregion Runner "pending" event +- // #region Runner untyped events +- interface Runner extends NodeJS.EventEmitter { +- on(event: string, listener: (...args: any[]) => void): this; +- once(event: string, listener: (...args: any[]) => void): this; +- addListener(event: string, listener: (...args: any[]) => void): this; +- removeListener(event: string, listener: (...args: any[]) => void): this; +- prependListener(event: string, listener: (...args: any[]) => void): this; +- prependOnceListener(event: string, listener: (...args: any[]) => void): this; +- emit(name: string, ...args: any[]): boolean; +- } +- // #endregion Runner untyped events +- +- interface SuiteConstants { +- readonly EVENT_FILE_POST_REQUIRE: 'post-require'; +- readonly EVENT_FILE_PRE_REQUIRE: 'pre-require'; +- readonly EVENT_FILE_REQUIRE: 'require'; +- readonly EVENT_ROOT_SUITE_RUN: 'run'; +- +- readonly HOOK_TYPE_AFTER_ALL: 'afterAll'; +- readonly HOOK_TYPE_AFTER_EACH: 'afterEach'; +- readonly HOOK_TYPE_BEFORE_ALL: 'beforeAll'; +- readonly HOOK_TYPE_BEFORE_EACH: 'beforeEach'; +- +- readonly EVENT_SUITE_ADD_HOOK_AFTER_ALL: 'afterAll'; +- readonly EVENT_SUITE_ADD_HOOK_AFTER_EACH: 'afterEach'; +- readonly EVENT_SUITE_ADD_HOOK_BEFORE_ALL: 'beforeAll'; +- readonly EVENT_SUITE_ADD_HOOK_BEFORE_EACH: 'beforeEach'; +- readonly EVENT_SUITE_ADD_SUITE: 'suite'; +- readonly EVENT_SUITE_ADD_TEST: 'test'; +- } +- +- /** +- * Initialize a new `Suite` with the given `title` and `ctx`. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html +- */ +- class Suite { +- private _beforeEach; +- private _beforeAll; +- private _afterEach; +- private _afterAll; +- private _timeout; +- private _slow; +- private _bail; +- private _retries; +- private _onlyTests; +- private _onlySuites; +- +- static readonly constants: SuiteConstants; +- +- constructor(title: string, parentContext?: Context); +- +- ctx: Context; +- suites: Suite[]; +- tests: Test[]; +- pending: boolean; +- file?: string; +- root: boolean; +- delayed: boolean; +- parent: Suite | undefined; +- title: string; +- +- /** +- * Create a new `Suite` with the given `title` and parent `Suite`. When a suite +- * with the same title is already present, that suite is returned to provide +- * nicer reporter and more flexible meta-testing. +- * +- * @see https://mochajs.org/api/mocha#.exports.create +- */ +- static create(parent: Suite, title: string): Suite; +- +- /** +- * Return a clone of this `Suite`. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#clone +- */ +- clone(): Suite; +- +- /** +- * Get timeout `ms`. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#timeout +- */ +- timeout(): number; +- +- /** +- * Set timeout `ms` or short-hand such as "2s". +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#timeout +- */ +- timeout(ms: string | number): this; +- +- /** +- * Get number of times to retry a failed test. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#retries +- */ +- retries(): number; +- +- /** +- * Set number of times to retry a failed test. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#retries +- */ +- retries(n: string | number): this; +- +- /** +- * Get slow `ms`. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#slow +- */ +- slow(): number; +- +- /** +- * Set slow `ms` or short-hand such as "2s". +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#slow +- */ +- slow(ms: string | number): this; +- +- /** +- * Get whether to bail after first error. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#bail +- */ +- bail(): boolean; +- +- /** +- * Set whether to bail after first error. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#bail +- */ +- bail(bail: boolean): this; +- +- /** +- * Check if this suite or its parent suite is marked as pending. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#isPending +- */ +- isPending(): boolean; +- +- /** +- * Run `fn(test[, done])` before running tests. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll +- */ +- beforeAll(fn?: Func): this; +- +- /** +- * Run `fn(test[, done])` before running tests. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll +- */ +- beforeAll(fn?: AsyncFunc): this; +- +- /** +- * Run `fn(test[, done])` before running tests. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll +- */ +- beforeAll(title: string, fn?: Func): this; +- +- /** +- * Run `fn(test[, done])` before running tests. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll +- */ +- beforeAll(title: string, fn?: AsyncFunc): this; +- +- /** +- * Run `fn(test[, done])` after running tests. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#afterAll +- */ +- afterAll(fn?: Func): this; +- +- /** +- * Run `fn(test[, done])` after running tests. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#afterAll +- */ +- afterAll(fn?: AsyncFunc): this; +- +- /** +- * Run `fn(test[, done])` after running tests. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#afterAll +- */ +- afterAll(title: string, fn?: Func): this; +- +- /** +- * Run `fn(test[, done])` after running tests. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#afterAll +- */ +- afterAll(title: string, fn?: AsyncFunc): this; +- +- /** +- * Run `fn(test[, done])` before each test case. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach +- */ +- beforeEach(fn?: Func): this; +- +- /** +- * Run `fn(test[, done])` before each test case. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach +- */ +- beforeEach(fn?: AsyncFunc): this; +- +- /** +- * Run `fn(test[, done])` before each test case. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach +- */ +- beforeEach(title: string, fn?: Func): this; +- +- /** +- * Run `fn(test[, done])` before each test case. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach +- */ +- beforeEach(title: string, fn?: AsyncFunc): this; +- +- /** +- * Run `fn(test[, done])` after each test case. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#afterEach +- */ +- afterEach(fn?: Func): this; +- +- /** +- * Run `fn(test[, done])` after each test case. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#afterEach +- */ +- afterEach(fn?: AsyncFunc): this; +- +- /** +- * Run `fn(test[, done])` after each test case. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#afterEach +- */ +- afterEach(title: string, fn?: Func): this; +- +- /** +- * Run `fn(test[, done])` after each test case. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#afterEach +- */ +- afterEach(title: string, fn?: AsyncFunc): this; +- +- /** +- * Add a test `suite`. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#addSuite +- */ +- addSuite(suite: Suite): this; +- +- /** +- * Add a `test` to this suite. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#addTest +- */ +- addTest(test: Test): this; +- +- /** +- * Cleans all references from this suite and all child suites. +- * +- * https://mochajs.org/api/suite#dispose +- */ +- dispose(): void; +- +- /** +- * Return the full title generated by recursively concatenating the parent's +- * full title. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#fullTitle +- */ +- fullTitle(): string; +- +- /** +- * Return the title path generated by recursively concatenating the parent's +- * title path. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#titlePath +- */ +- titlePath(): string[]; +- +- /** +- * Return the total number of tests. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#total +- */ +- total(): number; +- +- /** +- * Iterates through each suite recursively to find all tests. Applies a +- * function in the format `fn(test)`. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#eachTest +- */ +- eachTest(fn: (test: Test) => void): this; +- +- /** +- * This will run the root suite if we happen to be running in delayed mode. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#run +- */ +- run(): void; +- +- /** +- * Generic hook-creator. +- */ +- protected _createHook(title: string, fn?: Func | AsyncFunc): Hook; +- } +- +- // #region Suite "beforeAll" event +- interface Suite extends NodeJS.EventEmitter { +- on(event: "beforeAll", listener: (hook: Hook) => void): this; +- once(event: "beforeAll", listener: (hook: Hook) => void): this; +- addListener(event: "beforeAll", listener: (hook: Hook) => void): this; +- removeListener(event: "beforeAll", listener: (hook: Hook) => void): this; +- prependListener(event: "beforeAll", listener: (hook: Hook) => void): this; +- prependOnceListener(event: "beforeAll", listener: (hook: Hook) => void): this; +- emit(name: "beforeAll", hook: Hook): boolean; +- } +- // #endregion Suite "beforeAll" event +- // #region Suite "afterAll" event +- interface Suite extends NodeJS.EventEmitter { +- on(event: "afterAll", listener: (hook: Hook) => void): this; +- once(event: "afterAll", listener: (hook: Hook) => void): this; +- addListener(event: "afterAll", listener: (hook: Hook) => void): this; +- removeListener(event: "afterAll", listener: (hook: Hook) => void): this; +- prependListener(event: "afterAll", listener: (hook: Hook) => void): this; +- prependOnceListener(event: "afterAll", listener: (hook: Hook) => void): this; +- emit(name: "afterAll", hook: Hook): boolean; +- } +- // #endregion Suite "afterAll" event +- // #region Suite "beforeEach" event +- interface Suite extends NodeJS.EventEmitter { +- on(event: "beforeEach", listener: (hook: Hook) => void): this; +- once(event: "beforeEach", listener: (hook: Hook) => void): this; +- addListener(event: "beforeEach", listener: (hook: Hook) => void): this; +- removeListener(event: "beforeEach", listener: (hook: Hook) => void): this; +- prependListener(event: "beforeEach", listener: (hook: Hook) => void): this; +- prependOnceListener(event: "beforeEach", listener: (hook: Hook) => void): this; +- emit(name: "beforeEach", hook: Hook): boolean; +- } +- // #endregion Suite "beforeEach" event +- // #region Suite "afterEach" event +- interface Suite extends NodeJS.EventEmitter { +- on(event: "afterEach", listener: (hook: Hook) => void): this; +- once(event: "afterEach", listener: (hook: Hook) => void): this; +- addListener(event: "afterEach", listener: (hook: Hook) => void): this; +- removeListener(event: "afterEach", listener: (hook: Hook) => void): this; +- prependListener(event: "afterEach", listener: (hook: Hook) => void): this; +- prependOnceListener(event: "afterEach", listener: (hook: Hook) => void): this; +- emit(name: "afterEach", hook: Hook): boolean; +- } +- // #endregion Suite "afterEach" event +- // #region Suite "suite" event +- interface Suite extends NodeJS.EventEmitter { +- on(event: "suite", listener: (suite: Suite) => void): this; +- once(event: "suite", listener: (suite: Suite) => void): this; +- addListener(event: "suite", listener: (suite: Suite) => void): this; +- removeListener(event: "suite", listener: (suite: Suite) => void): this; +- prependListener(event: "suite", listener: (suite: Suite) => void): this; +- prependOnceListener(event: "suite", listener: (suite: Suite) => void): this; +- emit(name: "suite", suite: Suite): boolean; +- } +- // #endregion Suite "suite" event +- // #region Suite "test" event +- interface Suite { +- on(event: "test", listener: (test: Test) => void): this; +- once(event: "test", listener: (test: Test) => void): this; +- addListener(event: "test", listener: (test: Test) => void): this; +- removeListener(event: "test", listener: (test: Test) => void): this; +- prependListener(event: "test", listener: (test: Test) => void): this; +- prependOnceListener(event: "test", listener: (test: Test) => void): this; +- emit(name: "test", test: Test): boolean; +- } +- // #endregion Suite "test" event +- // #region Suite "run" event +- interface Suite extends NodeJS.EventEmitter { +- on(event: "run", listener: () => void): this; +- once(event: "run", listener: () => void): this; +- addListener(event: "run", listener: () => void): this; +- removeListener(event: "run", listener: () => void): this; +- prependListener(event: "run", listener: () => void): this; +- prependOnceListener(event: "run", listener: () => void): this; +- emit(name: "run"): boolean; +- } +- // #endregion Suite "run" event +- // #region Suite "pre-require" event +- interface Suite extends NodeJS.EventEmitter { +- on(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- once(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- addListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- removeListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- prependListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- prependOnceListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- emit(name: "pre-require", context: MochaGlobals, file: string, mocha: Mocha): boolean; +- } +- // #endregion Suite "pre-require" event +- // #region Suite "require" event +- interface Suite extends NodeJS.EventEmitter { +- on(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; +- once(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; +- addListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; +- removeListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; +- prependListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; +- prependOnceListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; +- emit(name: "require", module: any, file: string, mocha: Mocha): boolean; +- } +- // #endregion Suite "require" event +- // #region Suite "post-require" event +- interface Suite extends NodeJS.EventEmitter { +- on(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- once(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- addListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- removeListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- prependListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- prependOnceListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- emit(name: "post-require", context: MochaGlobals, file: string, mocha: Mocha): boolean; +- } +- // #endregion Suite "post-require" event +- // #region Suite untyped events +- interface Suite extends NodeJS.EventEmitter { +- on(event: string, listener: (...args: any[]) => void): this; +- once(event: string, listener: (...args: any[]) => void): this; +- addListener(event: string, listener: (...args: any[]) => void): this; +- removeListener(event: string, listener: (...args: any[]) => void): this; +- prependListener(event: string, listener: (...args: any[]) => void): this; +- prependOnceListener(event: string, listener: (...args: any[]) => void): this; +- emit(name: string, ...args: any[]): boolean; +- } +- // #endregion Runner untyped events +- +- /** +- * Initialize a new `Hook` with the given `title` and callback `fn` +- * +- * @see https://mochajs.org/api/Hook.html +- */ +- class Hook extends Runnable { +- private _error; +- +- type: "hook"; +- originalTitle?: string; // added by Runner +- +- /** +- * Get the test `err`. +- * +- * @see https://mochajs.org/api/Hook.html#error +- */ +- error(): any; +- +- /** +- * Set the test `err`. +- * +- * @see https://mochajs.org/api/Hook.html#error +- */ +- error(err: any): void; +- } +- +- /** +- * An alternative way to define root hooks that works with parallel runs. +- * +- * Root hooks work with any interface, but the property names do not change. +- * In other words, if you are using the tdd interface, suiteSetup maps to beforeAll, and setup maps to beforeEach. +- * +- * As with other hooks, `this` refers to to the current context object. +- * +- * @see https://mochajs.org/#root-hook-plugins +- */ +- interface RootHookObject { +- /** +- * In serial mode, run after all tests end, once only. +- * In parallel mode, run after all tests end, for each file. +- */ +- afterAll?: Func | AsyncFunc | Func[] | AsyncFunc[]; +- /** +- * In serial mode (Mocha's default), before all tests begin, once only. +- * In parallel mode, run before all tests begin, for each file. +- */ +- beforeAll?: Func | AsyncFunc | Func[] | AsyncFunc[]; +- /** +- * In both modes, run after every test. +- */ +- afterEach?: Func | AsyncFunc | Func[] | AsyncFunc[]; +- /** +- * In both modes, run before each test. +- */ +- beforeEach?: Func | AsyncFunc | Func[] | AsyncFunc[]; +- } +- +- /** +- * Initialize a new `Test` with the given `title` and callback `fn`. +- * +- * @see https://mochajs.org/api/Test.html +- */ +- class Test extends Runnable { +- type: "test"; +- speed?: "slow" | "medium" | "fast"; // added by reporters +- err?: Error; // added by reporters +- clone(): Test; +- } +- +- /** +- * Test statistics +- */ +- interface Stats { +- suites: number; +- tests: number; +- passes: number; +- pending: number; +- failures: number; +- start?: Date; +- end?: Date; +- duration?: number; +- } +- +- type TestInterface = (suite: Suite) => void; +- +- interface ReporterConstructor { +- new (runner: Runner, options: MochaOptions): reporters.Base; +- } +- +- type Done = (err?: any) => void; +- +- /** +- * Callback function used for tests and hooks. +- */ +- type Func = (this: Context, done: Done) => void; +- +- /** +- * Async callback function used for tests and hooks. +- */ +- type AsyncFunc = (this: Context) => PromiseLike; +- +- /** +- * Options to pass to Mocha. +- */ +- interface MochaOptions { +- /** Test interfaces ("bdd", "tdd", "exports", etc.). */ +- ui?: Interface; +- +- /** +- * Reporter constructor, built-in reporter name, or reporter module path. Defaults to +- * `"spec"`. +- */ +- reporter?: string | ReporterConstructor; +- +- /** Options to pass to the reporter. */ +- reporterOptions?: any; +- +- /** Array of accepted globals. */ +- globals?: string[]; +- +- /** timeout in milliseconds or time string like '1s'. */ +- timeout?: number | string; +- +- /** number of times to retry failed tests. */ +- retries?: number; +- +- /** bail on the first test failure. */ +- bail?: boolean; +- +- /** milliseconds to wait before considering a test slow. */ +- slow?: number; +- +- /** check for global variable leaks. */ +- checkLeaks?: boolean; +- +- /** display the full stack trace on failure. */ +- fullStackTrace?: boolean; +- +- /** string or regexp to filter tests with. */ +- grep?: string | RegExp; +- +- /** Enable growl support. */ +- growl?: boolean; +- +- /** Color TTY output from reporter */ +- color?: boolean; +- +- /** Use inline diffs rather than +/-. */ +- inlineDiffs?: boolean; +- +- /** Do not show diffs at all. */ +- hideDiff?: boolean; +- +- /** Run job in parallel */ +- parallel?: boolean; +- +- /** Max number of worker processes for parallel runs */ +- jobs?: number; +- +- /** Assigns hooks to the root suite */ +- rootHooks?: RootHookObject; +- +- asyncOnly?: boolean; +- delay?: boolean; +- forbidOnly?: boolean; +- forbidPending?: boolean; +- noHighlighting?: boolean; +- allowUncaught?: boolean; +- fullTrace?: boolean; +- } +- +- interface MochaInstanceOptions extends MochaOptions { +- files?: string[]; +- } +- +- /** +- * Variables added to the global scope by Mocha when run in the CLI. +- */ +- interface MochaGlobals { +- /** +- * Execute before running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#before +- */ +- before: HookFunction; +- +- /** +- * Execute after running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#after +- */ +- after: HookFunction; +- +- /** +- * Execute before each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#beforeEach +- */ +- beforeEach: HookFunction; +- +- /** +- * Execute after each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#afterEach +- */ +- afterEach: HookFunction; +- +- /** +- * Describe a "suite" containing nested suites and tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- describe: SuiteFunction; +- +- /** +- * Describe a "suite" containing nested suites and tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- context: SuiteFunction; +- +- /** +- * Pending suite. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- xdescribe: PendingSuiteFunction; +- +- /** +- * Pending suite. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- xcontext: PendingSuiteFunction; +- +- /** +- * Describes a test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- it: TestFunction; +- +- /** +- * Describes a test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- specify: TestFunction; +- +- /** +- * Describes a pending test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- xit: PendingTestFunction; +- +- /** +- * Describes a pending test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- xspecify: PendingTestFunction; +- +- /** +- * Execute before running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#before +- */ +- suiteSetup: HookFunction; +- +- /** +- * Execute after running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#after +- */ +- suiteTeardown: HookFunction; +- +- /** +- * Execute before each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#beforeEach +- */ +- setup: HookFunction; +- +- /** +- * Execute after each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#afterEach +- */ +- teardown: HookFunction; +- +- /** +- * Describe a "suite" containing nested suites and tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- suite: SuiteFunction; +- +- /** +- * Describes a test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- test: TestFunction; +- +- run: typeof run; +- } +- +- /** +- * Third-party declarations that want to add new entries to the `Reporter` union can +- * contribute names here. +- */ +- interface ReporterContributions { +- Base: never; +- base: never; +- Dot: never; +- dot: never; +- TAP: never; +- tap: never; +- JSON: never; +- json: never; +- HTML: never; +- html: never; +- List: never; +- list: never; +- Min: never; +- min: never; +- Spec: never; +- spec: never; +- Nyan: never; +- nyan: never; +- XUnit: never; +- xunit: never; +- Markdown: never; +- markdown: never; +- Progress: never; +- progress: never; +- Landing: never; +- landing: never; +- JSONStream: never; +- "json-stream": never; +- } +- +- type Reporter = keyof ReporterContributions; +- +- /** +- * Third-party declarations that want to add new entries to the `Interface` union can +- * contribute names here. +- */ +- interface InterfaceContributions { +- bdd: never; +- tdd: never; +- qunit: never; +- exports: never; +- } +- +- type Interface = keyof InterfaceContributions; +-} +- +-// #region Test interface augmentations +- +-/** +- * Triggers root suite execution. +- * +- * - _Only available if flag --delay is passed into Mocha._ +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#runWithSuite +- */ +-declare function run(): void; +- +-/** +- * Execute before running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#before +- */ +-declare var before: Mocha.HookFunction; +- +-/** +- * Execute before running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#before +- */ +-declare var suiteSetup: Mocha.HookFunction; +- +-/** +- * Execute after running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#after +- */ +-declare var after: Mocha.HookFunction; +- +-/** +- * Execute after running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#after +- */ +-declare var suiteTeardown: Mocha.HookFunction; +- +-/** +- * Execute before each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#beforeEach +- */ +-declare var beforeEach: Mocha.HookFunction; +- +-/** +- * Execute before each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#beforeEach +- */ +-declare var setup: Mocha.HookFunction; +- +-/** +- * Execute after each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#afterEach +- */ +-declare var afterEach: Mocha.HookFunction; +- +-/** +- * Execute after each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#afterEach +- */ +-declare var teardown: Mocha.HookFunction; +- +-/** +- * Describe a "suite" containing nested suites and tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var describe: Mocha.SuiteFunction; +- +-/** +- * Describe a "suite" containing nested suites and tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var context: Mocha.SuiteFunction; +- +-/** +- * Describe a "suite" containing nested suites and tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var suite: Mocha.SuiteFunction; +- +-/** +- * Pending suite. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var xdescribe: Mocha.PendingSuiteFunction; +- +-/** +- * Pending suite. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var xcontext: Mocha.PendingSuiteFunction; +- +-/** +- * Describes a test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var it: Mocha.TestFunction; +- +-/** +- * Describes a test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var specify: Mocha.TestFunction; +- +-/** +- * Describes a test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var test: Mocha.TestFunction; +- +-/** +- * Describes a pending test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var xit: Mocha.PendingTestFunction; +- +-/** +- * Describes a pending test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var xspecify: Mocha.PendingTestFunction; +- +-// #endregion Test interface augmentations +- +-// #region Reporter augmentations +- +-// Forward declaration for `HTMLLIElement` from lib.dom.d.ts. +-// Required by Mocha.reporters.HTML. +-// NOTE: Mocha *must not* have a direct dependency on DOM types. +-// tslint:disable-next-line no-empty-interface +-interface HTMLLIElement { } +- +-// Augments the DOM `Window` object when lib.dom.d.ts is loaded. +-// tslint:disable-next-line no-empty-interface +-interface Window extends Mocha.MochaGlobals { } +- +-declare namespace NodeJS { +- // Forward declaration for `NodeJS.EventEmitter` from node.d.ts. +- // Required by Mocha.Runnable, Mocha.Runner, and Mocha.Suite. +- // NOTE: Mocha *must not* have a direct dependency on @types/node. +- // tslint:disable-next-line no-empty-interface +- interface EventEmitter { } +- +- // Augments NodeJS's `global` object when node.d.ts is loaded +- // tslint:disable-next-line no-empty-interface +- interface Global extends Mocha.MochaGlobals { } +-} +- +-// #endregion Reporter augmentations +- +-// #region Browser augmentations +- +-/** +- * Mocha global. +- * +- * - _Only supported in the browser._ +- */ +-declare const mocha: BrowserMocha; +- +-interface BrowserMocha extends Mocha { +- /** +- * Function to allow assertion libraries to throw errors directly into mocha. +- * This is useful when running tests in a browser because window.onerror will +- * only receive the 'message' attribute of the Error. +- * +- * - _Only supported in the browser._ +- */ +- throwError(err: any): never; +- +- /** +- * Setup mocha with the given settings options. +- * +- * - _Only supported in the browser._ +- */ +- setup(opts?: Mocha.Interface | Mocha.MochaOptions): this; +-} +- +-// #endregion Browser augmentations +- +-declare module "mocha" { +- export = Mocha; +-} +- +-declare module "mocha/lib/stats-collector" { +- export = createStatsCollector; +- +- /** +- * Provides stats such as test duration, number of tests passed / failed etc., by listening for events emitted by `runner`. +- */ +- function createStatsCollector(runner: Mocha.Runner): void; +- } +- +-declare module "mocha/lib/interfaces/common" { +- export = common; +- +- function common(suites: Mocha.Suite[], context: Mocha.MochaGlobals, mocha: Mocha): common.CommonFunctions; +- +- namespace common { +- interface CommonFunctions { +- /** +- * This is only present if flag --delay is passed into Mocha. It triggers +- * root suite execution. +- */ +- runWithSuite(suite: Mocha.Suite): () => void; +- +- /** +- * Execute before running tests. +- */ +- before(fn?: Mocha.Func | Mocha.AsyncFunc): void; +- +- /** +- * Execute before running tests. +- */ +- before(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; +- +- /** +- * Execute after running tests. +- */ +- after(fn?: Mocha.Func | Mocha.AsyncFunc): void; +- +- /** +- * Execute after running tests. +- */ +- after(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; +- +- /** +- * Execute before each test case. +- */ +- beforeEach(fn?: Mocha.Func | Mocha.AsyncFunc): void; +- +- /** +- * Execute before each test case. +- */ +- beforeEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; +- +- /** +- * Execute after each test case. +- */ +- afterEach(fn?: Mocha.Func | Mocha.AsyncFunc): void; +- +- /** +- * Execute after each test case. +- */ +- afterEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; +- +- suite: SuiteFunctions; +- test: TestFunctions; +- } +- +- interface CreateOptions { +- /** Title of suite */ +- title: string; +- +- /** Suite function */ +- fn?: (this: Mocha.Suite) => void; +- +- /** Is suite pending? */ +- pending?: boolean; +- +- /** Filepath where this Suite resides */ +- file?: string; +- +- /** Is suite exclusive? */ +- isOnly?: boolean; +- } +- +- interface SuiteFunctions { +- /** +- * Create an exclusive Suite; convenience function +- */ +- only(opts: CreateOptions): Mocha.Suite; +- +- /** +- * Create a Suite, but skip it; convenience function +- */ +- skip(opts: CreateOptions): Mocha.Suite; +- +- /** +- * Creates a suite. +- */ +- create(opts: CreateOptions): Mocha.Suite; +- } +- +- interface TestFunctions { +- /** +- * Exclusive test-case. +- */ +- only(mocha: Mocha, test: Mocha.Test): Mocha.Test; +- +- /** +- * Pending test case. +- */ +- skip(title: string): void; +- +- /** +- * Number of retry attempts +- */ +- retries(n: number): void; +- } +- } +-} ++// // Type definitions for mocha 8.2 ++// // Project: https://mochajs.org ++// // Definitions by: Kazi Manzur Rashid ++// // otiai10 ++// // Vadim Macagon ++// // Andrew Bradley ++// // Dmitrii Sorin ++// // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped ++// // TypeScript Version: 2.1 ++ ++// /** ++// * Mocha API ++// * ++// * @see https://mochajs.org/api/mocha ++// */ ++// declare class Mocha { ++// private _growl; ++// private _reporter; ++// private _ui; ++ ++// constructor(options?: Mocha.MochaOptions); ++ ++// suite: Mocha.Suite; ++// files: string[]; ++// options: Mocha.MochaInstanceOptions; ++ ++// /** ++// * Add test `file`. ++// * ++// * @see https://mochajs.org/api/mocha#addFile ++// */ ++// addFile(file: string): this; ++ ++// /** ++// * Enable or disable bailing on the first failure. ++// * ++// * @see https://mochajs.org/api/mocha#bail ++// */ ++// bail(bail?: boolean): this; ++ ++// /** ++// * Manually dispose this mocha instance. Mark this instance as `disposed` and unable to run more tests. ++// * It also removes function references to tests functions and hooks, so variables trapped in closures can be cleaned by the garbage collector. ++// * ++// * @see https://mochajs.org/api/mocha#dispose ++// */ ++// dispose(): void; ++ ++// /** ++// * Set reporter to one of the built-in reporters. ++// * ++// * @see https://mochajs.org/api/mocha#reporter ++// */ ++// reporter(reporter: Mocha.Reporter, reporterOptions?: any): this; ++ ++// /** ++// * Set reporter to the provided constructor, one of the built-in reporters, or loads a reporter ++// * from a module path. Defaults to `"spec"`. ++// * ++// * @see https://mochajs.org/api/mocha#reporter ++// */ ++// reporter(reporter?: string | Mocha.ReporterConstructor, reporterOptions?: any): this; ++ ++// /** ++// * Set test UI to one of the built-in test interfaces. ++// * ++// * @see https://mochajs.org/api/mocha#ui ++// */ ++// ui(name: Mocha.Interface): this; ++ ++// /** ++// * Set test UI to one of the built-in test interfaces or loads a test interface from a module ++// * path. Defaults to `"bdd"`. ++// * ++// * @see https://mochajs.org/api/mocha#ui ++// */ ++// ui(name?: string): this; ++ ++// /** ++// * Escape string and add it to grep as a RegExp. ++// * ++// * @see https://mochajs.org/api/mocha#fgrep ++// */ ++// fgrep(str: string): this; ++ ++// /** ++// * Add regexp to grep, if `re` is a string it is escaped. ++// * ++// * @see https://mochajs.org/api/mocha#grep ++// */ ++// grep(re: string | RegExp): this; ++ ++// /** ++// * Invert `.grep()` matches. ++// * ++// * @see https://mochajs.org/api/mocha#invert ++// */ ++// invert(): this; ++ ++// /** ++// * Enable global leak checking. ++// * ++// * @see https://mochajs.org/api/mocha#checkLeaks ++// */ ++// checkLeaks(): this; ++ ++// /** ++// * Display long stack-trace on failing ++// * ++// * @see https://mochajs.org/api/mocha#fullTrace ++// */ ++// fullTrace(): this; ++ ++// /** ++// * Enable growl support. ++// * ++// * @see https://mochajs.org/api/mocha#growl ++// */ ++// growl(): this; ++ ++// /** ++// * Ignore `globals` array or string. ++// * ++// * @see https://mochajs.org/api/mocha#globals ++// */ ++// globals(globals: string | ReadonlyArray): this; ++ ++// /** ++// * Set the timeout in milliseconds. ++// * ++// * @see https://mochajs.org/api/mocha#timeout ++// */ ++// timeout(timeout: string | number): this; ++ ++// /** ++// * Set the number of times to retry failed tests. ++// * ++// * @see https://mochajs.org/api/mocha#retries ++// */ ++// retries(n: number): this; ++ ++// /** ++// * Set slowness threshold in milliseconds. ++// * ++// * @see https://mochajs.org/api/mocha#slow ++// */ ++// slow(slow: string | number): this; ++ ++// /** ++// * Makes all tests async (accepting a callback) ++// * ++// * @see https://mochajs.org/api/mocha#asyncOnly. ++// */ ++// asyncOnly(): this; ++ ++// /** ++// * Disable syntax highlighting (in browser). ++// * ++// * @see https://mochajs.org/api/mocha#noHighlighting ++// */ ++// noHighlighting(): this; ++ ++// /** ++// * Enable uncaught errors to propagate (in browser). ++// * ++// * @see https://mochajs.org/api/mocha#allowUncaught ++// */ ++// allowUncaught(): boolean; ++ ++// /** ++// * Delay root suite execution. ++// * ++// * @see https://mochajs.org/api/mocha#delay ++// */ ++// delay(): boolean; ++ ++// /** ++// * Tests marked only fail the suite ++// * ++// * @see https://mochajs.org/api/mocha#forbidOnly ++// */ ++// forbidOnly(): boolean; ++ ++// /** ++// * Pending tests and tests marked skip fail the suite ++// * ++// * @see https://mochajs.org/api/mocha#forbidPending ++// */ ++// forbidPending(): boolean; ++ ++// /** ++// * Run tests and invoke `fn()` when complete. ++// * ++// * Note that `run` relies on Node's `require` to execute ++// * the test interface functions and will be subject to the ++// * cache - if the files are already in the `require` cache, ++// * they will effectively be skipped. Therefore, to run tests ++// * multiple times or to run tests in files that are already ++// * in the `require` cache, make sure to clear them from the ++// * cache first in whichever manner best suits your needs. ++// * ++// * @see https://mochajs.org/api/mocha#run ++// */ ++// run(fn?: (failures: number) => void): Mocha.Runner; ++ ++// /** ++// * Loads ESM (and CJS) test files asynchronously. ++// * ++// * @see https://mochajs.org/api/mocha#loadFilesAsync ++// */ ++// loadFilesAsync(): Promise; ++ ++// /** ++// * Load registered files. ++// * ++// * @see https://mochajs.org/api/mocha#loadFiles ++// */ ++// protected loadFiles(fn?: () => void): void; ++ ++// /** ++// * Unloads `files` from Node's `require` cache. ++// * ++// * This allows required files to be "freshly" reloaded, providing the ability ++// * to reuse a Mocha instance programmatically. ++// * Note: does not clear ESM module files from the cache ++// */ ++// unloadFiles(): this; ++ ++// /** ++// * Toggles parallel mode. ++// * ++// * Must be run before calling `run`. Changes the `Runner` class to ++// * use; also enables lazy file loading if not already done so. ++// * ++// * @see https://mochajs.org/api/mocha#parallelMode ++// */ ++// parallelMode(enabled?: boolean): this; ++ ++// /** ++// * Assigns hooks to the root suite. ++// * ++// * @see https://mochajs.org/api/mocha#rootHooks ++// */ ++// rootHooks(hooks: Mocha.RootHookObject): this; ++ ++// /** ++// * Configures one or more global setup fixtures. ++// * If given no parameters, unsets any previously-set fixtures. ++// * ++// * @see https://mochajs.org/api/mocha#globalSetup ++// */ ++// globalSetup: Mocha.HookFunction; ++ ++// /** ++// * Configures one or more global teardown fixtures. ++// * If given no parameters, unsets any previously-set fixtures. ++// * ++// * @see https://mochajs.org/api/mocha#globalTeardown ++// */ ++// globalTeardown: Mocha.HookFunction; ++ ++// /** ++// * Returns `true` if one or more global setup fixtures have been supplied ++// * ++// * @see https://mochajs.org/api/mocha#hasGlobalSetupFixtures ++// */ ++// hasGlobalSetupFixtures(): boolean; ++ ++// /** ++// * Returns `true` if one or more global teardown fixtures have been supplied ++// * ++// * @see https://mochajs.org/api/mocha#hasGlobalTeardownFixtures ++// */ ++// hasGlobalTeardownFixtures(): boolean; ++ ++// /** ++// * Toggle execution of any global setup fixture(s) ++// * ++// * @see https://mochajs.org/api/mocha#enableGlobalSetup ++// */ ++// enableGlobalSetup(enabled: boolean): this; ++ ++// /** ++// * Toggle execution of any global teardown fixture(s) ++// * ++// * @see https://mochajs.org/api/mocha#enableGlobalTeardown ++// */ ++// enableGlobalTeardown(enabled: boolean): this; ++// } ++ ++// declare namespace Mocha { ++// namespace utils { ++// /** ++// * Compute a slug from the given `str`. ++// * ++// * @see https://mochajs.org/api/module-utils.html#.slug ++// */ ++// function slug(str: string): string; ++ ++// /** ++// * Strip the function definition from `str`, and re-indent for pre whitespace. ++// * ++// * @see https://mochajs.org/api/module-utils.html#.clean ++// */ ++// function clean(str: string): string; ++ ++// /** ++// * Highlight the given string of `js`. ++// */ ++// function highlight(js: string): string; ++ ++// /** ++// * Takes some variable and asks `Object.prototype.toString()` what it thinks it is. ++// */ ++// function type(value: any): string; ++ ++// /** ++// * Stringify `value`. Different behavior depending on type of value: ++// * ++// * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively. ++// * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes. ++// * - If `value` is an *empty* object, function, or array, returns `'{}'`, `'[Function]'`, or `'[]'` respectively. ++// * - If `value` has properties, call canonicalize} on it, then return result of `JSON.stringify()` ++// * ++// * @see https://mochajs.org/api/module-utils.html#.stringify ++// */ ++// function stringify(value: any): string; ++ ++// /** ++// * Return a new Thing that has the keys in sorted order. Recursive. ++// * ++// * If the Thing... ++// * - has already been seen, return string `'[Circular]'` ++// * - is `undefined`, return string `'[undefined]'` ++// * - is `null`, return value `null` ++// * - is some other primitive, return the value ++// * - is not a primitive or an `Array`, `Object`, or `Function`, return the value of the Thing's `toString()` method ++// * - is a non-empty `Array`, `Object`, or `Function`, return the result of calling this function again. ++// * - is an empty `Array`, `Object`, or `Function`, returns `'[]'`, `'{}'`, or `'[Function]'` respectively. ++// * ++// * @see https://mochajs.org/api/module-utils.html#.canonicalize ++// */ ++// function canonicalize(value: any, stack: any[], typeHint: string): any; ++ ++// /** ++// * Lookup file names at the given `path`. ++// * ++// * @see https://mochajs.org/api/Mocha.utils.html#.exports.lookupFiles ++// */ ++// function lookupFiles(filepath: string, extensions?: string[], recursive?: boolean): string[]; ++ ++// /** ++// * Generate an undefined error with a message warning the user. ++// * ++// * @see https://mochajs.org/api/module-utils.html#.undefinedError ++// */ ++// function undefinedError(): Error; ++ ++// /** ++// * Generate an undefined error if `err` is not defined. ++// * ++// * @see https://mochajs.org/api/module-utils.html#.getError ++// */ ++// function getError(err: Error | undefined): Error; ++ ++// /** ++// * When invoking this function you get a filter function that get the Error.stack as an ++// * input, and return a prettify output. (i.e: strip Mocha and internal node functions from ++// * stack trace). ++// * ++// * @see https://mochajs.org/api/module-utils.html#.stackTraceFilter ++// */ ++// function stackTraceFilter(): (stack: string) => string; ++// } ++ ++// namespace interfaces { ++// function bdd(suite: Suite): void; ++// function tdd(suite: Suite): void; ++// function qunit(suite: Suite): void; ++// function exports(suite: Suite): void; ++// } ++ ++// // #region Test interface augmentations ++ ++// interface HookFunction { ++// /** ++// * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the ++// * function is used as the name of the hook. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (fn: Func): void; ++ ++// /** ++// * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the ++// * function is used as the name of the hook. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (fn: AsyncFunc): void; ++ ++// /** ++// * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (name: string, fn?: Func): void; ++ ++// /** ++// * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (name: string, fn?: AsyncFunc): void; ++// } ++ ++// interface SuiteFunction { ++// /** ++// * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing ++// * nested suites. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (title: string, fn: (this: Suite) => void): Suite; ++ ++// /** ++// * [qunit] Describe a "suite" with the given `title`. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (title: string): Suite; ++ ++// /** ++// * [bdd, tdd, qunit] Indicates this suite should be executed exclusively. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// only: ExclusiveSuiteFunction; ++ ++// /** ++// * [bdd, tdd] Indicates this suite should not be executed. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// skip: PendingSuiteFunction; ++// } ++ ++// interface ExclusiveSuiteFunction { ++// /** ++// * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing ++// * nested suites. Indicates this suite should be executed exclusively. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (title: string, fn: (this: Suite) => void): Suite; ++ ++// /** ++// * [qunit] Describe a "suite" with the given `title`. Indicates this suite should be executed ++// * exclusively. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (title: string): Suite; ++// } ++ ++// /** ++// * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing ++// * nested suites. Indicates this suite should not be executed. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @returns [bdd] `Suite` ++// * @returns [tdd] `void` ++// */ ++// interface PendingSuiteFunction { ++// (title: string, fn: (this: Suite) => void): Suite | void; ++// } ++ ++// interface TestFunction { ++// /** ++// * Describe a specification or test-case with the given callback `fn` acting as a thunk. ++// * The name of the function is used as the name of the test. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (fn: Func): Test; ++ ++// /** ++// * Describe a specification or test-case with the given callback `fn` acting as a thunk. ++// * The name of the function is used as the name of the test. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (fn: AsyncFunc): Test; ++ ++// /** ++// * Describe a specification or test-case with the given `title` and callback `fn` acting ++// * as a thunk. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (title: string, fn?: Func): Test; ++ ++// /** ++// * Describe a specification or test-case with the given `title` and callback `fn` acting ++// * as a thunk. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (title: string, fn?: AsyncFunc): Test; ++ ++// /** ++// * Indicates this test should be executed exclusively. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// only: ExclusiveTestFunction; ++ ++// /** ++// * Indicates this test should not be executed. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// skip: PendingTestFunction; ++ ++// /** ++// * Number of attempts to retry. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// retries(n: number): void; ++// } ++ ++// interface ExclusiveTestFunction { ++// /** ++// * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` ++// * acting as a thunk. The name of the function is used as the name of the test. Indicates ++// * this test should be executed exclusively. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (fn: Func): Test; ++ ++// /** ++// * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` ++// * acting as a thunk. The name of the function is used as the name of the test. Indicates ++// * this test should be executed exclusively. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (fn: AsyncFunc): Test; ++ ++// /** ++// * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and ++// * callback `fn` acting as a thunk. Indicates this test should be executed exclusively. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (title: string, fn?: Func): Test; ++ ++// /** ++// * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and ++// * callback `fn` acting as a thunk. Indicates this test should be executed exclusively. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (title: string, fn?: AsyncFunc): Test; ++// } ++ ++// interface PendingTestFunction { ++// /** ++// * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` ++// * acting as a thunk. The name of the function is used as the name of the test. Indicates ++// * this test should not be executed. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (fn: Func): Test; ++ ++// /** ++// * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` ++// * acting as a thunk. The name of the function is used as the name of the test. Indicates ++// * this test should not be executed. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (fn: AsyncFunc): Test; ++ ++// /** ++// * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and ++// * callback `fn` acting as a thunk. Indicates this test should not be executed. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (title: string, fn?: Func): Test; ++ ++// /** ++// * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and ++// * callback `fn` acting as a thunk. Indicates this test should not be executed. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// (title: string, fn?: AsyncFunc): Test; ++// } ++ ++// /** ++// * Execute after each test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#afterEach ++// */ ++// let afterEach: HookFunction; ++ ++// /** ++// * Execute after running tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#after ++// */ ++// let after: HookFunction; ++ ++// /** ++// * Execute before each test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#beforeEach ++// */ ++// let beforeEach: HookFunction; ++ ++// /** ++// * Execute before running tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#before ++// */ ++// let before: HookFunction; ++ ++// /** ++// * Describe a "suite" containing nested suites and tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// let describe: SuiteFunction; ++ ++// /** ++// * Describes a test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// let it: TestFunction; ++ ++// /** ++// * Describes a pending test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// let xit: PendingTestFunction; ++ ++// /** ++// * Execute before each test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#beforeEach ++// */ ++// let setup: HookFunction; ++ ++// /** ++// * Execute before running tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#before ++// */ ++// let suiteSetup: HookFunction; ++ ++// /** ++// * Execute after running tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#after ++// */ ++// let suiteTeardown: HookFunction; ++ ++// /** ++// * Describe a "suite" containing nested suites and tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// let suite: SuiteFunction; ++ ++// /** ++// * Execute after each test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#afterEach ++// */ ++// let teardown: HookFunction; ++ ++// /** ++// * Describes a test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// let test: TestFunction; ++ ++// /** ++// * Triggers root suite execution. ++// * ++// * - _Only available if flag --delay is passed into Mocha._ ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#runWithSuite ++// */ ++// function run(): void; ++ ++// // #endregion Test interface augmentations ++ ++// namespace reporters { ++// /** ++// * Initialize a new `Base` reporter. ++// * ++// * All other reporters generally inherit from this reporter, providing stats such as test duration, ++// * number of tests passed / failed, etc. ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.Base.html ++// */ ++// class Base { ++// constructor(runner: Runner, options?: MochaOptions); ++ ++// /** ++// * Test run statistics ++// */ ++// stats: Stats; ++ ++// /** ++// * Test failures ++// */ ++// failures: Test[]; ++ ++// /** ++// * The configured runner ++// */ ++// runner: Runner; ++ ++// /** ++// * Output common epilogue used by many of the bundled reporters. ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.Base.html#.Base#epilogue ++// */ ++// epilogue(): void; ++ ++// done?(failures: number, fn?: (failures: number) => void): void; ++// } ++ ++// namespace Base { ++// /** ++// * Enables coloring by default ++// * ++// * @see https://mochajs.org/api/module-base#.useColors ++// */ ++// let useColors: boolean; ++ ++// /** ++// * Inline diffs instead of +/- ++// * ++// * @see https://mochajs.org/api/module-base#.inlineDiffs ++// */ ++// let inlineDiffs: boolean; ++ ++// /** ++// * Default color map ++// * ++// * @see https://mochajs.org/api/module-base#.colors ++// */ ++// const colors: ColorMap; ++ ++// /** ++// * Default color map ++// * ++// * @see https://mochajs.org/api/module-base#.colors ++// */ ++// interface ColorMap { ++// // added by Base ++// pass: number; ++// fail: number; ++// "bright pass": number; ++// "bright fail": number; ++// "bright yellow": number; ++// pending: number; ++// suite: number; ++// "error title": number; ++// "error message": number; ++// "error stack": number; ++// checkmark: number; ++// fast: number; ++// medium: number; ++// slow: number; ++// green: number; ++// light: number; ++// "diff gutter": number; ++// "diff added": number; ++// "diff removed": number; ++ ++// // added by Progress ++// progress: number; ++ ++// // added by Landing ++// plane: number; ++// "plane crash": number; ++// runway: number; ++ ++// [key: string]: number; ++// } ++ ++// /** ++// * Default symbol map ++// * ++// * @see https://mochajs.org/api/module-base#.symbols ++// */ ++// const symbols: SymbolMap; ++ ++// /** ++// * Default symbol map ++// * ++// * @see https://mochajs.org/api/module-base#.symbols ++// */ ++// interface SymbolMap { ++// ok: string; ++// err: string; ++// dot: string; ++// comma: string; ++// bang: string; ++// [key: string]: string; ++// } ++ ++// /** ++// * Color `str` with the given `type` (from `colors`) ++// * ++// * @see https://mochajs.org/api/module-base#.color ++// */ ++// function color(type: string, str: string): string; ++ ++// /** ++// * Expose terminal window size ++// * ++// * @see https://mochajs.org/api/module-base#.window ++// */ ++// const window: { ++// width: number; ++// }; ++ ++// /** ++// * ANSI TTY control sequences common among reporters. ++// * ++// * @see https://mochajs.org/api/module-base#.cursor ++// */ ++// namespace cursor { ++// /** ++// * Hides the cursor ++// */ ++// function hide(): void; ++ ++// /** ++// * Shows the cursor ++// */ ++// function show(): void; ++ ++// /** ++// * Deletes the current line ++// */ ++// function deleteLine(): void; ++ ++// /** ++// * Moves to the beginning of the line ++// */ ++// function beginningOfLine(): void; ++ ++// /** ++// * Clears the line and moves to the beginning of the line. ++// */ ++// function CR(): void; ++// } ++ ++// /** ++// * Returns a diff between two strings with colored ANSI output. ++// * ++// * @see https://mochajs.org/api/module-base#.generateDiff ++// */ ++// function generateDiff(actual: string, expected: string): string; ++ ++// /** ++// * Output the given `failures` as a list. ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.Base.html#.exports.list1 ++// */ ++// function list(failures: Test[]): void; ++// } ++ ++// /** ++// * Initialize a new `Dot` matrix test reporter. ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.Dot.html ++// */ ++// class Dot extends Base { ++// } ++ ++// /** ++// * Initialize a new `Doc` reporter. ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.Doc.html ++// */ ++// class Doc extends Base { ++// } ++ ++// /** ++// * Initialize a new `TAP` test reporter. ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.TAP.html ++// */ ++// class TAP extends Base { ++// } ++ ++// /** ++// * Initialize a new `JSON` reporter ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.JSON.html ++// */ ++// class JSON extends Base { ++// } ++ ++// /** ++// * Initialize a new `HTML` reporter. ++// * ++// * - _This reporter cannot be used on the console._ ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.HTML.html ++// */ ++// class HTML extends Base { ++// /** ++// * Provide suite URL. ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.HTML.html#suiteURL ++// */ ++// suiteURL(suite: Suite): string; ++ ++// /** ++// * Provide test URL. ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.HTML.html#testURL ++// */ ++// testURL(test: Test): string; ++ ++// /** ++// * Adds code toggle functionality for the provided test's list element. ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.HTML.html#addCodeToggle ++// */ ++// addCodeToggle(el: HTMLLIElement, contents: string): void; ++// } ++ ++// /** ++// * Initialize a new `List` test reporter. ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.List.html ++// */ ++// class List extends Base { ++// } ++ ++// /** ++// * Initialize a new `Min` minimal test reporter (best used with --watch). ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.Min.html ++// */ ++// class Min extends Base { ++// } ++ ++// /** ++// * Initialize a new `Spec` test reporter. ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.Spec.html ++// */ ++// class Spec extends Base { ++// } ++ ++// /** ++// * Initialize a new `NyanCat` test reporter. ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.Nyan.html ++// */ ++// class Nyan extends Base { ++// private colorIndex; ++// private numberOfLines; ++// private rainbowColors; ++// private scoreboardWidth; ++// private tick; ++// private trajectories; ++// private trajectoryWidthMax; ++// private draw; ++// private drawScoreboard; ++// private appendRainbow; ++// private drawRainbow; ++// private drawNyanCat; ++// private face; ++// private cursorUp; ++// private cursorDown; ++// private generateColors; ++// private rainbowify; ++// } ++ ++// /** ++// * Initialize a new `XUnit` test reporter. ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.XUnit.html ++// */ ++// class XUnit extends Base { ++// constructor(runner: Runner, options?: XUnit.MochaOptions); ++ ++// /** ++// * Override done to close the stream (if it's a file). ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#done ++// */ ++// done(failures: number, fn: (failures: number) => void): void; ++ ++// /** ++// * Write out the given line. ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#write ++// */ ++// write(line: string): void; ++ ++// /** ++// * Output tag for the given `test.` ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#test ++// */ ++// test(test: Test): void; ++// } ++ ++// namespace XUnit { ++// interface MochaOptions extends Mocha.MochaOptions { ++// reporterOptions?: ReporterOptions; ++// } ++ ++// interface ReporterOptions { ++// output?: string; ++// suiteName?: string; ++// } ++// } ++ ++// /** ++// * Initialize a new `Markdown` test reporter. ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.Markdown.html ++// */ ++// class Markdown extends Base { ++// } ++ ++// /** ++// * Initialize a new `Progress` bar test reporter. ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.Progress.html ++// */ ++// class Progress extends Base { ++// constructor(runner: Runner, options?: Progress.MochaOptions); ++// } ++ ++// namespace Progress { ++// interface MochaOptions extends Mocha.MochaOptions { ++// reporterOptions?: ReporterOptions; ++// } ++ ++// interface ReporterOptions { ++// open?: string; ++// complete?: string; ++// incomplete?: string; ++// close?: string; ++// verbose?: boolean; ++// } ++// } ++ ++// /** ++// * Initialize a new `Landing` reporter. ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.Landing.html ++// */ ++// class Landing extends Base { ++// } ++ ++// /** ++// * Initialize a new `JSONStream` test reporter. ++// * ++// * @see https://mochajs.org/api/Mocha.reporters.JSONStream.html ++// */ ++// class JSONStream extends Base { ++// } ++ ++// // value-only aliases ++// const base: typeof Base; ++// const dot: typeof Dot; ++// const doc: typeof Doc; ++// const tap: typeof TAP; ++// const json: typeof JSON; ++// const html: typeof HTML; ++// const list: typeof List; ++// const spec: typeof Spec; ++// const nyan: typeof Nyan; ++// const xunit: typeof XUnit; ++// const markdown: typeof Markdown; ++// const progress: typeof Progress; ++// const landing: typeof Landing; ++// // NOTE: not possible to type this correctly: ++// // const "json-stream": typeof JSONStream; ++// } ++ ++// /** ++// * Initialize a new `Runnable` with the given `title` and callback `fn`. ++// * ++// * @see https://mochajs.org/api/Runnable.html ++// */ ++// class Runnable { ++// private _slow; ++// private _retries; ++// private _currentRetry; ++// private _timeout; ++// private _timeoutError; ++ ++// constructor(title: string, fn?: Func | AsyncFunc); ++ ++// title: string; ++// fn: Func | AsyncFunc | undefined; ++// body: string; ++// async: boolean; ++// sync: boolean; ++// timedOut: boolean; ++// pending: boolean; ++// duration?: number; ++// parent?: Suite; ++// state?: "failed" | "passed"; ++// timer?: any; ++// ctx?: Context; ++// callback?: Done; ++// allowUncaught?: boolean; ++// file?: string; ++ ++// /** ++// * Get test timeout. ++// * ++// * @see https://mochajs.org/api/Runnable.html#timeout ++// */ ++// timeout(): number; ++ ++// /** ++// * Set test timeout. ++// * ++// * @see https://mochajs.org/api/Runnable.html#timeout ++// */ ++// timeout(ms: string | number): this; ++ ++// /** ++// * Get test slowness threshold. ++// * ++// * @see https://mochajs.org/api/Runnable.html#slow ++// */ ++// slow(): number; ++ ++// /** ++// * Set test slowness threshold. ++// * ++// * @see https://mochajs.org/api/Runnable.html#slow ++// */ ++// slow(ms: string | number): this; ++ ++// /** ++// * Halt and mark as pending. ++// */ ++// skip(): never; ++ ++// /** ++// * Check if this runnable or its parent suite is marked as pending. ++// * ++// * @see https://mochajs.org/api/Runnable.html#isPending ++// */ ++// isPending(): boolean; ++ ++// /** ++// * Return `true` if this Runnable has failed. ++// */ ++// isFailed(): boolean; ++ ++// /** ++// * Return `true` if this Runnable has passed. ++// */ ++// isPassed(): boolean; ++ ++// /** ++// * Set or get number of retries. ++// * ++// * @see https://mochajs.org/api/Runnable.html#retries ++// */ ++// retries(): number; ++ ++// /** ++// * Set or get number of retries. ++// * ++// * @see https://mochajs.org/api/Runnable.html#retries ++// */ ++// retries(n: number): void; ++ ++// /** ++// * Set or get current retry ++// * ++// * @see https://mochajs.org/api/Runnable.html#currentRetry ++// */ ++// protected currentRetry(): number; ++ ++// /** ++// * Set or get current retry ++// * ++// * @see https://mochajs.org/api/Runnable.html#currentRetry ++// */ ++// protected currentRetry(n: number): void; ++ ++// /** ++// * Return the full title generated by recursively concatenating the parent's full title. ++// */ ++// fullTitle(): string; ++ ++// /** ++// * Return the title path generated by concatenating the parent's title path with the title. ++// */ ++// titlePath(): string[]; ++ ++// /** ++// * Clear the timeout. ++// * ++// * @see https://mochajs.org/api/Runnable.html#clearTimeout ++// */ ++// clearTimeout(): void; ++ ++// /** ++// * Inspect the runnable void of private properties. ++// * ++// * @see https://mochajs.org/api/Runnable.html#inspect ++// */ ++// inspect(): string; ++ ++// /** ++// * Reset the timeout. ++// * ++// * @see https://mochajs.org/api/Runnable.html#resetTimeout ++// */ ++// resetTimeout(): void; ++ ++// /** ++// * Get a list of whitelisted globals for this test run. ++// * ++// * @see https://mochajs.org/api/Runnable.html#globals ++// */ ++// globals(): string[]; ++ ++// /** ++// * Set a list of whitelisted globals for this test run. ++// * ++// * @see https://mochajs.org/api/Runnable.html#globals ++// */ ++// globals(globals: ReadonlyArray): void; ++ ++// /** ++// * Run the test and invoke `fn(err)`. ++// * ++// * @see https://mochajs.org/api/Runnable.html#run ++// */ ++// run(fn: Done): void; ++// } ++ ++// // #region Runnable "error" event ++// interface Runnable extends NodeJS.EventEmitter { ++// on(event: "error", listener: (error: any) => void): this; ++// once(event: "error", listener: (error: any) => void): this; ++// addListener(event: "error", listener: (error: any) => void): this; ++// removeListener(event: "error", listener: (error: any) => void): this; ++// prependListener(event: "error", listener: (error: any) => void): this; ++// prependOnceListener(event: "error", listener: (error: any) => void): this; ++// emit(name: "error", error: any): boolean; ++// } ++// // #endregion Runnable "error" event ++// // #region Runnable untyped events ++// interface Runnable extends NodeJS.EventEmitter { ++// on(event: string, listener: (...args: any[]) => void): this; ++// once(event: string, listener: (...args: any[]) => void): this; ++// addListener(event: string, listener: (...args: any[]) => void): this; ++// removeListener(event: string, listener: (...args: any[]) => void): this; ++// prependListener(event: string, listener: (...args: any[]) => void): this; ++// prependOnceListener(event: string, listener: (...args: any[]) => void): this; ++// emit(name: string, ...args: any[]): boolean; ++// } ++// // #endregion Runnable untyped events ++ ++// /** ++// * Test context ++// * ++// * @see https://mochajs.org/api/module-Context.html#~Context ++// */ ++// class Context { ++// private _runnable; ++ ++// test?: Runnable; ++// currentTest?: Test; ++ ++// /** ++// * Get the context `Runnable`. ++// */ ++// runnable(): Runnable; ++ ++// /** ++// * Set the context `Runnable`. ++// */ ++// runnable(runnable: Runnable): this; ++ ++// /** ++// * Get test timeout. ++// */ ++// timeout(): number; ++ ++// /** ++// * Set test timeout. ++// */ ++// timeout(ms: string | number): this; ++ ++// /** ++// * Get test slowness threshold. ++// */ ++// slow(): number; ++ ++// /** ++// * Set test slowness threshold. ++// */ ++// slow(ms: string | number): this; ++ ++// /** ++// * Mark a test as skipped. ++// */ ++// skip(): never; ++ ++// /** ++// * Get the number of allowed retries on failed tests. ++// */ ++// retries(): number; ++ ++// /** ++// * Set the number of allowed retries on failed tests. ++// */ ++// retries(n: number): this; ++ ++// [key: string]: any; ++// } ++ ++// interface RunnerConstants { ++// readonly EVENT_HOOK_BEGIN: 'hook'; ++// readonly EVENT_HOOK_END: 'hook end'; ++// readonly EVENT_RUN_BEGIN: 'start'; ++// readonly EVENT_DELAY_BEGIN: 'waiting'; ++// readonly EVENT_DELAY_END: 'ready'; ++// readonly EVENT_RUN_END: 'end'; ++// readonly EVENT_SUITE_BEGIN: 'suite'; ++// readonly EVENT_SUITE_END: 'suite end'; ++// readonly EVENT_TEST_BEGIN: 'test'; ++// readonly EVENT_TEST_END: 'test end'; ++// readonly EVENT_TEST_FAIL: 'fail'; ++// readonly EVENT_TEST_PASS: 'pass'; ++// readonly EVENT_TEST_PENDING: 'pending'; ++// readonly EVENT_TEST_RETRY: 'retry'; ++// readonly STATE_IDLE: 'idle'; ++// readonly STATE_RUNNING: 'running'; ++// readonly STATE_STOPPED: 'stopped'; ++// } ++ ++// /** ++// * Initialize a `Runner` for the given `suite`. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html ++// */ ++// class Runner { ++// private _globals; ++// private _abort; ++// private _delay; ++// private _defaultGrep; ++// private next; ++// private hookErr; ++// private prevGlobalsLength; ++// private nextSuite; ++ ++// static readonly constants: RunnerConstants; ++ ++// constructor(suite: Suite, delay: boolean); ++ ++// suite: Suite; ++// started: boolean; ++// total: number; ++// failures: number; ++// asyncOnly?: boolean; ++// allowUncaught?: boolean; ++// fullStackTrace?: boolean; ++// forbidOnly?: boolean; ++// forbidPending?: boolean; ++// checkLeaks?: boolean; ++// test?: Test; ++// currentRunnable?: Runnable; ++// stats?: Stats; // added by reporters ++ ++// /** ++// * Removes all event handlers set during a run on this instance. ++// * Remark: this does *not* clean/dispose the tests or suites themselves. ++// * ++// * @see https://mochajs.org/api/runner#dispose ++// */ ++// dispose(): void; ++ ++// /** ++// * Run tests with full titles matching `re`. Updates runner.total ++// * with number of tests matched. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grep ++// */ ++// grep(re: RegExp, invert: boolean): this; ++ ++// /** ++// * Returns the number of tests matching the grep search for the ++// * given suite. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grepTotal ++// */ ++// grepTotal(suite: Suite): number; ++ ++// /** ++// * Gets the allowed globals. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals ++// */ ++// globals(): string[]; ++ ++// /** ++// * Allow the given `arr` of globals. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals ++// */ ++// globals(arr: ReadonlyArray): this; ++ ++// /** ++// * Run the root suite and invoke `fn(failures)` on completion. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#run ++// */ ++// run(fn?: (failures: number) => void): this; ++ ++// /** ++// * Cleanly abort execution. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#abort ++// */ ++// abort(): this; ++ ++// /** ++// * Handle uncaught exceptions. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#uncaught ++// */ ++// uncaught(err: any): void; ++ ++// /** ++// * Wrapper for setImmediate, process.nextTick, or browser polyfill. ++// */ ++// protected static immediately(callback: Function): void; ++ ++// /** ++// * Return a list of global properties. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#globalProps ++// */ ++// protected globalProps(): string[]; ++ ++// /** ++// * Check for global variable leaks. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#checkGlobals ++// */ ++// protected checkGlobals(test: Test): void; ++ ++// /** ++// * Fail the given `test`. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#fail ++// */ ++// protected fail(test: Test, err: any): void; ++ ++// /** ++// * Fail the given `hook` with `err`. ++// * ++// * Hook failures work in the following pattern: ++// * - If bail, then exit ++// * - Failed `before` hook skips all tests in a suite and subsuites, ++// * but jumps to corresponding `after` hook ++// * - Failed `before each` hook skips remaining tests in a ++// * suite and jumps to corresponding `after each` hook, ++// * which is run only once ++// * - Failed `after` hook does not alter ++// * execution order ++// * - Failed `after each` hook skips remaining tests in a ++// * suite and subsuites, but executes other `after each` ++// * hooks ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#failHook ++// */ ++// protected failHook(hook: Hook, err: any): void; ++ ++// /** ++// * Run hook `name` callbacks and then invoke `fn()`. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#hook ++// */ ++// protected hook(name: string, fn: () => void): void; ++ ++// /** ++// * Run hook `name` for the given array of `suites` ++// * in order, and callback `fn(err, errSuite)`. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#hooks ++// */ ++// protected hooks(name: string, suites: Suite[], fn: (err?: any, errSuite?: Suite) => void): void; ++ ++// /** ++// * Run hooks from the top level down. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#hookUp ++// */ ++// protected hookUp(name: string, fn: (err?: any, errSuite?: Suite) => void): void; ++ ++// /** ++// * Run hooks from the bottom up. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#hookDown ++// */ ++// protected hookDown(name: string, fn: (err?: any, errSuite?: Suite) => void): void; ++ ++// /** ++// * Return an array of parent Suites from closest to furthest. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#parents ++// */ ++// protected parents(): Suite[]; ++ ++// /** ++// * Run the current test and callback `fn(err)`. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#runTest ++// */ ++// protected runTest(fn: Done): any; ++ ++// /** ++// * Run tests in the given `suite` and invoke the callback `fn()` when complete. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#runTests ++// */ ++// protected runTests(suite: Suite, fn: (errSuite?: Suite) => void): void; ++ ++// /** ++// * Run the given `suite` and invoke the callback `fn()` when complete. ++// * ++// * @see https://mochajs.org/api/Mocha.Runner.html#runSuite ++// */ ++// protected runSuite(suite: Suite, fn: (errSuite?: Suite) => void): void; ++// } ++ ++// // #region Runner "waiting" event ++// interface Runner { ++// on(event: "waiting", listener: (rootSuite: Suite) => void): this; ++// once(event: "waiting", listener: (rootSuite: Suite) => void): this; ++// addListener(event: "waiting", listener: (rootSuite: Suite) => void): this; ++// removeListener(event: "waiting", listener: (rootSuite: Suite) => void): this; ++// prependListener(event: "waiting", listener: (rootSuite: Suite) => void): this; ++// prependOnceListener(event: "waiting", listener: (rootSuite: Suite) => void): this; ++// emit(name: "waiting", rootSuite: Suite): boolean; ++// } ++// // #endregion Runner "waiting" event ++// // #region Runner "start" event ++// interface Runner extends NodeJS.EventEmitter { ++// on(event: "start", listener: () => void): this; ++// once(event: "start", listener: () => void): this; ++// addListener(event: "start", listener: () => void): this; ++// removeListener(event: "start", listener: () => void): this; ++// prependListener(event: "start", listener: () => void): this; ++// prependOnceListener(event: "start", listener: () => void): this; ++// emit(name: "start"): boolean; ++// } ++// // #endregion Runner "start" event ++// // #region Runner "end" event ++// interface Runner extends NodeJS.EventEmitter { ++// on(event: "end", listener: () => void): this; ++// once(event: "end", listener: () => void): this; ++// addListener(event: "end", listener: () => void): this; ++// removeListener(event: "end", listener: () => void): this; ++// prependListener(event: "end", listener: () => void): this; ++// prependOnceListener(event: "end", listener: () => void): this; ++// emit(name: "end"): boolean; ++// } ++// // #endregion Runner "end" event ++// // #region Runner "suite" event ++// interface Runner extends NodeJS.EventEmitter { ++// on(event: "suite", listener: (suite: Suite) => void): this; ++// once(event: "suite", listener: (suite: Suite) => void): this; ++// addListener(event: "suite", listener: (suite: Suite) => void): this; ++// removeListener(event: "suite", listener: (suite: Suite) => void): this; ++// prependListener(event: "suite", listener: (suite: Suite) => void): this; ++// prependOnceListener(event: "suite", listener: (suite: Suite) => void): this; ++// emit(name: "suite", suite: Suite): boolean; ++// } ++// // #endregion Runner "suite" event ++// // #region Runner "suite end" event ++// interface Runner extends NodeJS.EventEmitter { ++// on(event: "suite end", listener: (suite: Suite) => void): this; ++// once(event: "suite end", listener: (suite: Suite) => void): this; ++// addListener(event: "suite end", listener: (suite: Suite) => void): this; ++// removeListener(event: "suite end", listener: (suite: Suite) => void): this; ++// prependListener(event: "suite end", listener: (suite: Suite) => void): this; ++// prependOnceListener(event: "suite end", listener: (suite: Suite) => void): this; ++// emit(name: "suite end", suite: Suite): boolean; ++// } ++// // #endregion Runner "suite end" event ++// // #region Runner "test" event ++// interface Runner extends NodeJS.EventEmitter { ++// on(event: "test", listener: (test: Test) => void): this; ++// once(event: "test", listener: (test: Test) => void): this; ++// addListener(event: "test", listener: (test: Test) => void): this; ++// removeListener(event: "test", listener: (test: Test) => void): this; ++// prependListener(event: "test", listener: (test: Test) => void): this; ++// prependOnceListener(event: "test", listener: (test: Test) => void): this; ++// emit(name: "test", test: Test): boolean; ++// } ++// // #endregion Runner "test" event ++// // #region Runner "test end" event ++// interface Runner extends NodeJS.EventEmitter { ++// on(event: "test end", listener: (test: Test) => void): this; ++// once(event: "test end", listener: (test: Test) => void): this; ++// addListener(event: "test end", listener: (test: Test) => void): this; ++// removeListener(event: "test end", listener: (test: Test) => void): this; ++// prependListener(event: "test end", listener: (test: Test) => void): this; ++// prependOnceListener(event: "test end", listener: (test: Test) => void): this; ++// emit(name: "test end", test: Test): boolean; ++// } ++// // #endregion Runner "test end" event ++// // #region Runner "hook" event ++// interface Runner extends NodeJS.EventEmitter { ++// on(event: "hook", listener: (hook: Hook) => void): this; ++// once(event: "hook", listener: (hook: Hook) => void): this; ++// addListener(event: "hook", listener: (hook: Hook) => void): this; ++// removeListener(event: "hook", listener: (hook: Hook) => void): this; ++// prependListener(event: "hook", listener: (hook: Hook) => void): this; ++// prependOnceListener(event: "hook", listener: (hook: Hook) => void): this; ++// emit(name: "hook", hook: Hook): boolean; ++// } ++// // #endregion Runner "hook" event ++// // #region Runner "hook end" event ++// interface Runner extends NodeJS.EventEmitter { ++// on(event: "hook end", listener: (hook: Hook) => void): this; ++// once(event: "hook end", listener: (hook: Hook) => void): this; ++// addListener(event: "hook end", listener: (hook: Hook) => void): this; ++// removeListener(event: "hook end", listener: (hook: Hook) => void): this; ++// prependListener(event: "hook end", listener: (hook: Hook) => void): this; ++// prependOnceListener(event: "hook end", listener: (hook: Hook) => void): this; ++// emit(name: "hook end", hook: Hook): boolean; ++// } ++// // #endregion Runner "hook end" event ++// // #region Runner "pass" event ++// interface Runner extends NodeJS.EventEmitter { ++// on(event: "pass", listener: (test: Test) => void): this; ++// once(event: "pass", listener: (test: Test) => void): this; ++// addListener(event: "pass", listener: (test: Test) => void): this; ++// removeListener(event: "pass", listener: (test: Test) => void): this; ++// prependListener(event: "pass", listener: (test: Test) => void): this; ++// prependOnceListener(event: "pass", listener: (test: Test) => void): this; ++// emit(name: "pass", test: Test): boolean; ++// } ++// // #endregion Runner "pass" event ++// // #region Runner "fail" event ++// interface Runner extends NodeJS.EventEmitter { ++// on(event: "fail", listener: (test: Test, err: any) => void): this; ++// once(event: "fail", listener: (test: Test, err: any) => void): this; ++// addListener(event: "fail", listener: (test: Test, err: any) => void): this; ++// removeListener(event: "fail", listener: (test: Test, err: any) => void): this; ++// prependListener(event: "fail", listener: (test: Test, err: any) => void): this; ++// prependOnceListener(event: "fail", listener: (test: Test, err: any) => void): this; ++// emit(name: "fail", test: Test, err: any): boolean; ++// } ++// // #endregion Runner "fail" event ++// // #region Runner "pending" event ++// interface Runner extends NodeJS.EventEmitter { ++// on(event: "pending", listener: (test: Test) => void): this; ++// once(event: "pending", listener: (test: Test) => void): this; ++// addListener(event: "pending", listener: (test: Test) => void): this; ++// removeListener(event: "pending", listener: (test: Test) => void): this; ++// prependListener(event: "pending", listener: (test: Test) => void): this; ++// prependOnceListener(event: "pending", listener: (test: Test) => void): this; ++// emit(name: "pending", test: Test): boolean; ++// } ++// // #endregion Runner "pending" event ++// // #region Runner untyped events ++// interface Runner extends NodeJS.EventEmitter { ++// on(event: string, listener: (...args: any[]) => void): this; ++// once(event: string, listener: (...args: any[]) => void): this; ++// addListener(event: string, listener: (...args: any[]) => void): this; ++// removeListener(event: string, listener: (...args: any[]) => void): this; ++// prependListener(event: string, listener: (...args: any[]) => void): this; ++// prependOnceListener(event: string, listener: (...args: any[]) => void): this; ++// emit(name: string, ...args: any[]): boolean; ++// } ++// // #endregion Runner untyped events ++ ++// interface SuiteConstants { ++// readonly EVENT_FILE_POST_REQUIRE: 'post-require'; ++// readonly EVENT_FILE_PRE_REQUIRE: 'pre-require'; ++// readonly EVENT_FILE_REQUIRE: 'require'; ++// readonly EVENT_ROOT_SUITE_RUN: 'run'; ++ ++// readonly HOOK_TYPE_AFTER_ALL: 'afterAll'; ++// readonly HOOK_TYPE_AFTER_EACH: 'afterEach'; ++// readonly HOOK_TYPE_BEFORE_ALL: 'beforeAll'; ++// readonly HOOK_TYPE_BEFORE_EACH: 'beforeEach'; ++ ++// readonly EVENT_SUITE_ADD_HOOK_AFTER_ALL: 'afterAll'; ++// readonly EVENT_SUITE_ADD_HOOK_AFTER_EACH: 'afterEach'; ++// readonly EVENT_SUITE_ADD_HOOK_BEFORE_ALL: 'beforeAll'; ++// readonly EVENT_SUITE_ADD_HOOK_BEFORE_EACH: 'beforeEach'; ++// readonly EVENT_SUITE_ADD_SUITE: 'suite'; ++// readonly EVENT_SUITE_ADD_TEST: 'test'; ++// } ++ ++// /** ++// * Initialize a new `Suite` with the given `title` and `ctx`. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html ++// */ ++// class Suite { ++// private _beforeEach; ++// private _beforeAll; ++// private _afterEach; ++// private _afterAll; ++// private _timeout; ++// private _slow; ++// private _bail; ++// private _retries; ++// private _onlyTests; ++// private _onlySuites; ++ ++// static readonly constants: SuiteConstants; ++ ++// constructor(title: string, parentContext?: Context); ++ ++// ctx: Context; ++// suites: Suite[]; ++// tests: Test[]; ++// pending: boolean; ++// file?: string; ++// root: boolean; ++// delayed: boolean; ++// parent: Suite | undefined; ++// title: string; ++ ++// /** ++// * Create a new `Suite` with the given `title` and parent `Suite`. When a suite ++// * with the same title is already present, that suite is returned to provide ++// * nicer reporter and more flexible meta-testing. ++// * ++// * @see https://mochajs.org/api/mocha#.exports.create ++// */ ++// static create(parent: Suite, title: string): Suite; ++ ++// /** ++// * Return a clone of this `Suite`. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#clone ++// */ ++// clone(): Suite; ++ ++// /** ++// * Get timeout `ms`. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#timeout ++// */ ++// timeout(): number; ++ ++// /** ++// * Set timeout `ms` or short-hand such as "2s". ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#timeout ++// */ ++// timeout(ms: string | number): this; ++ ++// /** ++// * Get number of times to retry a failed test. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#retries ++// */ ++// retries(): number; ++ ++// /** ++// * Set number of times to retry a failed test. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#retries ++// */ ++// retries(n: string | number): this; ++ ++// /** ++// * Get slow `ms`. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#slow ++// */ ++// slow(): number; ++ ++// /** ++// * Set slow `ms` or short-hand such as "2s". ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#slow ++// */ ++// slow(ms: string | number): this; ++ ++// /** ++// * Get whether to bail after first error. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#bail ++// */ ++// bail(): boolean; ++ ++// /** ++// * Set whether to bail after first error. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#bail ++// */ ++// bail(bail: boolean): this; ++ ++// /** ++// * Check if this suite or its parent suite is marked as pending. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#isPending ++// */ ++// isPending(): boolean; ++ ++// /** ++// * Run `fn(test[, done])` before running tests. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll ++// */ ++// beforeAll(fn?: Func): this; ++ ++// /** ++// * Run `fn(test[, done])` before running tests. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll ++// */ ++// beforeAll(fn?: AsyncFunc): this; ++ ++// /** ++// * Run `fn(test[, done])` before running tests. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll ++// */ ++// beforeAll(title: string, fn?: Func): this; ++ ++// /** ++// * Run `fn(test[, done])` before running tests. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll ++// */ ++// beforeAll(title: string, fn?: AsyncFunc): this; ++ ++// /** ++// * Run `fn(test[, done])` after running tests. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#afterAll ++// */ ++// afterAll(fn?: Func): this; ++ ++// /** ++// * Run `fn(test[, done])` after running tests. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#afterAll ++// */ ++// afterAll(fn?: AsyncFunc): this; ++ ++// /** ++// * Run `fn(test[, done])` after running tests. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#afterAll ++// */ ++// afterAll(title: string, fn?: Func): this; ++ ++// /** ++// * Run `fn(test[, done])` after running tests. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#afterAll ++// */ ++// afterAll(title: string, fn?: AsyncFunc): this; ++ ++// /** ++// * Run `fn(test[, done])` before each test case. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach ++// */ ++// beforeEach(fn?: Func): this; ++ ++// /** ++// * Run `fn(test[, done])` before each test case. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach ++// */ ++// beforeEach(fn?: AsyncFunc): this; ++ ++// /** ++// * Run `fn(test[, done])` before each test case. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach ++// */ ++// beforeEach(title: string, fn?: Func): this; ++ ++// /** ++// * Run `fn(test[, done])` before each test case. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach ++// */ ++// beforeEach(title: string, fn?: AsyncFunc): this; ++ ++// /** ++// * Run `fn(test[, done])` after each test case. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#afterEach ++// */ ++// afterEach(fn?: Func): this; ++ ++// /** ++// * Run `fn(test[, done])` after each test case. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#afterEach ++// */ ++// afterEach(fn?: AsyncFunc): this; ++ ++// /** ++// * Run `fn(test[, done])` after each test case. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#afterEach ++// */ ++// afterEach(title: string, fn?: Func): this; ++ ++// /** ++// * Run `fn(test[, done])` after each test case. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#afterEach ++// */ ++// afterEach(title: string, fn?: AsyncFunc): this; ++ ++// /** ++// * Add a test `suite`. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#addSuite ++// */ ++// addSuite(suite: Suite): this; ++ ++// /** ++// * Add a `test` to this suite. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#addTest ++// */ ++// addTest(test: Test): this; ++ ++// /** ++// * Cleans all references from this suite and all child suites. ++// * ++// * https://mochajs.org/api/suite#dispose ++// */ ++// dispose(): void; ++ ++// /** ++// * Return the full title generated by recursively concatenating the parent's ++// * full title. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#fullTitle ++// */ ++// fullTitle(): string; ++ ++// /** ++// * Return the title path generated by recursively concatenating the parent's ++// * title path. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#titlePath ++// */ ++// titlePath(): string[]; ++ ++// /** ++// * Return the total number of tests. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#total ++// */ ++// total(): number; ++ ++// /** ++// * Iterates through each suite recursively to find all tests. Applies a ++// * function in the format `fn(test)`. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#eachTest ++// */ ++// eachTest(fn: (test: Test) => void): this; ++ ++// /** ++// * This will run the root suite if we happen to be running in delayed mode. ++// * ++// * @see https://mochajs.org/api/Mocha.Suite.html#run ++// */ ++// run(): void; ++ ++// /** ++// * Generic hook-creator. ++// */ ++// protected _createHook(title: string, fn?: Func | AsyncFunc): Hook; ++// } ++ ++// // #region Suite "beforeAll" event ++// interface Suite extends NodeJS.EventEmitter { ++// on(event: "beforeAll", listener: (hook: Hook) => void): this; ++// once(event: "beforeAll", listener: (hook: Hook) => void): this; ++// addListener(event: "beforeAll", listener: (hook: Hook) => void): this; ++// removeListener(event: "beforeAll", listener: (hook: Hook) => void): this; ++// prependListener(event: "beforeAll", listener: (hook: Hook) => void): this; ++// prependOnceListener(event: "beforeAll", listener: (hook: Hook) => void): this; ++// emit(name: "beforeAll", hook: Hook): boolean; ++// } ++// // #endregion Suite "beforeAll" event ++// // #region Suite "afterAll" event ++// interface Suite extends NodeJS.EventEmitter { ++// on(event: "afterAll", listener: (hook: Hook) => void): this; ++// once(event: "afterAll", listener: (hook: Hook) => void): this; ++// addListener(event: "afterAll", listener: (hook: Hook) => void): this; ++// removeListener(event: "afterAll", listener: (hook: Hook) => void): this; ++// prependListener(event: "afterAll", listener: (hook: Hook) => void): this; ++// prependOnceListener(event: "afterAll", listener: (hook: Hook) => void): this; ++// emit(name: "afterAll", hook: Hook): boolean; ++// } ++// // #endregion Suite "afterAll" event ++// // #region Suite "beforeEach" event ++// interface Suite extends NodeJS.EventEmitter { ++// on(event: "beforeEach", listener: (hook: Hook) => void): this; ++// once(event: "beforeEach", listener: (hook: Hook) => void): this; ++// addListener(event: "beforeEach", listener: (hook: Hook) => void): this; ++// removeListener(event: "beforeEach", listener: (hook: Hook) => void): this; ++// prependListener(event: "beforeEach", listener: (hook: Hook) => void): this; ++// prependOnceListener(event: "beforeEach", listener: (hook: Hook) => void): this; ++// emit(name: "beforeEach", hook: Hook): boolean; ++// } ++// // #endregion Suite "beforeEach" event ++// // #region Suite "afterEach" event ++// interface Suite extends NodeJS.EventEmitter { ++// on(event: "afterEach", listener: (hook: Hook) => void): this; ++// once(event: "afterEach", listener: (hook: Hook) => void): this; ++// addListener(event: "afterEach", listener: (hook: Hook) => void): this; ++// removeListener(event: "afterEach", listener: (hook: Hook) => void): this; ++// prependListener(event: "afterEach", listener: (hook: Hook) => void): this; ++// prependOnceListener(event: "afterEach", listener: (hook: Hook) => void): this; ++// emit(name: "afterEach", hook: Hook): boolean; ++// } ++// // #endregion Suite "afterEach" event ++// // #region Suite "suite" event ++// interface Suite extends NodeJS.EventEmitter { ++// on(event: "suite", listener: (suite: Suite) => void): this; ++// once(event: "suite", listener: (suite: Suite) => void): this; ++// addListener(event: "suite", listener: (suite: Suite) => void): this; ++// removeListener(event: "suite", listener: (suite: Suite) => void): this; ++// prependListener(event: "suite", listener: (suite: Suite) => void): this; ++// prependOnceListener(event: "suite", listener: (suite: Suite) => void): this; ++// emit(name: "suite", suite: Suite): boolean; ++// } ++// // #endregion Suite "suite" event ++// // #region Suite "test" event ++// interface Suite { ++// on(event: "test", listener: (test: Test) => void): this; ++// once(event: "test", listener: (test: Test) => void): this; ++// addListener(event: "test", listener: (test: Test) => void): this; ++// removeListener(event: "test", listener: (test: Test) => void): this; ++// prependListener(event: "test", listener: (test: Test) => void): this; ++// prependOnceListener(event: "test", listener: (test: Test) => void): this; ++// emit(name: "test", test: Test): boolean; ++// } ++// // #endregion Suite "test" event ++// // #region Suite "run" event ++// interface Suite extends NodeJS.EventEmitter { ++// on(event: "run", listener: () => void): this; ++// once(event: "run", listener: () => void): this; ++// addListener(event: "run", listener: () => void): this; ++// removeListener(event: "run", listener: () => void): this; ++// prependListener(event: "run", listener: () => void): this; ++// prependOnceListener(event: "run", listener: () => void): this; ++// emit(name: "run"): boolean; ++// } ++// // #endregion Suite "run" event ++// // #region Suite "pre-require" event ++// interface Suite extends NodeJS.EventEmitter { ++// on(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++// once(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++// addListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++// removeListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++// prependListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++// prependOnceListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++// emit(name: "pre-require", context: MochaGlobals, file: string, mocha: Mocha): boolean; ++// } ++// // #endregion Suite "pre-require" event ++// // #region Suite "require" event ++// interface Suite extends NodeJS.EventEmitter { ++// on(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; ++// once(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; ++// addListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; ++// removeListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; ++// prependListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; ++// prependOnceListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; ++// emit(name: "require", module: any, file: string, mocha: Mocha): boolean; ++// } ++// // #endregion Suite "require" event ++// // #region Suite "post-require" event ++// interface Suite extends NodeJS.EventEmitter { ++// on(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++// once(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++// addListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++// removeListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++// prependListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++// prependOnceListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++// emit(name: "post-require", context: MochaGlobals, file: string, mocha: Mocha): boolean; ++// } ++// // #endregion Suite "post-require" event ++// // #region Suite untyped events ++// interface Suite extends NodeJS.EventEmitter { ++// on(event: string, listener: (...args: any[]) => void): this; ++// once(event: string, listener: (...args: any[]) => void): this; ++// addListener(event: string, listener: (...args: any[]) => void): this; ++// removeListener(event: string, listener: (...args: any[]) => void): this; ++// prependListener(event: string, listener: (...args: any[]) => void): this; ++// prependOnceListener(event: string, listener: (...args: any[]) => void): this; ++// emit(name: string, ...args: any[]): boolean; ++// } ++// // #endregion Runner untyped events ++ ++// /** ++// * Initialize a new `Hook` with the given `title` and callback `fn` ++// * ++// * @see https://mochajs.org/api/Hook.html ++// */ ++// class Hook extends Runnable { ++// private _error; ++ ++// type: "hook"; ++// originalTitle?: string; // added by Runner ++ ++// /** ++// * Get the test `err`. ++// * ++// * @see https://mochajs.org/api/Hook.html#error ++// */ ++// error(): any; ++ ++// /** ++// * Set the test `err`. ++// * ++// * @see https://mochajs.org/api/Hook.html#error ++// */ ++// error(err: any): void; ++// } ++ ++// /** ++// * An alternative way to define root hooks that works with parallel runs. ++// * ++// * Root hooks work with any interface, but the property names do not change. ++// * In other words, if you are using the tdd interface, suiteSetup maps to beforeAll, and setup maps to beforeEach. ++// * ++// * As with other hooks, `this` refers to to the current context object. ++// * ++// * @see https://mochajs.org/#root-hook-plugins ++// */ ++// interface RootHookObject { ++// /** ++// * In serial mode, run after all tests end, once only. ++// * In parallel mode, run after all tests end, for each file. ++// */ ++// afterAll?: Func | AsyncFunc | Func[] | AsyncFunc[]; ++// /** ++// * In serial mode (Mocha's default), before all tests begin, once only. ++// * In parallel mode, run before all tests begin, for each file. ++// */ ++// beforeAll?: Func | AsyncFunc | Func[] | AsyncFunc[]; ++// /** ++// * In both modes, run after every test. ++// */ ++// afterEach?: Func | AsyncFunc | Func[] | AsyncFunc[]; ++// /** ++// * In both modes, run before each test. ++// */ ++// beforeEach?: Func | AsyncFunc | Func[] | AsyncFunc[]; ++// } ++ ++// /** ++// * Initialize a new `Test` with the given `title` and callback `fn`. ++// * ++// * @see https://mochajs.org/api/Test.html ++// */ ++// class Test extends Runnable { ++// type: "test"; ++// speed?: "slow" | "medium" | "fast"; // added by reporters ++// err?: Error; // added by reporters ++// clone(): Test; ++// } ++ ++// /** ++// * Test statistics ++// */ ++// interface Stats { ++// suites: number; ++// tests: number; ++// passes: number; ++// pending: number; ++// failures: number; ++// start?: Date; ++// end?: Date; ++// duration?: number; ++// } ++ ++// type TestInterface = (suite: Suite) => void; ++ ++// interface ReporterConstructor { ++// new (runner: Runner, options: MochaOptions): reporters.Base; ++// } ++ ++// type Done = (err?: any) => void; ++ ++// /** ++// * Callback function used for tests and hooks. ++// */ ++// type Func = (this: Context, done: Done) => void; ++ ++// /** ++// * Async callback function used for tests and hooks. ++// */ ++// type AsyncFunc = (this: Context) => PromiseLike; ++ ++// /** ++// * Options to pass to Mocha. ++// */ ++// interface MochaOptions { ++// /** Test interfaces ("bdd", "tdd", "exports", etc.). */ ++// ui?: Interface; ++ ++// /** ++// * Reporter constructor, built-in reporter name, or reporter module path. Defaults to ++// * `"spec"`. ++// */ ++// reporter?: string | ReporterConstructor; ++ ++// /** Options to pass to the reporter. */ ++// reporterOptions?: any; ++ ++// /** Array of accepted globals. */ ++// globals?: string[]; ++ ++// /** timeout in milliseconds or time string like '1s'. */ ++// timeout?: number | string; ++ ++// /** number of times to retry failed tests. */ ++// retries?: number; ++ ++// /** bail on the first test failure. */ ++// bail?: boolean; ++ ++// /** milliseconds to wait before considering a test slow. */ ++// slow?: number; ++ ++// /** check for global variable leaks. */ ++// checkLeaks?: boolean; ++ ++// /** display the full stack trace on failure. */ ++// fullStackTrace?: boolean; ++ ++// /** string or regexp to filter tests with. */ ++// grep?: string | RegExp; ++ ++// /** Enable growl support. */ ++// growl?: boolean; ++ ++// /** Color TTY output from reporter */ ++// color?: boolean; ++ ++// /** Use inline diffs rather than +/-. */ ++// inlineDiffs?: boolean; ++ ++// /** Do not show diffs at all. */ ++// hideDiff?: boolean; ++ ++// /** Run job in parallel */ ++// parallel?: boolean; ++ ++// /** Max number of worker processes for parallel runs */ ++// jobs?: number; ++ ++// /** Assigns hooks to the root suite */ ++// rootHooks?: RootHookObject; ++ ++// asyncOnly?: boolean; ++// delay?: boolean; ++// forbidOnly?: boolean; ++// forbidPending?: boolean; ++// noHighlighting?: boolean; ++// allowUncaught?: boolean; ++// fullTrace?: boolean; ++// } ++ ++// interface MochaInstanceOptions extends MochaOptions { ++// files?: string[]; ++// } ++ ++// /** ++// * Variables added to the global scope by Mocha when run in the CLI. ++// */ ++// interface MochaGlobals { ++// /** ++// * Execute before running tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#before ++// */ ++// before: HookFunction; ++ ++// /** ++// * Execute after running tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#after ++// */ ++// after: HookFunction; ++ ++// /** ++// * Execute before each test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#beforeEach ++// */ ++// beforeEach: HookFunction; ++ ++// /** ++// * Execute after each test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#afterEach ++// */ ++// afterEach: HookFunction; ++ ++// /** ++// * Describe a "suite" containing nested suites and tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// describe: SuiteFunction; ++ ++// /** ++// * Describe a "suite" containing nested suites and tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// context: SuiteFunction; ++ ++// /** ++// * Pending suite. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// xdescribe: PendingSuiteFunction; ++ ++// /** ++// * Pending suite. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// xcontext: PendingSuiteFunction; ++ ++// /** ++// * Describes a test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// it: TestFunction; ++ ++// /** ++// * Describes a test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// specify: TestFunction; ++ ++// /** ++// * Describes a pending test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// xit: PendingTestFunction; ++ ++// /** ++// * Describes a pending test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// xspecify: PendingTestFunction; ++ ++// /** ++// * Execute before running tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#before ++// */ ++// suiteSetup: HookFunction; ++ ++// /** ++// * Execute after running tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#after ++// */ ++// suiteTeardown: HookFunction; ++ ++// /** ++// * Execute before each test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#beforeEach ++// */ ++// setup: HookFunction; ++ ++// /** ++// * Execute after each test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#afterEach ++// */ ++// teardown: HookFunction; ++ ++// /** ++// * Describe a "suite" containing nested suites and tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// suite: SuiteFunction; ++ ++// /** ++// * Describes a test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// test: TestFunction; ++ ++// run: typeof run; ++// } ++ ++// /** ++// * Third-party declarations that want to add new entries to the `Reporter` union can ++// * contribute names here. ++// */ ++// interface ReporterContributions { ++// Base: never; ++// base: never; ++// Dot: never; ++// dot: never; ++// TAP: never; ++// tap: never; ++// JSON: never; ++// json: never; ++// HTML: never; ++// html: never; ++// List: never; ++// list: never; ++// Min: never; ++// min: never; ++// Spec: never; ++// spec: never; ++// Nyan: never; ++// nyan: never; ++// XUnit: never; ++// xunit: never; ++// Markdown: never; ++// markdown: never; ++// Progress: never; ++// progress: never; ++// Landing: never; ++// landing: never; ++// JSONStream: never; ++// "json-stream": never; ++// } ++ ++// type Reporter = keyof ReporterContributions; ++ ++// /** ++// * Third-party declarations that want to add new entries to the `Interface` union can ++// * contribute names here. ++// */ ++// interface InterfaceContributions { ++// bdd: never; ++// tdd: never; ++// qunit: never; ++// exports: never; ++// } ++ ++// type Interface = keyof InterfaceContributions; ++// } ++ ++// // #region Test interface augmentations ++ ++// /** ++// * Triggers root suite execution. ++// * ++// * - _Only available if flag --delay is passed into Mocha._ ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#runWithSuite ++// */ ++// declare function run(): void; ++ ++// /** ++// * Execute before running tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#before ++// */ ++// declare var before: Mocha.HookFunction; ++ ++// /** ++// * Execute before running tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#before ++// */ ++// declare var suiteSetup: Mocha.HookFunction; ++ ++// /** ++// * Execute after running tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#after ++// */ ++// declare var after: Mocha.HookFunction; ++ ++// /** ++// * Execute after running tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#after ++// */ ++// declare var suiteTeardown: Mocha.HookFunction; ++ ++// /** ++// * Execute before each test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#beforeEach ++// */ ++// declare var beforeEach: Mocha.HookFunction; ++ ++// /** ++// * Execute before each test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#beforeEach ++// */ ++// declare var setup: Mocha.HookFunction; ++ ++// /** ++// * Execute after each test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#afterEach ++// */ ++// declare var afterEach: Mocha.HookFunction; ++ ++// /** ++// * Execute after each test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// * ++// * @see https://mochajs.org/api/global.html#afterEach ++// */ ++// declare var teardown: Mocha.HookFunction; ++ ++// /** ++// * Describe a "suite" containing nested suites and tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// declare var describe: Mocha.SuiteFunction; ++ ++// /** ++// * Describe a "suite" containing nested suites and tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// declare var context: Mocha.SuiteFunction; ++ ++// /** ++// * Describe a "suite" containing nested suites and tests. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// declare var suite: Mocha.SuiteFunction; ++ ++// /** ++// * Pending suite. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// declare var xdescribe: Mocha.PendingSuiteFunction; ++ ++// /** ++// * Pending suite. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// declare var xcontext: Mocha.PendingSuiteFunction; ++ ++// /** ++// * Describes a test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// declare var it: Mocha.TestFunction; ++ ++// /** ++// * Describes a test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// declare var specify: Mocha.TestFunction; ++ ++// /** ++// * Describes a test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// declare var test: Mocha.TestFunction; ++ ++// /** ++// * Describes a pending test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// declare var xit: Mocha.PendingTestFunction; ++ ++// /** ++// * Describes a pending test case. ++// * ++// * - _Only available when invoked via the mocha CLI._ ++// */ ++// declare var xspecify: Mocha.PendingTestFunction; ++ ++// // #endregion Test interface augmentations ++ ++// // #region Reporter augmentations ++ ++// // Forward declaration for `HTMLLIElement` from lib.dom.d.ts. ++// // Required by Mocha.reporters.HTML. ++// // NOTE: Mocha *must not* have a direct dependency on DOM types. ++// // tslint:disable-next-line no-empty-interface ++// interface HTMLLIElement { } ++ ++// // Augments the DOM `Window` object when lib.dom.d.ts is loaded. ++// // tslint:disable-next-line no-empty-interface ++// interface Window extends Mocha.MochaGlobals { } ++ ++// declare namespace NodeJS { ++// // Forward declaration for `NodeJS.EventEmitter` from node.d.ts. ++// // Required by Mocha.Runnable, Mocha.Runner, and Mocha.Suite. ++// // NOTE: Mocha *must not* have a direct dependency on @types/node. ++// // tslint:disable-next-line no-empty-interface ++// interface EventEmitter { } ++ ++// // Augments NodeJS's `global` object when node.d.ts is loaded ++// // tslint:disable-next-line no-empty-interface ++// interface Global extends Mocha.MochaGlobals { } ++// } ++ ++// // #endregion Reporter augmentations ++ ++// // #region Browser augmentations ++ ++// /** ++// * Mocha global. ++// * ++// * - _Only supported in the browser._ ++// */ ++// declare const mocha: BrowserMocha; ++ ++// interface BrowserMocha extends Mocha { ++// /** ++// * Function to allow assertion libraries to throw errors directly into mocha. ++// * This is useful when running tests in a browser because window.onerror will ++// * only receive the 'message' attribute of the Error. ++// * ++// * - _Only supported in the browser._ ++// */ ++// throwError(err: any): never; ++ ++// /** ++// * Setup mocha with the given settings options. ++// * ++// * - _Only supported in the browser._ ++// */ ++// setup(opts?: Mocha.Interface | Mocha.MochaOptions): this; ++// } ++ ++// // #endregion Browser augmentations ++ ++// declare module "mocha" { ++// export = Mocha; ++// } ++ ++// declare module "mocha/lib/stats-collector" { ++// export = createStatsCollector; ++ ++// /** ++// * Provides stats such as test duration, number of tests passed / failed etc., by listening for events emitted by `runner`. ++// */ ++// function createStatsCollector(runner: Mocha.Runner): void; ++// } ++ ++// declare module "mocha/lib/interfaces/common" { ++// export = common; ++ ++// function common(suites: Mocha.Suite[], context: Mocha.MochaGlobals, mocha: Mocha): common.CommonFunctions; ++ ++// namespace common { ++// interface CommonFunctions { ++// /** ++// * This is only present if flag --delay is passed into Mocha. It triggers ++// * root suite execution. ++// */ ++// runWithSuite(suite: Mocha.Suite): () => void; ++ ++// /** ++// * Execute before running tests. ++// */ ++// before(fn?: Mocha.Func | Mocha.AsyncFunc): void; ++ ++// /** ++// * Execute before running tests. ++// */ ++// before(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; ++ ++// /** ++// * Execute after running tests. ++// */ ++// after(fn?: Mocha.Func | Mocha.AsyncFunc): void; ++ ++// /** ++// * Execute after running tests. ++// */ ++// after(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; ++ ++// /** ++// * Execute before each test case. ++// */ ++// beforeEach(fn?: Mocha.Func | Mocha.AsyncFunc): void; ++ ++// /** ++// * Execute before each test case. ++// */ ++// beforeEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; ++ ++// /** ++// * Execute after each test case. ++// */ ++// afterEach(fn?: Mocha.Func | Mocha.AsyncFunc): void; ++ ++// /** ++// * Execute after each test case. ++// */ ++// afterEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; ++ ++// suite: SuiteFunctions; ++// test: TestFunctions; ++// } ++ ++// interface CreateOptions { ++// /** Title of suite */ ++// title: string; ++ ++// /** Suite function */ ++// fn?: (this: Mocha.Suite) => void; ++ ++// /** Is suite pending? */ ++// pending?: boolean; ++ ++// /** Filepath where this Suite resides */ ++// file?: string; ++ ++// /** Is suite exclusive? */ ++// isOnly?: boolean; ++// } ++ ++// interface SuiteFunctions { ++// /** ++// * Create an exclusive Suite; convenience function ++// */ ++// only(opts: CreateOptions): Mocha.Suite; ++ ++// /** ++// * Create a Suite, but skip it; convenience function ++// */ ++// skip(opts: CreateOptions): Mocha.Suite; ++ ++// /** ++// * Creates a suite. ++// */ ++// create(opts: CreateOptions): Mocha.Suite; ++// } ++ ++// interface TestFunctions { ++// /** ++// * Exclusive test-case. ++// */ ++// only(mocha: Mocha, test: Mocha.Test): Mocha.Test; ++ ++// /** ++// * Pending test case. ++// */ ++// skip(title: string): void; ++ ++// /** ++// * Number of retry attempts ++// */ ++// retries(n: number): void; ++// } ++// } ++// } From ec28117a3a13fef4065e0e01729b71aa91f1d385 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 13:33:53 -0600 Subject: [PATCH 53/96] make config package type safe --- .../config/__snapshots__/index_spec.ts.js | 153 +++++++ .../__snapshots__/validation_spec.ts.js | 226 ++++++++++ packages/config/index.js | 1 + packages/config/lib/index.js | 144 ------- packages/config/lib/index.ts | 162 ++++++++ packages/config/lib/options.ts | 39 +- .../lib/{validation.js => validation.ts} | 227 +++++----- packages/config/package.json | 19 +- packages/config/test/unit/index_spec.ts | 174 ++++++++ packages/config/test/unit/validation_spec.ts | 391 ++++++++++++++++++ packages/config/tsconfig.json | 15 +- .../src/data/ProjectLifecycleManager.ts | 3 +- .../data-context/src/util/config-options.ts | 2 +- packages/graphql/schemas/schema.graphql | 1 + packages/server/lib/makeDataContext.ts | 2 +- .../server/test/integration/cypress_spec.js | 2 +- packages/types/src/config.ts | 23 -- 17 files changed, 1291 insertions(+), 293 deletions(-) create mode 100644 packages/config/__snapshots__/index_spec.ts.js create mode 100644 packages/config/__snapshots__/validation_spec.ts.js create mode 100644 packages/config/index.js delete mode 100644 packages/config/lib/index.js create mode 100644 packages/config/lib/index.ts rename packages/config/lib/{validation.js => validation.ts} (55%) create mode 100644 packages/config/test/unit/index_spec.ts create mode 100644 packages/config/test/unit/validation_spec.ts diff --git a/packages/config/__snapshots__/index_spec.ts.js b/packages/config/__snapshots__/index_spec.ts.js new file mode 100644 index 000000000000..950e55900213 --- /dev/null +++ b/packages/config/__snapshots__/index_spec.ts.js @@ -0,0 +1,153 @@ +exports['src/index .getBreakingKeys returns list of breaking config keys 1'] = [ + "integrationFolder", + "componentFolder", + "testFiles", + "blacklistHosts", + "experimentalComponentTesting", + "experimentalGetCookiesSameSite", + "experimentalNetworkStubbing", + "experimentalRunEvents", + "experimentalShadowDomSupport", + "firefoxGcInterval", + "nodeVersion", + "nodeVersion" +] + +exports['src/index .getDefaultValues returns list of public config keys 1'] = { + "animationDistanceThreshold": 5, + "baseUrl": null, + "blockHosts": null, + "chromeWebSecurity": true, + "clientCertificates": [], + "component": { + "specPattern": "**/*.cy.{js,jsx,ts,tsx}" + }, + "defaultCommandTimeout": 4000, + "downloadsFolder": "cypress/downloads", + "e2e": { + "specPattern": "cypress/e2e/**/*.cy.{js,jsx,ts,tsx}" + }, + "env": {}, + "execTimeout": 60000, + "exit": true, + "experimentalFetchPolyfill": false, + "experimentalInteractiveRunEvents": false, + "experimentalSessionSupport": false, + "experimentalSourceRewriting": false, + "fileServerFolder": "", + "fixturesFolder": "cypress/fixtures", + "excludeSpecPattern": "*.hot-update.js", + "includeShadowDom": false, + "keystrokeDelay": 0, + "modifyObstructiveCode": true, + "numTestsKeptInMemory": 50, + "pageLoadTimeout": 60000, + "pluginsFile": "cypress/plugins", + "port": null, + "projectId": null, + "redirectionLimit": 20, + "reporter": "spec", + "reporterOptions": null, + "requestTimeout": 5000, + "resolvedNodePath": null, + "resolvedNodeVersion": null, + "responseTimeout": 30000, + "retries": { + "runMode": 0, + "openMode": 0 + }, + "screenshotOnRunFailure": true, + "screenshotsFolder": "cypress/screenshots", + "slowTestThreshold": 10000, + "scrollBehavior": "top", + "supportFile": "cypress/support/e2e.{js,jsx,ts,tsx}", + "supportFolder": false, + "taskTimeout": 60000, + "trashAssetsBeforeRuns": true, + "userAgent": null, + "video": true, + "videoCompression": 32, + "videosFolder": "cypress/videos", + "videoUploadOnPasses": true, + "viewportHeight": 660, + "viewportWidth": 1000, + "waitForAnimations": true, + "watchForFileChanges": true, + "autoOpen": false, + "browsers": [], + "clientRoute": "/__/", + "configFile": "cypress.config.js", + "devServerPublicPathRoute": "/__cypress/src", + "hosts": null, + "isInteractive": true, + "isTextTerminal": false, + "morgan": true, + "namespace": "__cypress", + "reporterRoute": "/__cypress/reporter", + "socketId": null, + "socketIoCookie": "__socket.io", + "socketIoRoute": "/__socket.io", + "xhrRoute": "/xhrs/" +} + +exports['src/index .getPublicConfigKeys returns list of public config keys 1'] = [ + "animationDistanceThreshold", + "arch", + "baseUrl", + "blockHosts", + "chromeWebSecurity", + "clientCertificates", + "component", + "defaultCommandTimeout", + "downloadsFolder", + "e2e", + "env", + "execTimeout", + "exit", + "experimentalFetchPolyfill", + "experimentalInteractiveRunEvents", + "experimentalSessionSupport", + "experimentalSourceRewriting", + "fileServerFolder", + "fixturesFolder", + "excludeSpecPattern", + "includeShadowDom", + "keystrokeDelay", + "modifyObstructiveCode", + "nodeVersion", + "numTestsKeptInMemory", + "platform", + "pageLoadTimeout", + "pluginsFile", + "port", + "projectId", + "redirectionLimit", + "reporter", + "reporterOptions", + "requestTimeout", + "resolvedNodePath", + "resolvedNodeVersion", + "responseTimeout", + "retries", + "screenshotOnRunFailure", + "screenshotsFolder", + "slowTestThreshold", + "scrollBehavior", + "supportFile", + "supportFolder", + "taskTimeout", + "trashAssetsBeforeRuns", + "userAgent", + "video", + "videoCompression", + "videosFolder", + "videoUploadOnPasses", + "viewportHeight", + "viewportWidth", + "waitForAnimations", + "watchForFileChanges", + "browsers", + "hosts", + "isInteractive", + "modifyObstructiveCode" +] diff --git a/packages/config/__snapshots__/validation_spec.ts.js b/packages/config/__snapshots__/validation_spec.ts.js new file mode 100644 index 000000000000..1b3d0e62bfce --- /dev/null +++ b/packages/config/__snapshots__/validation_spec.ts.js @@ -0,0 +1,226 @@ +exports['src/validation .isValidClientCertificatesSet returns error message for certs not passed as an array array 1'] = { + "key": "mockConfigKey", + "value": "1", + "type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls" +} + +exports['src/validation .isValidClientCertificatesSet returns error message for certs object without url 1'] = { + "key": "clientCertificates[0].url", + "type": "a URL matcher" +} + +exports['missing https protocol'] = { + "key": "clientCertificates[0].url", + "value": "http://url.com", + "type": "an https protocol" +} + +exports['invalid url'] = { + "key": "clientCertificates[0].url", + "value": "not *", + "type": "a valid URL" +} + +exports['src/validation .isValidBrowser passes valid browsers and forms error messages for invalid ones isValidBrowser 1'] = { + "name": "isValidBrowser", + "behavior": [ + { + "given": { + "name": "Chrome", + "displayName": "Chrome Browser", + "family": "chromium", + "path": "/path/to/chrome", + "version": "1.2.3", + "majorVersion": 1 + }, + "expect": true + }, + { + "given": { + "name": "FF", + "displayName": "Firefox", + "family": "firefox", + "path": "/path/to/firefox", + "version": "1.2.3", + "majorVersion": "1" + }, + "expect": true + }, + { + "given": { + "name": "Electron", + "displayName": "Electron", + "family": "chromium", + "path": "", + "version": "99.101.3", + "majorVersion": 99 + }, + "expect": true + }, + { + "given": { + "name": "No display name", + "family": "chromium" + }, + "expect": { + "key": "displayName", + "value": { + "name": "No display name", + "family": "chromium" + }, + "type": "a non-empty string" + } + }, + { + "given": { + "name": "bad family", + "displayName": "Bad family browser", + "family": "unknown family" + }, + "expect": { + "key": "family", + "value": { + "name": "bad family", + "displayName": "Bad family browser", + "family": "unknown family" + }, + "type": "either chromium or firefox" + } + } + ] +} + +exports['undefined browsers'] = ` +Missing browsers list +` + +exports['empty list of browsers'] = ` +Expected at least one browser +` + +exports['browsers list with a string'] = { + "key": "name", + "value": "foo", + "type": "a non-empty string", + "list": "browsers" +} + +exports['invalid retry value'] = { + "key": "mockConfigKey", + "value": "1", + "type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls" +} + +exports['invalid retry object'] = { + "key": "mockConfigKey", + "value": { + "fakeMode": 1 + }, + "type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls" +} + +exports['src/validation .isPlainObject returns error message when value is a not an object 1'] = { + "key": "mockConfigKey", + "value": 1, + "type": "a plain object" +} + +exports['src/validation .isNumber returns error message when value is a not a number 1'] = { + "key": "mockConfigKey", + "value": "string", + "type": "a number" +} + +exports['src/validation .isNumberOrFalse returns error message when value is a not number or false 1'] = { + "key": "mockConfigKey", + "value": null, + "type": "a number or false" +} + +exports['not qualified url'] = { + "key": "mockConfigKey", + "value": "url.com", + "type": "a fully qualified URL (starting with `http://` or `https://`)" +} + +exports['empty string'] = { + "key": "mockConfigKey", + "value": "", + "type": "a fully qualified URL (starting with `http://` or `https://`)" +} + +exports['src/validation .isBoolean returns error message when value is a not a string 1'] = { + "key": "mockConfigKey", + "value": 1, + "type": "a string" +} + +exports['src/validation .isString returns error message when value is a not a string 1'] = { + "key": "mockConfigKey", + "value": 1, + "type": "a string" +} + +exports['src/validation .isArray returns error message when value is a non-array 1'] = { + "key": "mockConfigKey", + "value": 1, + "type": "an array" +} + +exports['src/validation .isStringOrFalse returns error message when value is neither string nor false 1'] = { + "key": "mockConfigKey", + "value": null, + "type": "a string or false" +} + +exports['not string or array'] = { + "key": "mockConfigKey", + "value": null, + "type": "a string or an array of strings" +} + +exports['array of non-strings'] = { + "key": "mockConfigKey", + "value": [ + 1, + 2, + 3 + ], + "type": "a string or an array of strings" +} + +exports['not one of the strings error message'] = { + "key": "test", + "value": "nope", + "type": "one of these values: \"foo\", \"bar\"" +} + +exports['number instead of string'] = { + "key": "test", + "value": 42, + "type": "one of these values: \"foo\", \"bar\"" +} + +exports['null instead of string'] = { + "key": "test", + "value": null, + "type": "one of these values: \"foo\", \"bar\"" +} + +exports['not one of the numbers error message'] = { + "key": "test", + "value": 4, + "type": "one of these values: 1, 2, 3" +} + +exports['string instead of a number'] = { + "key": "test", + "value": "foo", + "type": "one of these values: 1, 2, 3" +} + +exports['null instead of a number'] = { + "key": "test", + "value": null, + "type": "one of these values: 1, 2, 3" +} diff --git a/packages/config/index.js b/packages/config/index.js new file mode 100644 index 000000000000..2d2f3c0bcb52 --- /dev/null +++ b/packages/config/index.js @@ -0,0 +1 @@ +module.exports = require('./dist') diff --git a/packages/config/lib/index.js b/packages/config/lib/index.js deleted file mode 100644 index a949d37ff95f..000000000000 --- a/packages/config/lib/index.js +++ /dev/null @@ -1,144 +0,0 @@ -const _ = require('lodash') -const debug = require('debug')('cypress:config:validator') - -const { options, breakingOptions, breakingRootOptions, testingTypeBreakingOptions } = require('./options') - -const dashesOrUnderscoresRe = /^(_-)+/ - -// takes an array and creates an index object of [keyKey]: [valueKey] -const createIndex = (arr, keyKey, valueKey) => { - return _.reduce(arr, (memo, item) => { - if (item[valueKey] !== undefined) { - memo[item[keyKey]] = item[valueKey] - } - - return memo - }, {}) -} - -const breakingKeys = _.map(breakingOptions, 'name') -const defaultValues = createIndex(options, 'name', 'defaultValue') -const publicConfigKeys = _(options).reject({ isInternal: true }).map('name').value() -const validationRules = createIndex(options, 'name', 'validation') -const testConfigOverrideOptions = createIndex(options, 'name', 'canUpdateDuringTestTime') - -const issuedWarnings = new Set() - -const validateNoBreakingOptions = (breakingCfgOptions, cfg, onWarning, onErr) => { - breakingCfgOptions.forEach(({ name, errorKey, newName, isWarning, value }) => { - if (_.has(cfg, name)) { - if (value && cfg[name] !== value) { - // Bail if a value is specified but the config does not have that value. - return - } - - if (isWarning) { - if (issuedWarnings.has(errorKey)) { - return - } - - // avoid re-issuing the same warning more than once - issuedWarnings.add(errorKey) - - return onWarning(errorKey, { - name, - newName, - value, - configFile: cfg.configFile, - }) - } - - return onErr(errorKey, { - name, - newName, - value, - configFile: cfg.configFile, - }) - } - }) -} - -module.exports = { - allowed: (obj = {}) => { - const propertyNames = publicConfigKeys.concat(breakingKeys) - - return _.pick(obj, propertyNames) - }, - - getBreakingKeys: () => { - return breakingKeys - }, - - getBreakingRootKeys: () => { - return breakingRootOptions - }, - - getDefaultValues: (runtimeOptions = {}) => { - // Default values can be functions, in which case they are evaluated - // at runtime - for example, slowTestThreshold where the default value - // varies between e2e and component testing. - return _.mapValues(defaultValues, (value) => (typeof value === 'function' ? value(runtimeOptions) : value)) - }, - - getPublicConfigKeys: () => { - return publicConfigKeys - }, - - matchesConfigKey: (key) => { - if (_.has(defaultValues, key)) { - return key - } - - key = key.toLowerCase().replace(dashesOrUnderscoresRe, '') - key = _.camelCase(key) - - if (_.has(defaultValues, key)) { - return key - } - }, - - options, - - validate: (cfg, onErr) => { - debug('validating configuration', cfg) - - return _.each(cfg, (value, key) => { - const validationFn = validationRules[key] - - // key has a validation rule & value different from the default - if (validationFn && value !== defaultValues[key]) { - const result = validationFn(key, value) - - if (result !== true) { - return onErr(result) - } - } - }) - }, - - validateNoBreakingConfigRoot: (cfg, onWarning, onErr) => { - return validateNoBreakingOptions(breakingRootOptions, cfg, onWarning, onErr) - }, - - validateNoBreakingConfig: (cfg, onWarning, onErr) => { - return validateNoBreakingOptions(breakingOptions, cfg, onWarning, onErr) - }, - - validateNoBreakingTestingTypeConfig: (cfg, testingType, onWarning, onErr) => { - const options = testingTypeBreakingOptions[testingType] - - return validateNoBreakingOptions(options, cfg, onWarning, onErr) - }, - - validateNoReadOnlyConfig: (config, onErr) => { - let errProperty - - Object.keys(config).some((option) => { - return errProperty = testConfigOverrideOptions[option] === false ? option : undefined - }) - - if (errProperty) { - return onErr(errProperty) - } - }, -} diff --git a/packages/config/lib/index.ts b/packages/config/lib/index.ts new file mode 100644 index 000000000000..5bbf35250448 --- /dev/null +++ b/packages/config/lib/index.ts @@ -0,0 +1,162 @@ +import _ from 'lodash' +import Debug from 'debug' +import { options, breakingOptions, breakingRootOptions, testingTypeBreakingOptions } from './options' +import type { BreakingOption, BreakingOptionErrorKey } from './options' + +export * as validation from './validation' + +export { breakingOptions, BreakingOption, BreakingOptionErrorKey } + +const debug = Debug('cypress:config:validator') + +const dashesOrUnderscoresRe = /^(_-)+/ + +// takes an array and creates an index object of [keyKey]: [valueKey] +function createIndex> (arr: Array, keyKey: keyof T, valueKey: keyof T) { + return _.reduce(arr, (memo: Record, item) => { + if (item[valueKey] !== undefined) { + memo[item[keyKey] as string] = item[valueKey] + } + + return memo + }, {}) +} + +const breakingKeys = _.map(breakingOptions, 'name') +const defaultValues = createIndex(options, 'name', 'defaultValue') +const publicConfigKeys = _(options).reject({ isInternal: true }).map('name').value() +const validationRules = createIndex(options, 'name', 'validation') +const testConfigOverrideOptions = createIndex(options, 'name', 'canUpdateDuringTestTime') + +const issuedWarnings = new Set() + +export type BreakingErrResult = { + name: string + newName?: string + value?: any + configFile: string +} + +type ErrorHandler = ( + key: BreakingOptionErrorKey, + options: BreakingErrResult +) => void + +const validateNoBreakingOptions = (breakingCfgOptions: BreakingOption[], cfg: any, onWarning: ErrorHandler, onErr: ErrorHandler) => { + breakingCfgOptions.forEach(({ name, errorKey, newName, isWarning, value }) => { + if (_.has(cfg, name)) { + if (value && cfg[name] !== value) { + // Bail if a value is specified but the config does not have that value. + return + } + + if (isWarning) { + if (issuedWarnings.has(errorKey)) { + return + } + + // avoid re-issuing the same warning more than once + issuedWarnings.add(errorKey) + + return onWarning(errorKey, { + name, + newName, + value, + configFile: cfg.configFile, + }) + } + + return onErr(errorKey, { + name, + newName, + value, + configFile: cfg.configFile, + }) + } + }) +} + +export const allowed = (obj = {}) => { + const propertyNames = publicConfigKeys.concat(breakingKeys) + + return _.pick(obj, propertyNames) +} + +export const getBreakingKeys = () => { + return breakingKeys +} + +export const getBreakingRootKeys = () => { + return breakingRootOptions +} + +export const getDefaultValues = (runtimeOptions = {}) => { + // Default values can be functions, in which case they are evaluated + // at runtime - for example, slowTestThreshold where the default value + // varies between e2e and component testing. + return _.mapValues(defaultValues, (value) => (typeof value === 'function' ? value(runtimeOptions) : value)) +} + +export const getPublicConfigKeys = () => { + return publicConfigKeys +} + +export const matchesConfigKey = (key: string) => { + if (_.has(defaultValues, key)) { + return key + } + + key = key.toLowerCase().replace(dashesOrUnderscoresRe, '') + key = _.camelCase(key) + + if (_.has(defaultValues, key)) { + return key + } + + return +} + +export { options } + +export const validate = (cfg: any, onErr: (property: string) => void) => { + debug('validating configuration', cfg) + + return _.each(cfg, (value, key) => { + const validationFn = validationRules[key] + + // key has a validation rule & value different from the default + if (validationFn && value !== defaultValues[key]) { + const result = validationFn(key, value) + + if (result !== true) { + return onErr(result) + } + } + }) +} + +export const validateNoBreakingConfigRoot = (cfg: any, onWarning: ErrorHandler, onErr: ErrorHandler) => { + return validateNoBreakingOptions(breakingRootOptions, cfg, onWarning, onErr) +} + +export const validateNoBreakingConfig = (cfg: any, onWarning: ErrorHandler, onErr: ErrorHandler) => { + return validateNoBreakingOptions(breakingOptions, cfg, onWarning, onErr) +} + +export const validateNoBreakingTestingTypeConfig = (cfg: any, testingType: keyof typeof testingTypeBreakingOptions, onWarning: ErrorHandler, onErr: ErrorHandler) => { + const options = testingTypeBreakingOptions[testingType] + + return validateNoBreakingOptions(options, cfg, onWarning, onErr) +} + +export const validateNoReadOnlyConfig = (config: any, onErr: (property: string) => void) => { + let errProperty + + Object.keys(config).some((option) => { + return errProperty = testConfigOverrideOptions[option] === false ? option : undefined + }) + + if (errProperty) { + return onErr(errProperty) + } +} diff --git a/packages/config/lib/options.ts b/packages/config/lib/options.ts index 762b42bd0dd0..1fa791875e24 100644 --- a/packages/config/lib/options.ts +++ b/packages/config/lib/options.ts @@ -1,8 +1,23 @@ import os from 'os' -import validate from './validation' +import * as validate from './validation' // @ts-ignore import pkg from '@packages/root' +export type BreakingOptionErrorKey = + | 'RENAMED_CONFIG_OPTION' + | 'EXPERIMENTAL_COMPONENT_TESTING_REMOVED' + | 'EXPERIMENTAL_SAMESITE_REMOVED' + | 'EXPERIMENTAL_NETWORK_STUBBING_REMOVED' + | 'EXPERIMENTAL_RUN_EVENTS_REMOVED' + | 'EXPERIMENTAL_SHADOW_DOM_REMOVED' + | 'FIREFOX_GC_INTERVAL_REMOVED' + | 'NODE_VERSION_DEPRECATION_SYSTEM' + | 'NODE_VERSION_DEPRECATION_BUNDLED' + | 'CONFIG_FILE_INVALID_ROOT_CONFIG' + | 'CONFIG_FILE_INVALID_ROOT_CONFIG_E2E' + | 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT' + | 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN' + type TestingType = 'e2e' | 'component' interface ResolvedConfigOption { @@ -29,7 +44,7 @@ interface RuntimeConfigOption { canUpdateDuringTestTime?: boolean } -interface BreakingOption { +export interface BreakingOption { /** * The non-passive configuration option. */ @@ -37,7 +52,7 @@ interface BreakingOption { /** * String to summarize the error messaging that is logged. */ - errorKey: string + errorKey: BreakingOptionErrorKey /** * Array of testing types this config option is valid for */ @@ -493,15 +508,26 @@ export const options: Array = [ ...runtimeOptions, ] +/** + * Values not allowed in 10.X+ in the root, e2e and component config + */ export const breakingOptions: Array = [ { + name: 'integrationFolder', + errorKey: 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN', + }, { + name: 'componentFolder', + errorKey: 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN', + }, { + name: 'testFiles', + errorKey: 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN', + }, { name: 'blacklistHosts', errorKey: 'RENAMED_CONFIG_OPTION', newName: 'blockHosts', }, { name: 'experimentalComponentTesting', errorKey: 'EXPERIMENTAL_COMPONENT_TESTING_REMOVED', - isWarning: false, }, { name: 'experimentalGetCookiesSameSite', errorKey: 'EXPERIMENTAL_SAMESITE_REMOVED', @@ -533,11 +559,6 @@ export const breakingOptions: Array = [ errorKey: 'NODE_VERSION_DEPRECATION_BUNDLED', isWarning: true, }, - { - name: 'testFiles', - errorKey: 'TEST_FILES_DEPRECATION', - isWarning: false, - }, ] export const breakingRootOptions: Array = [ diff --git a/packages/config/lib/validation.js b/packages/config/lib/validation.ts similarity index 55% rename from packages/config/lib/validation.js rename to packages/config/lib/validation.ts index 75c3ca6ed301..e7843512addc 100644 --- a/packages/config/lib/validation.js +++ b/packages/config/lib/validation.ts @@ -1,17 +1,25 @@ -const _ = require('lodash') -const debug = require('debug')('cypress:server:validation') -const is = require('check-more-types') -const { commaListsOr } = require('common-tags') -const path = require('path') +import path from 'path' +import * as _ from 'lodash' +import * as is from 'check-more-types' +import { commaListsOr } from 'common-tags' +import Debug from 'debug' + +const debug = Debug('cypress:server:validation') // validation functions take a key and a value and should: // - return true if it passes validation // - return a error message if it fails validation const str = JSON.stringify -const { isArray, isString, isFinite: isNumber } = _ -const errMsg = (key, value, type) => { +type ErrResult = { + key: string + value: any + type: string + list?: string +} + +const errMsg = (key: string, value: any, type: string): ErrResult => { return { key, value, @@ -19,15 +27,15 @@ const errMsg = (key, value, type) => { } } -const isFullyQualifiedUrl = (value) => { - return isString(value) && /^https?\:\/\//.test(value) +const _isFullyQualifiedUrl = (value: any): ErrResult | boolean => { + return _.isString(value) && /^https?\:\/\//.test(value) } -const isArrayOfStrings = (value) => { - return isArray(value) && _.every(value, isString) +const isArrayOfStrings = (value: any): ErrResult | boolean => { + return _.isArray(value) && _.every(value, _.isString) } -const isFalse = (value) => { +const isFalse = (value: any): boolean => { return value === false } @@ -35,7 +43,7 @@ const isFalse = (value) => { * Validates a single browser object. * @returns {string|true} Returns `true` if the object is matching browser object schema. Returns an error message if it does not. */ -const isValidBrowser = (browser) => { +export const isValidBrowser = (browser: any): ErrResult | true => { if (!is.unemptyString(browser.name)) { return errMsg('name', browser, 'a non-empty string') } @@ -55,11 +63,11 @@ const isValidBrowser = (browser) => { return errMsg('version', browser, 'a non-empty string') } - if (!is.string(browser.path)) { + if (typeof browser.path !== 'string') { return errMsg('path', browser, 'a string') } - if (!is.string(browser.majorVersion) && !is.positive(browser.majorVersion)) { + if (typeof browser.majorVersion !== 'string' && !(is.number(browser.majorVersion) && browser.majorVersion > 0)) { return errMsg('majorVersion', browser, 'a string or a positive number') } @@ -69,7 +77,7 @@ const isValidBrowser = (browser) => { /** * Validates the list of browsers. */ -const isValidBrowserList = (key, browsers) => { +export const isValidBrowserList = (key: string, browsers: any): ErrResult | true | string => { debug('browsers %o', browsers) if (!browsers) { return 'Missing browsers list' @@ -86,7 +94,7 @@ const isValidBrowserList = (key, browsers) => { } for (let k = 0; k < browsers.length; k += 1) { - const validationResult = isValidBrowser(browsers[k]) + const validationResult: boolean | {key: string, value: string, type: string, list?: string} = isValidBrowser(browsers[k]) if (validationResult !== true) { validationResult.list = 'browsers' @@ -98,10 +106,10 @@ const isValidBrowserList = (key, browsers) => { return true } -const isValidRetriesConfig = (key, value) => { +export const isValidRetriesConfig = (key: string, value: any): ErrResult | true => { const optionalKeys = ['runMode', 'openMode'] - const isValidRetryValue = (val) => _.isNull(val) || (Number.isInteger(val) && val >= 0) - const optionalKeysAreValid = (val, k) => optionalKeys.includes(k) && isValidRetryValue(val) + const isValidRetryValue = (val: any) => _.isNull(val) || (Number.isInteger(val) && val >= 0) + const optionalKeysAreValid = (val: any, k: string) => optionalKeys.includes(k) && isValidRetryValue(val) if (isValidRetryValue(value)) { return true @@ -114,15 +122,16 @@ const isValidRetriesConfig = (key, value) => { return errMsg(key, value, 'a positive number or null or an object with keys "openMode" and "runMode" with values of numbers or nulls') } -const isPlainObject = (key, value) => { - if (value == null || _.isPlainObject(value)) { - return true - } - - return errMsg(key, value, 'a plain object') -} - -const isOneOf = (...values) => { +/** + * Checks if given value for a key is equal to one of the provided values. + * @example + ``` + validate = v.isOneOf("foo", "bar") + validate("example", "foo") // true + validate("example", "else") // error message string + ``` + */ +export const isOneOf = (...values: any[]): ((key: string, value: any) => ErrResult | true) => { return (key, value) => { if (values.some((v) => { if (typeof value === 'function') { @@ -134,7 +143,7 @@ const isOneOf = (...values) => { return true } - const strings = values.map(str).join(', ') + const strings = values.map((a) => str(a)).join(', ') return errMsg(key, value, `one of these values: ${strings}`) } @@ -144,19 +153,32 @@ const isOneOf = (...values) => { * Validates whether the supplied set of cert information is valid * @returns {string|true} Returns `true` if the information set is valid. Returns an error message if it is not. */ -const isValidClientCertificatesSet = (_key, certsForUrls) => { +// _key: string, certsForUrls: any[]): ErrResult | true {} +export const isValidClientCertificatesSet = (_key: string, certsForUrls: Array<{ + name?: string + url?: string + ca?: string[] + certs?: Array<{ + key: string + cert: string + pfx: string + }>}>): ErrResult | true | string => { debug('clientCerts: %o', certsForUrls) if (!Array.isArray(certsForUrls)) { return errMsg(`clientCertificates.certs`, certsForUrls, 'an array of certs for URLs') } - let urls = [] + let urls: string[] = [] for (let i = 0; i < certsForUrls.length; i++) { debug(`Processing clientCertificates: ${i}`) let certsForUrl = certsForUrls[i] + if (!certsForUrl) { + continue + } + if (!certsForUrl.url) { return errMsg(`clientCertificates[${i}].url`, certsForUrl.url, 'a URL matcher') } @@ -190,6 +212,10 @@ const isValidClientCertificatesSet = (_key, certsForUrls) => { for (let j = 0; j < certsForUrl.certs.length; j++) { let certInfo = certsForUrl.certs[j] + if (!certInfo) { + continue + } + // Only one of PEM or PFX cert allowed if (certInfo.cert && certInfo.pfx) { return `\`clientCertificates[${i}].certs[${j}]\` has both PEM and PFX defined` @@ -220,9 +246,11 @@ const isValidClientCertificatesSet = (_key, certsForUrls) => { } } - for (let k = 0; k < certsForUrl.ca.length; k++) { - if (path.isAbsolute(certsForUrl.ca[k])) { - return errMsg(`clientCertificates[${k}].ca[${k}]`, certsForUrl.ca[k], 'a relative filepath') + if (certsForUrl.ca) { + for (let k = 0; k < certsForUrl.ca.length; k++) { + if (path.isAbsolute(certsForUrl.ca[k] || '')) { + return errMsg(`clientCertificates[${k}].ca[${k}]`, certsForUrl.ca[k], 'a relative filepath') + } } } } @@ -230,93 +258,78 @@ const isValidClientCertificatesSet = (_key, certsForUrls) => { return true } -module.exports = { - isValidClientCertificatesSet, - - isValidBrowser, - - isValidBrowserList, - - isValidRetriesConfig, +export const isPlainObject = (key: string, value: any) => { + if (value == null || _.isPlainObject(value)) { + return true + } - isPlainObject, + return errMsg(key, value, 'a plain object') +} - isNumber (key, value) { - if (value == null || isNumber(value)) { - return true - } +export function isBoolean (key: string, value: any): ErrResult | true { + if (value == null || _.isBoolean(value)) { + return true + } - return errMsg(key, value, 'a number') - }, + return errMsg(key, value, 'a boolean') +} - isNumberOrFalse (key, value) { - if (isNumber(value) || isFalse(value)) { - return true - } +export function isNumber (key: string, value: any): ErrResult | true { + if (value == null || _.isNumber(value)) { + return true + } - return errMsg(key, value, 'a number or false') - }, + return errMsg(key, value, 'a number') +} - isFullyQualifiedUrl (key, value) { - if (value == null || isFullyQualifiedUrl(value)) { - return true - } +export function isString (key: string, value: any): ErrResult | true { + if (value == null || _.isString(value)) { + return true + } - return errMsg( - key, - value, - 'a fully qualified URL (starting with `http://` or `https://`)', - ) - }, + return errMsg(key, value, 'a string') +} - isBoolean (key, value) { - if (value == null || _.isBoolean(value)) { - return true - } +export function isArray (key: string, value: any) { + if (value == null || _.isArray(value)) { + return true + } - return errMsg(key, value, 'a boolean') - }, + return errMsg(key, value, 'an array') +} - isString (key, value) { - if (value == null || isString(value)) { - return true - } +export function isNumberOrFalse (key: string, value: any): ErrResult | true { + if (_.isNumber(value) || isFalse(value)) { + return true + } - return errMsg(key, value, 'a string') - }, + return errMsg(key, value, 'a number or false') +} - isArray (key, value) { - if (value == null || isArray(value)) { - return true - } +export function isStringOrFalse (key: string, value: any): ErrResult | true { + if (_.isString(value) || isFalse(value)) { + return true + } - return errMsg(key, value, 'an array') - }, + return errMsg(key, value, 'a string or false') +} - isStringOrFalse (key, value) { - if (isString(value) || isFalse(value)) { - return true - } +export function isFullyQualifiedUrl (key: string, value: any): ErrResult | true { + if (value == null || _isFullyQualifiedUrl(value)) { + return true + } - return errMsg(key, value, 'a string or false') - }, + return errMsg( + key, + value, + 'a fully qualified URL (starting with `http://` or `https://`)', + ) +} - isStringOrArrayOfStrings (key, value) { - if (isString(value) || isArrayOfStrings(value)) { - return true - } +export function isStringOrArrayOfStrings (key: string, value: any): ErrResult | true { + if (_.isString(value) || isArrayOfStrings(value)) { + return true + } - return errMsg(key, value, 'a string or an array of strings') - }, - - /** - * Checks if given value for a key is equal to one of the provided values. - * @example - ``` - validate = v.isOneOf("foo", "bar") - validate("example", "foo") // true - validate("example", "else") // error message string - ``` - */ - isOneOf, + return errMsg(key, value, 'a string or an array of strings') } diff --git a/packages/config/package.json b/packages/config/package.json index e1d374a99b53..1802895b5351 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -3,10 +3,13 @@ "version": "0.0.0-development", "description": "Config contains the configuration types and validation function used in the cypress electron application.", "private": true, - "main": "lib/index.js", + "main": "index.js", "scripts": { - "build-prod": "tsc --project .", - "clean": "rm lib/options.js || echo 'ok'", + "watch": "yarn build --watch", + "build": "tsc --project .", + "build-prod": "yarn build", + "check-ts": "tsc --noEmit", + "clean": "rm lib/*.js || echo 'ok'", "test": "yarn test-unit", "test-debug": "yarn test-unit --inspect-brk=5566", "test-unit": "mocha --configFile=../../mocha-reporter-config.json -r @packages/ts/register -extension=.js,.ts test/unit/*spec.* --exit" @@ -20,6 +23,9 @@ "devDependencies": { "@packages/root": "0.0.0-development", "@packages/ts": "0.0.0-development", + "@packages/types": "0.0.0-development", + "@types/mocha": "^8.0.3", + "@types/node": "14.14.31", "chai": "1.10.0", "mocha": "7.0.1", "sinon": "7.3.1", @@ -27,6 +33,9 @@ "snap-shot-it": "7.9.3" }, "files": [ - "lib" - ] + "lib", + "dist", + "index.js" + ], + "types": "dist/index.d.ts" } diff --git a/packages/config/test/unit/index_spec.ts b/packages/config/test/unit/index_spec.ts new file mode 100644 index 000000000000..cb1d6b5e48ca --- /dev/null +++ b/packages/config/test/unit/index_spec.ts @@ -0,0 +1,174 @@ +import chai from 'chai' +import snapshot from 'snap-shot-it' +import sinon from 'sinon' +import sinonChai from 'sinon-chai' + +import * as configUtil from '../../lib/index' + +chai.use(sinonChai) +const { expect } = chai + +describe('src/index', () => { + describe('.allowed', () => { + it('returns filter config only containing allowed keys', () => { + const keys = configUtil.allowed({ + 'baseUrl': 'https://url.com', + 'blacklistHosts': 'breaking option', + 'devServerPublicPathRoute': 'internal key', + 'random': 'not a config option', + }) + + expect(keys).to.deep.eq({ + 'baseUrl': 'https://url.com', + 'blacklistHosts': 'breaking option', + }) + }) + }) + + describe('.getBreakingKeys', () => { + it('returns list of breaking config keys', () => { + const breakingKeys = configUtil.getBreakingKeys() + + expect(breakingKeys).to.include('blacklistHosts') + snapshot(breakingKeys) + }) + }) + + describe('.getDefaultValues', () => { + it('returns list of public config keys', () => { + const defaultValues = configUtil.getDefaultValues() + + expect(defaultValues).to.deep.include({ + defaultCommandTimeout: 4000, + scrollBehavior: 'top', + watchForFileChanges: true, + }) + + expect(defaultValues.env).to.deep.eq({}) + + // remove these since they are different depending on your machine + ;['platform', 'arch', 'version'].forEach((x) => { + expect(defaultValues[x]).to.exist + delete defaultValues[x] + }) + + snapshot(defaultValues) + }) + }) + + describe('.getPublicConfigKeys', () => { + it('returns list of public config keys', () => { + const publicConfigKeys = configUtil.getPublicConfigKeys() + + expect(publicConfigKeys).to.include('blockHosts') + expect(publicConfigKeys).to.not.include('devServerPublicPathRoute') + snapshot(publicConfigKeys) + }) + }) + + describe('.matchesConfigKey', () => { + it('returns normalized key when config key has a default value', () => { + let normalizedKey = configUtil.matchesConfigKey('EXEC_TIMEOUT') + + expect(normalizedKey).to.eq('execTimeout') + + normalizedKey = configUtil.matchesConfigKey('Base-url') + expect(normalizedKey).to.eq('baseUrl') + }) + + it('returns nothing when config key does not has a default value', () => { + let normalizedKey = configUtil.matchesConfigKey('random') + + expect(normalizedKey).to.be.undefined + }) + }) + + describe('.validate', () => { + it('validates config', () => { + const errorFn = sinon.spy() + + configUtil.validate({ + 'baseUrl': 'https://', + }, errorFn) + + expect(errorFn).to.have.callCount(0) + }) + + it('calls error callback if config is invalid', () => { + const errorFn = sinon.spy() + + configUtil.validate({ + 'baseUrl': ' ', + }, errorFn) + + expect(errorFn).to.have.been.calledWithMatch({ key: 'baseUrl' }) + expect(errorFn).to.have.been.calledWithMatch({ type: 'a fully qualified URL (starting with `http://` or `https://`)' }) + }) + }) + + describe('.validateNoBreakingConfig', () => { + it('calls warning callback if config contains breaking option that warns', () => { + const warningFn = sinon.spy() + const errorFn = sinon.spy() + + configUtil.validateNoBreakingConfig({ + 'experimentalNetworkStubbing': 'should break', + configFile: 'config.js', + }, warningFn, errorFn) + + expect(warningFn).to.have.been.calledOnceWith('EXPERIMENTAL_NETWORK_STUBBING_REMOVED', { + name: 'experimentalNetworkStubbing', + newName: undefined, + value: undefined, + configFile: 'config.js', + }) + + expect(errorFn).to.have.callCount(0) + }) + + it('calls error callback if config contains breaking option that should throw an error', () => { + const warningFn = sinon.spy() + const errorFn = sinon.spy() + + configUtil.validateNoBreakingConfig({ + 'blacklistHosts': 'should break', + configFile: 'config.js', + }, warningFn, errorFn) + + expect(warningFn).to.have.been.callCount(0) + expect(errorFn).to.have.been.calledOnceWith('RENAMED_CONFIG_OPTION', { + name: 'blacklistHosts', + newName: 'blockHosts', + value: undefined, + configFile: 'config.js', + }) + }) + }) + + describe('.validateNoReadOnlyConfig', () => { + it('returns an error if validation fails', () => { + const errorFn = sinon.spy() + + configUtil.validateNoReadOnlyConfig({ chromeWebSecurity: false }, errorFn) + + expect(errorFn).to.have.callCount(1) + expect(errorFn).to.have.been.calledWithMatch(/chromeWebSecurity/) + }) + + it('does not return an error if validation succeeds', () => { + const errorFn = sinon.spy() + + configUtil.validateNoReadOnlyConfig({ requestTimeout: 1000 }, errorFn) + + expect(errorFn).to.have.callCount(0) + }) + + it('does not return an error if configuration is a non-Cypress config option', () => { + const errorFn = sinon.spy() + + configUtil.validateNoReadOnlyConfig({ foo: 'bar' }, errorFn) + + expect(errorFn).to.have.callCount(0) + }) + }) +}) diff --git a/packages/config/test/unit/validation_spec.ts b/packages/config/test/unit/validation_spec.ts new file mode 100644 index 000000000000..8175d1d71768 --- /dev/null +++ b/packages/config/test/unit/validation_spec.ts @@ -0,0 +1,391 @@ +import snapshot from 'snap-shot-it' +import { expect } from 'chai' + +import * as validation from '../../lib/validation' + +describe('src/validation', () => { + const mockKey = 'mockConfigKey' + + describe('.isValidClientCertificatesSet', () => { + it('returns error message for certs not passed as an array array', () => { + const result = validation.isValidRetriesConfig(mockKey, '1') + + expect(result).to.not.be.true + snapshot(result) + }) + + it('returns error message for certs object without url', () => { + const result = validation.isValidClientCertificatesSet(mockKey, [ + { name: 'cert' }, + ]) + + expect(result).to.not.be.true + snapshot(result) + }) + + it('returns error message for certs url not matching *', () => { + let result = validation.isValidClientCertificatesSet(mockKey, [ + { url: 'http://url.com' }, + ]) + + expect(result).to.not.be.true + snapshot('missing https protocol', result) + + result = validation.isValidClientCertificatesSet(mockKey, [ + { url: 'not *' }, + ]) + + expect(result).to.not.be.true + snapshot('invalid url', result) + }) + }) + + describe('.isValidBrowser', () => { + it('passes valid browsers and forms error messages for invalid ones', () => { + const browsers = [ + // valid browser + { + name: 'Chrome', + displayName: 'Chrome Browser', + family: 'chromium', + path: '/path/to/chrome', + version: '1.2.3', + majorVersion: 1, + }, + // another valid browser + { + name: 'FF', + displayName: 'Firefox', + family: 'firefox', + path: '/path/to/firefox', + version: '1.2.3', + majorVersion: '1', + }, + // Electron is a valid browser + { + name: 'Electron', + displayName: 'Electron', + family: 'chromium', + path: '', + version: '99.101.3', + majorVersion: 99, + }, + // invalid browser, missing displayName + { + name: 'No display name', + family: 'chromium', + }, + { + name: 'bad family', + displayName: 'Bad family browser', + family: 'unknown family', + }, + ] + + // data-driven testing - computers snapshot value for each item in the list passed through the function + // https://github.com/bahmutov/snap-shot-it#data-driven-testing + return snapshot.apply(null, [validation.isValidBrowser].concat(browsers as any)) + }) + }) + + describe('.isValidBrowserList', () => { + it('does not allow empty or not browsers', () => { + snapshot('undefined browsers', validation.isValidBrowserList('browsers', undefined)) + snapshot('empty list of browsers', validation.isValidBrowserList('browsers', [])) + + return snapshot('browsers list with a string', validation.isValidBrowserList('browsers', ['foo'])) + }) + }) + + describe('.isValidRetriesConfig', () => { + it('returns true for valid retry value', () => { + let result = validation.isValidRetriesConfig(mockKey, null) + + expect(result).to.be.true + + result = validation.isValidRetriesConfig(mockKey, 2) + expect(result).to.be.true + }) + + it('returns true for valid retry objects', () => { + let result = validation.isValidRetriesConfig(mockKey, { runMode: 1 }) + + expect(result).to.be.true + + result = validation.isValidRetriesConfig(mockKey, { openMode: 1 }) + expect(result).to.be.true + + result = validation.isValidRetriesConfig(mockKey, { + runMode: 3, + openMode: 0, + }) + + expect(result).to.be.true + }) + + it('returns error message for invalid retry config', () => { + let result = validation.isValidRetriesConfig(mockKey, '1') + + expect(result).to.not.be.true + snapshot('invalid retry value', result) + + result = validation.isValidRetriesConfig(mockKey, { fakeMode: 1 }) + expect(result).to.not.be.true + snapshot('invalid retry object', result) + }) + }) + + describe('.isPlainObject', () => { + it('returns true for value=null', () => { + const result = validation.isPlainObject(mockKey, null) + + expect(result).to.be.true + }) + + it('returns true for value=number', () => { + const result = validation.isPlainObject(mockKey, { foo: 'bar' }) + + expect(result).to.be.true + }) + + it('returns error message when value is a not an object', () => { + const result = validation.isPlainObject(mockKey, 1) + + expect(result).to.not.be.true + snapshot(result) + }) + }) + + describe('.isNumber', () => { + it('returns true for value=null', () => { + const result = validation.isNumber(mockKey, null) + + expect(result).to.be.true + }) + + it('returns true for value=number', () => { + const result = validation.isNumber(mockKey, 1) + + expect(result).to.be.true + }) + + it('returns error message when value is a not a number', () => { + const result = validation.isNumber(mockKey, 'string') + + expect(result).to.not.be.true + snapshot(result) + }) + }) + + describe('.isNumberOrFalse', () => { + it('returns true for value=number', () => { + const result = validation.isNumberOrFalse(mockKey, 1) + + expect(result).to.be.true + }) + + it('returns true for value=false', () => { + const result = validation.isNumberOrFalse(mockKey, false) + + expect(result).to.be.true + }) + + it('returns error message when value is a not number or false', () => { + const result = validation.isNumberOrFalse(mockKey, null) + + expect(result).to.not.be.true + snapshot(result) + }) + }) + + describe('.isFullyQualifiedUrl', () => { + it('returns true for value=null', () => { + const result = validation.isFullyQualifiedUrl(mockKey, null) + + expect(result).to.be.true + }) + + it('returns true for value=qualified urls', () => { + let result = validation.isFullyQualifiedUrl(mockKey, 'https://url.com') + + expect(result).to.be.true + result = validation.isFullyQualifiedUrl(mockKey, 'http://url.com') + expect(result).to.be.true + }) + + it('returns error message when value is a not qualified url', () => { + let result = validation.isFullyQualifiedUrl(mockKey, 'url.com') + + expect(result).to.not.be.true + snapshot('not qualified url', result) + + result = validation.isFullyQualifiedUrl(mockKey, '') + expect(result).to.not.be.true + snapshot('empty string', result) + }) + }) + + describe('.isBoolean', () => { + it('returns true for value=null', () => { + const result = validation.isBoolean(mockKey, null) + + expect(result).to.be.true + }) + + it('returns true for value=true', () => { + const result = validation.isBoolean(mockKey, true) + + expect(result).to.be.true + }) + + it('returns true for value=false', () => { + const result = validation.isBoolean(mockKey, false) + + expect(result).to.be.true + }) + + it('returns error message when value is a not a string', () => { + const result = validation.isString(mockKey, 1) + + expect(result).to.not.be.true + snapshot(result) + }) + }) + + describe('.isString', () => { + it('returns true for value=null', () => { + const result = validation.isString(mockKey, null) + + expect(result).to.be.true + }) + + it('returns true for value=array', () => { + const result = validation.isString(mockKey, 'string') + + expect(result).to.be.true + }) + + it('returns error message when value is a not a string', () => { + const result = validation.isString(mockKey, 1) + + expect(result).to.not.be.true + snapshot(result) + }) + }) + + describe('.isArray', () => { + it('returns true for value=null', () => { + const result = validation.isArray(mockKey, null) + + expect(result).to.be.true + }) + + it('returns true for value=array', () => { + const result = validation.isArray(mockKey, [1, 2, 3]) + + expect(result).to.be.true + }) + + it('returns error message when value is a non-array', () => { + const result = validation.isArray(mockKey, 1) + + expect(result).to.not.be.true + snapshot(result) + }) + }) + + describe('.isStringOrFalse', () => { + it('returns true for value=string', () => { + const result = validation.isStringOrFalse(mockKey, 'string') + + expect(result).to.be.true + }) + + it('returns true for value=false', () => { + const result = validation.isStringOrFalse(mockKey, false) + + expect(result).to.be.true + }) + + it('returns error message when value is neither string nor false', () => { + const result = validation.isStringOrFalse(mockKey, null) + + expect(result).to.not.be.true + snapshot(result) + }) + }) + + describe('.isStringOrArrayOfStrings', () => { + it('returns true for value=string', () => { + const result = validation.isStringOrArrayOfStrings(mockKey, 'string') + + expect(result).to.be.true + }) + + it('returns true for value=array of strings', () => { + const result = validation.isStringOrArrayOfStrings(mockKey, ['string', 'other']) + + expect(result).to.be.true + }) + + it('returns error message when value is neither string nor array of string', () => { + let result = validation.isStringOrArrayOfStrings(mockKey, null) + + expect(result).to.not.be.true + snapshot('not string or array', result) + + result = validation.isStringOrArrayOfStrings(mockKey, [1, 2, 3]) + + expect(result).to.not.be.true + snapshot('array of non-strings', result) + }) + }) + + describe('.isOneOf', () => { + it('validates a string', () => { + const validate = validation.isOneOf('foo', 'bar') + + expect(validate).to.be.a('function') + expect(validate('test', 'foo')).to.be.true + expect(validate('test', 'bar')).to.be.true + + // different value + let msg = validate('test', 'nope') + + expect(msg).to.not.be.true + snapshot('not one of the strings error message', msg) + + msg = validate('test', 42) + expect(msg).to.not.be.true + snapshot('number instead of string', msg) + + msg = validate('test', null) + expect(msg).to.not.be.true + + return snapshot('null instead of string', msg) + }) + + it('validates a number', () => { + const validate = validation.isOneOf(1, 2, 3) + + expect(validate).to.be.a('function') + expect(validate('test', 1)).to.be.true + expect(validate('test', 3)).to.be.true + + // different value + let msg = validate('test', 4) + + expect(msg).to.not.be.true + snapshot('not one of the numbers error message', msg) + + msg = validate('test', 'foo') + expect(msg).to.not.be.true + snapshot('string instead of a number', msg) + + msg = validate('test', null) + expect(msg).to.not.be.true + + return snapshot('null instead of a number', msg) + }) + }) +}) diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json index a4b49c139f31..7648e38890e1 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/tsconfig.json @@ -1,6 +1,19 @@ { "extends": "../ts/tsconfig.json", "include": [ - "lib/*", + "lib", ], + "compilerOptions": { + "outDir": "./dist", + "noImplicitAny": true, + "strict": true, + "allowJs": false, + "noUnusedLocals": false, + "resolveJsonModule": true, + "experimentalDecorators": true, + "noUncheckedIndexedAccess": true, + "importsNotUsedAsValues": "error", + "declaration": true, + "sourceMap": true + } } diff --git a/packages/data-context/src/data/ProjectLifecycleManager.ts b/packages/data-context/src/data/ProjectLifecycleManager.ts index 12eb9731abb5..9429da4c70fa 100644 --- a/packages/data-context/src/data/ProjectLifecycleManager.ts +++ b/packages/data-context/src/data/ProjectLifecycleManager.ts @@ -20,7 +20,8 @@ import { getError, CypressError, ConfigValidationFailureInfo } from '@packages/e import type { DataContext } from '..' import { LoadConfigReply, SetupNodeEventsReply, ProjectConfigIpc, IpcHandler } from './ProjectConfigIpc' import assert from 'assert' -import type { AllModeOptions, BreakingErrResult, BreakingOption, FoundBrowser, FullConfig, TestingType } from '@packages/types' +import type { AllModeOptions, FoundBrowser, FullConfig, TestingType } from '@packages/types' +import type { BreakingErrResult, BreakingOption } from '@packages/config' import { autoBindDebug } from '../util/autoBindDebug' import type { LegacyCypressConfigJson } from '../sources' diff --git a/packages/data-context/src/util/config-options.ts b/packages/data-context/src/util/config-options.ts index 7d470fe1a1b6..983f4805679b 100644 --- a/packages/data-context/src/util/config-options.ts +++ b/packages/data-context/src/util/config-options.ts @@ -1,4 +1,4 @@ -import { options } from '@packages/config/lib/options' +import { options } from '@packages/config' export const getDefaultSpecPatterns = () => { return { diff --git a/packages/graphql/schemas/schema.graphql b/packages/graphql/schemas/schema.graphql index cf5ef0052035..eba3dadb4a65 100644 --- a/packages/graphql/schemas/schema.graphql +++ b/packages/graphql/schemas/schema.graphql @@ -581,6 +581,7 @@ enum ErrorTypeEnum { SUPPORT_FILE_NOT_FOUND TESTS_DID_NOT_START_FAILED TESTS_DID_NOT_START_RETRYING + TEST_FILES_DEPRECATION UNEXPECTED_BEFORE_BROWSER_LAUNCH_PROPERTIES UNEXPECTED_INTERNAL_ERROR UNEXPECTED_MUTATION_ERROR diff --git a/packages/server/lib/makeDataContext.ts b/packages/server/lib/makeDataContext.ts index c971d56e7637..135e817f7b3b 100644 --- a/packages/server/lib/makeDataContext.ts +++ b/packages/server/lib/makeDataContext.ts @@ -1,7 +1,7 @@ import { DataContext, getCtx, clearCtx, setCtx } from '@packages/data-context' import electron, { OpenDialogOptions, SaveDialogOptions, BrowserWindow } from 'electron' import pkg from '@packages/root' -import configUtils from '@packages/config' +import * as configUtils from '@packages/config' import { isListening } from './util/ensure-url' import type { diff --git a/packages/server/test/integration/cypress_spec.js b/packages/server/test/integration/cypress_spec.js index 12a76ec4680b..764d1ee10839 100644 --- a/packages/server/test/integration/cypress_spec.js +++ b/packages/server/test/integration/cypress_spec.js @@ -14,7 +14,7 @@ const pkg = require('@packages/root') const detect = require('@packages/launcher/lib/detect') const launch = require('@packages/launcher/lib/browsers') const extension = require('@packages/extension') -const v = require('@packages/config/lib/validation') +const { validation: v } = require('@packages/config') const argsUtil = require(`../../lib/util/args`) const { fs } = require(`../../lib/util/fs`) diff --git a/packages/types/src/config.ts b/packages/types/src/config.ts index a359fd2defd8..2f11c7304882 100644 --- a/packages/types/src/config.ts +++ b/packages/types/src/config.ts @@ -44,26 +44,3 @@ export interface SettingsOptions { testingType?: 'component' |'e2e' args?: AllModeOptions } - -// Todo, move to @packages/config when it becomes type-safe - -export type BreakingOption = - | 'RENAMED_CONFIG_OPTION' - | 'EXPERIMENTAL_COMPONENT_TESTING_REMOVED' - | 'EXPERIMENTAL_SAMESITE_REMOVED' - | 'EXPERIMENTAL_NETWORK_STUBBING_REMOVED' - | 'EXPERIMENTAL_RUN_EVENTS_REMOVED' - | 'EXPERIMENTAL_SHADOW_DOM_REMOVED' - | 'FIREFOX_GC_INTERVAL_REMOVED' - | 'NODE_VERSION_DEPRECATION_SYSTEM' - | 'NODE_VERSION_DEPRECATION_BUNDLED' - | 'CONFIG_FILE_INVALID_ROOT_CONFIG' - | 'CONFIG_FILE_INVALID_ROOT_CONFIG_E2E' - | 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT' - -export type BreakingErrResult = { - name: string - newName?: string - value?: any - configFile: string -} From dfc063d27784e7edce12d027f568033cc8affa2f Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 13:51:38 -0600 Subject: [PATCH 54/96] generate the file with gulp task --- packages/config/__snapshots__/index_spec.js | 151 ------- .../config/__snapshots__/index_spec.ts.js | 153 ------- .../config/__snapshots__/validation_spec.js | 226 ---------- .../__snapshots__/validation_spec.ts.js | 226 ---------- packages/config/index.js | 6 +- packages/config/lib/validation.d.ts | 36 -- packages/config/package.json | 28 +- packages/config/{lib => src}/index.ts | 0 packages/config/{lib => src}/options.ts | 0 packages/config/{lib => src}/validation.ts | 1 + packages/config/test/.mocharc.js | 1 + packages/config/test/unit/index_spec.js | 174 -------- packages/config/test/unit/validation_spec.js | 391 ------------------ packages/config/tsconfig.json | 17 +- 14 files changed, 27 insertions(+), 1383 deletions(-) delete mode 100644 packages/config/__snapshots__/index_spec.js delete mode 100644 packages/config/__snapshots__/index_spec.ts.js delete mode 100644 packages/config/__snapshots__/validation_spec.js delete mode 100644 packages/config/__snapshots__/validation_spec.ts.js delete mode 100644 packages/config/lib/validation.d.ts rename packages/config/{lib => src}/index.ts (100%) rename packages/config/{lib => src}/options.ts (100%) rename packages/config/{lib => src}/validation.ts (99%) create mode 100644 packages/config/test/.mocharc.js delete mode 100644 packages/config/test/unit/index_spec.js delete mode 100644 packages/config/test/unit/validation_spec.js diff --git a/packages/config/__snapshots__/index_spec.js b/packages/config/__snapshots__/index_spec.js deleted file mode 100644 index 37e17272bfa4..000000000000 --- a/packages/config/__snapshots__/index_spec.js +++ /dev/null @@ -1,151 +0,0 @@ -exports['src/index .getBreakingKeys returns list of breaking config keys 1'] = [ - "blacklistHosts", - "experimentalComponentTesting", - "experimentalGetCookiesSameSite", - "experimentalNetworkStubbing", - "experimentalRunEvents", - "experimentalShadowDomSupport", - "firefoxGcInterval", - "nodeVersion", - "nodeVersion", - "testFiles" -] - -exports['src/index .getDefaultValues returns list of public config keys 1'] = { - "animationDistanceThreshold": 5, - "baseUrl": null, - "blockHosts": null, - "chromeWebSecurity": true, - "clientCertificates": [], - "component": { - "specPattern": "**/*.cy.{js,jsx,ts,tsx}" - }, - "defaultCommandTimeout": 4000, - "downloadsFolder": "cypress/downloads", - "e2e": { - "specPattern": "cypress/e2e/**/*.cy.{js,jsx,ts,tsx}" - }, - "env": {}, - "execTimeout": 60000, - "exit": true, - "experimentalFetchPolyfill": false, - "experimentalInteractiveRunEvents": false, - "experimentalSessionSupport": false, - "experimentalSourceRewriting": false, - "fileServerFolder": "", - "fixturesFolder": "cypress/fixtures", - "excludeSpecPattern": "*.hot-update.js", - "includeShadowDom": false, - "keystrokeDelay": 0, - "modifyObstructiveCode": true, - "numTestsKeptInMemory": 50, - "pageLoadTimeout": 60000, - "pluginsFile": "cypress/plugins", - "port": null, - "projectId": null, - "redirectionLimit": 20, - "reporter": "spec", - "reporterOptions": null, - "requestTimeout": 5000, - "resolvedNodePath": null, - "resolvedNodeVersion": null, - "responseTimeout": 30000, - "retries": { - "runMode": 0, - "openMode": 0 - }, - "screenshotOnRunFailure": true, - "screenshotsFolder": "cypress/screenshots", - "slowTestThreshold": 10000, - "scrollBehavior": "top", - "supportFile": "cypress/support/e2e.{js,jsx,ts,tsx}", - "supportFolder": false, - "taskTimeout": 60000, - "trashAssetsBeforeRuns": true, - "userAgent": null, - "video": true, - "videoCompression": 32, - "videosFolder": "cypress/videos", - "videoUploadOnPasses": true, - "viewportHeight": 660, - "viewportWidth": 1000, - "waitForAnimations": true, - "watchForFileChanges": true, - "autoOpen": false, - "browsers": [], - "clientRoute": "/__/", - "configFile": "cypress.config.js", - "devServerPublicPathRoute": "/__cypress/src", - "hosts": null, - "isInteractive": true, - "isTextTerminal": false, - "morgan": true, - "namespace": "__cypress", - "reporterRoute": "/__cypress/reporter", - "socketId": null, - "socketIoCookie": "__socket.io", - "socketIoRoute": "/__socket.io", - "xhrRoute": "/xhrs/" -} - -exports['src/index .getPublicConfigKeys returns list of public config keys 1'] = [ - "animationDistanceThreshold", - "arch", - "baseUrl", - "blockHosts", - "chromeWebSecurity", - "clientCertificates", - "component", - "defaultCommandTimeout", - "downloadsFolder", - "e2e", - "env", - "execTimeout", - "exit", - "experimentalFetchPolyfill", - "experimentalInteractiveRunEvents", - "experimentalSessionSupport", - "experimentalSourceRewriting", - "fileServerFolder", - "fixturesFolder", - "excludeSpecPattern", - "includeShadowDom", - "keystrokeDelay", - "modifyObstructiveCode", - "nodeVersion", - "numTestsKeptInMemory", - "platform", - "pageLoadTimeout", - "pluginsFile", - "port", - "projectId", - "redirectionLimit", - "reporter", - "reporterOptions", - "requestTimeout", - "resolvedNodePath", - "resolvedNodeVersion", - "responseTimeout", - "retries", - "screenshotOnRunFailure", - "screenshotsFolder", - "slowTestThreshold", - "scrollBehavior", - "supportFile", - "supportFolder", - "taskTimeout", - "trashAssetsBeforeRuns", - "userAgent", - "video", - "videoCompression", - "videosFolder", - "videoUploadOnPasses", - "viewportHeight", - "viewportWidth", - "waitForAnimations", - "watchForFileChanges", - "browsers", - "hosts", - "isInteractive", - "modifyObstructiveCode" -] diff --git a/packages/config/__snapshots__/index_spec.ts.js b/packages/config/__snapshots__/index_spec.ts.js deleted file mode 100644 index 950e55900213..000000000000 --- a/packages/config/__snapshots__/index_spec.ts.js +++ /dev/null @@ -1,153 +0,0 @@ -exports['src/index .getBreakingKeys returns list of breaking config keys 1'] = [ - "integrationFolder", - "componentFolder", - "testFiles", - "blacklistHosts", - "experimentalComponentTesting", - "experimentalGetCookiesSameSite", - "experimentalNetworkStubbing", - "experimentalRunEvents", - "experimentalShadowDomSupport", - "firefoxGcInterval", - "nodeVersion", - "nodeVersion" -] - -exports['src/index .getDefaultValues returns list of public config keys 1'] = { - "animationDistanceThreshold": 5, - "baseUrl": null, - "blockHosts": null, - "chromeWebSecurity": true, - "clientCertificates": [], - "component": { - "specPattern": "**/*.cy.{js,jsx,ts,tsx}" - }, - "defaultCommandTimeout": 4000, - "downloadsFolder": "cypress/downloads", - "e2e": { - "specPattern": "cypress/e2e/**/*.cy.{js,jsx,ts,tsx}" - }, - "env": {}, - "execTimeout": 60000, - "exit": true, - "experimentalFetchPolyfill": false, - "experimentalInteractiveRunEvents": false, - "experimentalSessionSupport": false, - "experimentalSourceRewriting": false, - "fileServerFolder": "", - "fixturesFolder": "cypress/fixtures", - "excludeSpecPattern": "*.hot-update.js", - "includeShadowDom": false, - "keystrokeDelay": 0, - "modifyObstructiveCode": true, - "numTestsKeptInMemory": 50, - "pageLoadTimeout": 60000, - "pluginsFile": "cypress/plugins", - "port": null, - "projectId": null, - "redirectionLimit": 20, - "reporter": "spec", - "reporterOptions": null, - "requestTimeout": 5000, - "resolvedNodePath": null, - "resolvedNodeVersion": null, - "responseTimeout": 30000, - "retries": { - "runMode": 0, - "openMode": 0 - }, - "screenshotOnRunFailure": true, - "screenshotsFolder": "cypress/screenshots", - "slowTestThreshold": 10000, - "scrollBehavior": "top", - "supportFile": "cypress/support/e2e.{js,jsx,ts,tsx}", - "supportFolder": false, - "taskTimeout": 60000, - "trashAssetsBeforeRuns": true, - "userAgent": null, - "video": true, - "videoCompression": 32, - "videosFolder": "cypress/videos", - "videoUploadOnPasses": true, - "viewportHeight": 660, - "viewportWidth": 1000, - "waitForAnimations": true, - "watchForFileChanges": true, - "autoOpen": false, - "browsers": [], - "clientRoute": "/__/", - "configFile": "cypress.config.js", - "devServerPublicPathRoute": "/__cypress/src", - "hosts": null, - "isInteractive": true, - "isTextTerminal": false, - "morgan": true, - "namespace": "__cypress", - "reporterRoute": "/__cypress/reporter", - "socketId": null, - "socketIoCookie": "__socket.io", - "socketIoRoute": "/__socket.io", - "xhrRoute": "/xhrs/" -} - -exports['src/index .getPublicConfigKeys returns list of public config keys 1'] = [ - "animationDistanceThreshold", - "arch", - "baseUrl", - "blockHosts", - "chromeWebSecurity", - "clientCertificates", - "component", - "defaultCommandTimeout", - "downloadsFolder", - "e2e", - "env", - "execTimeout", - "exit", - "experimentalFetchPolyfill", - "experimentalInteractiveRunEvents", - "experimentalSessionSupport", - "experimentalSourceRewriting", - "fileServerFolder", - "fixturesFolder", - "excludeSpecPattern", - "includeShadowDom", - "keystrokeDelay", - "modifyObstructiveCode", - "nodeVersion", - "numTestsKeptInMemory", - "platform", - "pageLoadTimeout", - "pluginsFile", - "port", - "projectId", - "redirectionLimit", - "reporter", - "reporterOptions", - "requestTimeout", - "resolvedNodePath", - "resolvedNodeVersion", - "responseTimeout", - "retries", - "screenshotOnRunFailure", - "screenshotsFolder", - "slowTestThreshold", - "scrollBehavior", - "supportFile", - "supportFolder", - "taskTimeout", - "trashAssetsBeforeRuns", - "userAgent", - "video", - "videoCompression", - "videosFolder", - "videoUploadOnPasses", - "viewportHeight", - "viewportWidth", - "waitForAnimations", - "watchForFileChanges", - "browsers", - "hosts", - "isInteractive", - "modifyObstructiveCode" -] diff --git a/packages/config/__snapshots__/validation_spec.js b/packages/config/__snapshots__/validation_spec.js deleted file mode 100644 index 0f0171ed3ca9..000000000000 --- a/packages/config/__snapshots__/validation_spec.js +++ /dev/null @@ -1,226 +0,0 @@ -exports['undefined browsers'] = ` -Missing browsers list -` - -exports['empty list of browsers'] = ` -Expected at least one browser -` - -exports['browsers list with a string'] = { - "key": "name", - "value": "foo", - "type": "a non-empty string", - "list": "browsers" -} - -exports['src/validation .isValidBrowser passes valid browsers and forms error messages for invalid ones isValidBrowser 1'] = { - "name": "isValidBrowser", - "behavior": [ - { - "given": { - "name": "Chrome", - "displayName": "Chrome Browser", - "family": "chromium", - "path": "/path/to/chrome", - "version": "1.2.3", - "majorVersion": 1 - }, - "expect": true - }, - { - "given": { - "name": "FF", - "displayName": "Firefox", - "family": "firefox", - "path": "/path/to/firefox", - "version": "1.2.3", - "majorVersion": "1" - }, - "expect": true - }, - { - "given": { - "name": "Electron", - "displayName": "Electron", - "family": "chromium", - "path": "", - "version": "99.101.3", - "majorVersion": 99 - }, - "expect": true - }, - { - "given": { - "name": "No display name", - "family": "chromium" - }, - "expect": { - "key": "displayName", - "value": { - "name": "No display name", - "family": "chromium" - }, - "type": "a non-empty string" - } - }, - { - "given": { - "name": "bad family", - "displayName": "Bad family browser", - "family": "unknown family" - }, - "expect": { - "key": "family", - "value": { - "name": "bad family", - "displayName": "Bad family browser", - "family": "unknown family" - }, - "type": "either chromium or firefox" - } - } - ] -} - -exports['not one of the strings error message'] = { - "key": "test", - "value": "nope", - "type": "one of these values: \"foo\", \"bar\"" -} - -exports['number instead of string'] = { - "key": "test", - "value": 42, - "type": "one of these values: \"foo\", \"bar\"" -} - -exports['null instead of string'] = { - "key": "test", - "value": null, - "type": "one of these values: \"foo\", \"bar\"" -} - -exports['not one of the numbers error message'] = { - "key": "test", - "value": 4, - "type": "one of these values: 1, 2, 3" -} - -exports['string instead of a number'] = { - "key": "test", - "value": "foo", - "type": "one of these values: 1, 2, 3" -} - -exports['null instead of a number'] = { - "key": "test", - "value": null, - "type": "one of these values: 1, 2, 3" -} - -exports['src/validation .isStringOrFalse returns error message when value is neither string nor false 1'] = { - "key": "mockConfigKey", - "value": null, - "type": "a string or false" -} - -exports['src/validation .isBoolean returns error message when value is a not a string 1'] = { - "key": "mockConfigKey", - "value": 1, - "type": "a string" -} - -exports['src/validation .isString returns error message when value is a not a string 1'] = { - "key": "mockConfigKey", - "value": 1, - "type": "a string" -} - -exports['src/validation .isArray returns error message when value is a non-array 1'] = { - "key": "mockConfigKey", - "value": 1, - "type": "an array" -} - -exports['not string or array'] = { - "key": "mockConfigKey", - "value": null, - "type": "a string or an array of strings" -} - -exports['array of non-strings'] = { - "key": "mockConfigKey", - "value": [ - 1, - 2, - 3 - ], - "type": "a string or an array of strings" -} - -exports['src/validation .isNumberOrFalse returns error message when value is a not number or false 1'] = { - "key": "mockConfigKey", - "value": null, - "type": "a number or false" -} - -exports['src/validation .isPlainObject returns error message when value is a not an object 1'] = { - "key": "mockConfigKey", - "value": 1, - "type": "a plain object" -} - -exports['src/validation .isNumber returns error message when value is a not a number 1'] = { - "key": "mockConfigKey", - "value": "string", - "type": "a number" -} - -exports['invalid retry value'] = { - "key": "mockConfigKey", - "value": "1", - "type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls" -} - -exports['invalid retry object'] = { - "key": "mockConfigKey", - "value": { - "fakeMode": 1 - }, - "type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls" -} - -exports['src/validation .isValidClientCertificatesSet returns error message for certs not passed as an array array 1'] = { - "key": "mockConfigKey", - "value": "1", - "type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls" -} - -exports['src/validation .isValidClientCertificatesSet returns error message for certs object without url 1'] = { - "key": "clientCertificates[0].url", - "type": "a URL matcher" -} - -exports['missing https protocol'] = { - "key": "clientCertificates[0].url", - "value": "http://url.com", - "type": "an https protocol" -} - -exports['invalid url'] = { - "key": "clientCertificates[0].url", - "value": "not *", - "type": "a valid URL" -} - -exports['not qualified url'] = { - "key": "mockConfigKey", - "value": "url.com", - "type": "a fully qualified URL (starting with `http://` or `https://`)" -} - -exports['empty string'] = { - "key": "mockConfigKey", - "value": "", - "type": "a fully qualified URL (starting with `http://` or `https://`)" -} diff --git a/packages/config/__snapshots__/validation_spec.ts.js b/packages/config/__snapshots__/validation_spec.ts.js deleted file mode 100644 index 1b3d0e62bfce..000000000000 --- a/packages/config/__snapshots__/validation_spec.ts.js +++ /dev/null @@ -1,226 +0,0 @@ -exports['src/validation .isValidClientCertificatesSet returns error message for certs not passed as an array array 1'] = { - "key": "mockConfigKey", - "value": "1", - "type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls" -} - -exports['src/validation .isValidClientCertificatesSet returns error message for certs object without url 1'] = { - "key": "clientCertificates[0].url", - "type": "a URL matcher" -} - -exports['missing https protocol'] = { - "key": "clientCertificates[0].url", - "value": "http://url.com", - "type": "an https protocol" -} - -exports['invalid url'] = { - "key": "clientCertificates[0].url", - "value": "not *", - "type": "a valid URL" -} - -exports['src/validation .isValidBrowser passes valid browsers and forms error messages for invalid ones isValidBrowser 1'] = { - "name": "isValidBrowser", - "behavior": [ - { - "given": { - "name": "Chrome", - "displayName": "Chrome Browser", - "family": "chromium", - "path": "/path/to/chrome", - "version": "1.2.3", - "majorVersion": 1 - }, - "expect": true - }, - { - "given": { - "name": "FF", - "displayName": "Firefox", - "family": "firefox", - "path": "/path/to/firefox", - "version": "1.2.3", - "majorVersion": "1" - }, - "expect": true - }, - { - "given": { - "name": "Electron", - "displayName": "Electron", - "family": "chromium", - "path": "", - "version": "99.101.3", - "majorVersion": 99 - }, - "expect": true - }, - { - "given": { - "name": "No display name", - "family": "chromium" - }, - "expect": { - "key": "displayName", - "value": { - "name": "No display name", - "family": "chromium" - }, - "type": "a non-empty string" - } - }, - { - "given": { - "name": "bad family", - "displayName": "Bad family browser", - "family": "unknown family" - }, - "expect": { - "key": "family", - "value": { - "name": "bad family", - "displayName": "Bad family browser", - "family": "unknown family" - }, - "type": "either chromium or firefox" - } - } - ] -} - -exports['undefined browsers'] = ` -Missing browsers list -` - -exports['empty list of browsers'] = ` -Expected at least one browser -` - -exports['browsers list with a string'] = { - "key": "name", - "value": "foo", - "type": "a non-empty string", - "list": "browsers" -} - -exports['invalid retry value'] = { - "key": "mockConfigKey", - "value": "1", - "type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls" -} - -exports['invalid retry object'] = { - "key": "mockConfigKey", - "value": { - "fakeMode": 1 - }, - "type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls" -} - -exports['src/validation .isPlainObject returns error message when value is a not an object 1'] = { - "key": "mockConfigKey", - "value": 1, - "type": "a plain object" -} - -exports['src/validation .isNumber returns error message when value is a not a number 1'] = { - "key": "mockConfigKey", - "value": "string", - "type": "a number" -} - -exports['src/validation .isNumberOrFalse returns error message when value is a not number or false 1'] = { - "key": "mockConfigKey", - "value": null, - "type": "a number or false" -} - -exports['not qualified url'] = { - "key": "mockConfigKey", - "value": "url.com", - "type": "a fully qualified URL (starting with `http://` or `https://`)" -} - -exports['empty string'] = { - "key": "mockConfigKey", - "value": "", - "type": "a fully qualified URL (starting with `http://` or `https://`)" -} - -exports['src/validation .isBoolean returns error message when value is a not a string 1'] = { - "key": "mockConfigKey", - "value": 1, - "type": "a string" -} - -exports['src/validation .isString returns error message when value is a not a string 1'] = { - "key": "mockConfigKey", - "value": 1, - "type": "a string" -} - -exports['src/validation .isArray returns error message when value is a non-array 1'] = { - "key": "mockConfigKey", - "value": 1, - "type": "an array" -} - -exports['src/validation .isStringOrFalse returns error message when value is neither string nor false 1'] = { - "key": "mockConfigKey", - "value": null, - "type": "a string or false" -} - -exports['not string or array'] = { - "key": "mockConfigKey", - "value": null, - "type": "a string or an array of strings" -} - -exports['array of non-strings'] = { - "key": "mockConfigKey", - "value": [ - 1, - 2, - 3 - ], - "type": "a string or an array of strings" -} - -exports['not one of the strings error message'] = { - "key": "test", - "value": "nope", - "type": "one of these values: \"foo\", \"bar\"" -} - -exports['number instead of string'] = { - "key": "test", - "value": 42, - "type": "one of these values: \"foo\", \"bar\"" -} - -exports['null instead of string'] = { - "key": "test", - "value": null, - "type": "one of these values: \"foo\", \"bar\"" -} - -exports['not one of the numbers error message'] = { - "key": "test", - "value": 4, - "type": "one of these values: 1, 2, 3" -} - -exports['string instead of a number'] = { - "key": "test", - "value": "foo", - "type": "one of these values: 1, 2, 3" -} - -exports['null instead of a number'] = { - "key": "test", - "value": null, - "type": "one of these values: 1, 2, 3" -} diff --git a/packages/config/index.js b/packages/config/index.js index 2d2f3c0bcb52..643cb42256ee 100644 --- a/packages/config/index.js +++ b/packages/config/index.js @@ -1 +1,5 @@ -module.exports = require('./dist') +if (process.env.CYPRESS_INTERNAL_ENV !== 'production') { + require('@packages/ts/register') +} + +module.exports = require('./src') diff --git a/packages/config/lib/validation.d.ts b/packages/config/lib/validation.d.ts deleted file mode 100644 index 1d4ebe15477f..000000000000 --- a/packages/config/lib/validation.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -// TODO: Remove this file when we land type-safe @packages/config -type ErrResult = { - key: string - value: any - type: string -} - -export default { - isValidClientCertificatesSet(_key: string, certsForUrls: any[]): ErrResult | true {}, - - isValidBrowser(browser: any): ErrResult | true {}, - - isValidBrowserList(key: string, browsers: any[]): ErrResult | true {}, - - isValidRetriesConfig(key: string, value: any): ErrResult | true {}, - - isPlainObject(key: string, value: any): ErrResult | true {}, - - isNumber(key: string, value: any): ErrResult | true {}, - - isNumberOrFalse(key: string, value: any): ErrResult | true {}, - - isFullyQualifiedUrl(key: string, value: string): ErrResult | true {}, - - isBoolean(key: string, value: any): ErrResult | true {}, - - isString(key: string, value: any): ErrResult | true {}, - - isArray(key: string, value: any): ErrResult | true {}, - - isStringOrFalse(key: string, value: any): ErrResult | true {}, - - isStringOrArrayOfStrings(key: string, value: any): ErrResult | true {}, - - isOneOf(...any: any[]): (key: any, value: any) => boolean {}, -} \ No newline at end of file diff --git a/packages/config/package.json b/packages/config/package.json index 1802895b5351..c841834b442a 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -4,15 +4,14 @@ "description": "Config contains the configuration types and validation function used in the cypress electron application.", "private": true, "main": "index.js", + "browser": "src/index.ts", "scripts": { - "watch": "yarn build --watch", - "build": "tsc --project .", - "build-prod": "yarn build", + "build-prod": "tsc || echo 'built, with errors'", "check-ts": "tsc --noEmit", - "clean": "rm lib/*.js || echo 'ok'", - "test": "yarn test-unit", - "test-debug": "yarn test-unit --inspect-brk=5566", - "test-unit": "mocha --configFile=../../mocha-reporter-config.json -r @packages/ts/register -extension=.js,.ts test/unit/*spec.* --exit" + "clean-deps": "rm -rf node_modules", + "clean": "rm -f ./src/*.js ./src/**/*.js ./src/**/**/*.js ./test/**/*.js || echo 'cleaned'", + "test-unit": "mocha -r @packages/ts/register test/unit/**/*.spec.ts --config ./test/.mocharc.js --exit", + "test-integration": "mocha -r @packages/ts/register test/integration/**/*.spec.ts --config ./test/.mocharc.js --exit" }, "dependencies": { "check-more-types": "2.24.0", @@ -24,18 +23,11 @@ "@packages/root": "0.0.0-development", "@packages/ts": "0.0.0-development", "@packages/types": "0.0.0-development", - "@types/mocha": "^8.0.3", - "@types/node": "14.14.31", - "chai": "1.10.0", - "mocha": "7.0.1", - "sinon": "7.3.1", - "sinon-chai": "3.3.0", - "snap-shot-it": "7.9.3" + "chai": "4.2.0", + "mocha": "7.0.1" }, "files": [ - "lib", - "dist", - "index.js" + "src" ], - "types": "dist/index.d.ts" + "types": "src/index.ts" } diff --git a/packages/config/lib/index.ts b/packages/config/src/index.ts similarity index 100% rename from packages/config/lib/index.ts rename to packages/config/src/index.ts diff --git a/packages/config/lib/options.ts b/packages/config/src/options.ts similarity index 100% rename from packages/config/lib/options.ts rename to packages/config/src/options.ts diff --git a/packages/config/lib/validation.ts b/packages/config/src/validation.ts similarity index 99% rename from packages/config/lib/validation.ts rename to packages/config/src/validation.ts index e7843512addc..fb6df6716ecf 100644 --- a/packages/config/lib/validation.ts +++ b/packages/config/src/validation.ts @@ -1,3 +1,4 @@ +import URL from 'url' import path from 'path' import * as _ from 'lodash' import * as is from 'check-more-types' diff --git a/packages/config/test/.mocharc.js b/packages/config/test/.mocharc.js new file mode 100644 index 000000000000..4ba52ba2c8df --- /dev/null +++ b/packages/config/test/.mocharc.js @@ -0,0 +1 @@ +module.exports = {} diff --git a/packages/config/test/unit/index_spec.js b/packages/config/test/unit/index_spec.js deleted file mode 100644 index 526062fcf480..000000000000 --- a/packages/config/test/unit/index_spec.js +++ /dev/null @@ -1,174 +0,0 @@ -const chai = require('chai') -const snapshot = require('snap-shot-it') -const sinon = require('sinon') -const sinonChai = require('sinon-chai') - -const configUtil = require('../../lib/index') - -chai.use(sinonChai) -const { expect } = chai - -describe('src/index', () => { - describe('.allowed', () => { - it('returns filter config only containing allowed keys', () => { - const keys = configUtil.allowed({ - 'baseUrl': 'https://url.com', - 'blacklistHosts': 'breaking option', - 'devServerPublicPathRoute': 'internal key', - 'random': 'not a config option', - }) - - expect(keys).to.deep.eq({ - 'baseUrl': 'https://url.com', - 'blacklistHosts': 'breaking option', - }) - }) - }) - - describe('.getBreakingKeys', () => { - it('returns list of breaking config keys', () => { - const breakingKeys = configUtil.getBreakingKeys() - - expect(breakingKeys).to.include('blacklistHosts') - snapshot(breakingKeys) - }) - }) - - describe('.getDefaultValues', () => { - it('returns list of public config keys', () => { - const defaultValues = configUtil.getDefaultValues() - - expect(defaultValues).to.deep.include({ - defaultCommandTimeout: 4000, - scrollBehavior: 'top', - watchForFileChanges: true, - }) - - expect(defaultValues.env).to.deep.eq({}) - - // remove these since they are different depending on your machine - ;['platform', 'arch', 'version'].forEach((x) => { - expect(defaultValues[x]).to.exist - delete defaultValues[x] - }) - - snapshot(defaultValues) - }) - }) - - describe('.getPublicConfigKeys', () => { - it('returns list of public config keys', () => { - const publicConfigKeys = configUtil.getPublicConfigKeys() - - expect(publicConfigKeys).to.include('blockHosts') - expect(publicConfigKeys).to.not.include('devServerPublicPathRoute') - snapshot(publicConfigKeys) - }) - }) - - describe('.matchesConfigKey', () => { - it('returns normalized key when config key has a default value', () => { - let normalizedKey = configUtil.matchesConfigKey('EXEC_TIMEOUT') - - expect(normalizedKey).to.eq('execTimeout') - - normalizedKey = configUtil.matchesConfigKey('Base-url') - expect(normalizedKey).to.eq('baseUrl') - }) - - it('returns nothing when config key does not has a default value', () => { - let normalizedKey = configUtil.matchesConfigKey('random') - - expect(normalizedKey).to.be.undefined - }) - }) - - describe('.validate', () => { - it('validates config', () => { - const errorFn = sinon.spy() - - configUtil.validate({ - 'baseUrl': 'https://', - }, errorFn) - - expect(errorFn).to.have.callCount(0) - }) - - it('calls error callback if config is invalid', () => { - const errorFn = sinon.spy() - - configUtil.validate({ - 'baseUrl': ' ', - }, errorFn) - - expect(errorFn).to.have.been.calledWithMatch({ key: 'baseUrl' }) - expect(errorFn).to.have.been.calledWithMatch({ type: 'a fully qualified URL (starting with `http://` or `https://`)' }) - }) - }) - - describe('.validateNoBreakingConfig', () => { - it('calls warning callback if config contains breaking option that warns', () => { - const warningFn = sinon.spy() - const errorFn = sinon.spy() - - configUtil.validateNoBreakingConfig({ - 'experimentalNetworkStubbing': 'should break', - configFile: 'config.js', - }, warningFn, errorFn) - - expect(warningFn).to.have.been.calledOnceWith('EXPERIMENTAL_NETWORK_STUBBING_REMOVED', { - name: 'experimentalNetworkStubbing', - newName: undefined, - value: undefined, - configFile: 'config.js', - }) - - expect(errorFn).to.have.callCount(0) - }) - - it('calls error callback if config contains breaking option that should throw an error', () => { - const warningFn = sinon.spy() - const errorFn = sinon.spy() - - configUtil.validateNoBreakingConfig({ - 'blacklistHosts': 'should break', - configFile: 'config.js', - }, warningFn, errorFn) - - expect(warningFn).to.have.been.callCount(0) - expect(errorFn).to.have.been.calledOnceWith('RENAMED_CONFIG_OPTION', { - name: 'blacklistHosts', - newName: 'blockHosts', - value: undefined, - configFile: 'config.js', - }) - }) - }) - - describe('.validateNoReadOnlyConfig', () => { - it('returns an error if validation fails', () => { - const errorFn = sinon.spy() - - configUtil.validateNoReadOnlyConfig({ chromeWebSecurity: false }, errorFn) - - expect(errorFn).to.have.callCount(1) - expect(errorFn).to.have.been.calledWithMatch(/chromeWebSecurity/) - }) - - it('does not return an error if validation succeeds', () => { - const errorFn = sinon.spy() - - configUtil.validateNoReadOnlyConfig({ requestTimeout: 1000 }, errorFn) - - expect(errorFn).to.have.callCount(0) - }) - - it('does not return an error if configuration is a non-Cypress config option', () => { - const errorFn = sinon.spy() - - configUtil.validateNoReadOnlyConfig({ foo: 'bar' }, errorFn) - - expect(errorFn).to.have.callCount(0) - }) - }) -}) diff --git a/packages/config/test/unit/validation_spec.js b/packages/config/test/unit/validation_spec.js deleted file mode 100644 index b3ecbbeb8b51..000000000000 --- a/packages/config/test/unit/validation_spec.js +++ /dev/null @@ -1,391 +0,0 @@ -const snapshot = require('snap-shot-it') -const { expect } = require('chai') - -const validation = require('../../lib/validation') - -describe('src/validation', () => { - const mockKey = 'mockConfigKey' - - describe('.isValidClientCertificatesSet', () => { - it('returns error message for certs not passed as an array array', () => { - const result = validation.isValidRetriesConfig(mockKey, '1') - - expect(result).to.not.be.true - snapshot(result) - }) - - it('returns error message for certs object without url', () => { - const result = validation.isValidClientCertificatesSet(mockKey, [ - { name: 'cert' }, - ]) - - expect(result).to.not.be.true - snapshot(result) - }) - - it('returns error message for certs url not matching *', () => { - let result = validation.isValidClientCertificatesSet(mockKey, [ - { url: 'http://url.com' }, - ]) - - expect(result).to.not.be.true - snapshot('missing https protocol', result) - - result = validation.isValidClientCertificatesSet(mockKey, [ - { url: 'not *' }, - ]) - - expect(result).to.not.be.true - snapshot('invalid url', result) - }) - }) - - describe('.isValidBrowser', () => { - it('passes valid browsers and forms error messages for invalid ones', () => { - const browsers = [ - // valid browser - { - name: 'Chrome', - displayName: 'Chrome Browser', - family: 'chromium', - path: '/path/to/chrome', - version: '1.2.3', - majorVersion: 1, - }, - // another valid browser - { - name: 'FF', - displayName: 'Firefox', - family: 'firefox', - path: '/path/to/firefox', - version: '1.2.3', - majorVersion: '1', - }, - // Electron is a valid browser - { - name: 'Electron', - displayName: 'Electron', - family: 'chromium', - path: '', - version: '99.101.3', - majorVersion: 99, - }, - // invalid browser, missing displayName - { - name: 'No display name', - family: 'chromium', - }, - { - name: 'bad family', - displayName: 'Bad family browser', - family: 'unknown family', - }, - ] - - // data-driven testing - computers snapshot value for each item in the list passed through the function - // https://github.com/bahmutov/snap-shot-it#data-driven-testing - return snapshot.apply(null, [validation.isValidBrowser].concat(browsers)) - }) - }) - - describe('.isValidBrowserList', () => { - it('does not allow empty or not browsers', () => { - snapshot('undefined browsers', validation.isValidBrowserList('browsers')) - snapshot('empty list of browsers', validation.isValidBrowserList('browsers', [])) - - return snapshot('browsers list with a string', validation.isValidBrowserList('browsers', ['foo'])) - }) - }) - - describe('.isValidRetriesConfig', () => { - it('returns true for valid retry value', () => { - let result = validation.isValidRetriesConfig(mockKey, null) - - expect(result).to.be.true - - result = validation.isValidRetriesConfig(mockKey, 2) - expect(result).to.be.true - }) - - it('returns true for valid retry objects', () => { - let result = validation.isValidRetriesConfig(mockKey, { runMode: 1 }) - - expect(result).to.be.true - - result = validation.isValidRetriesConfig(mockKey, { openMode: 1 }) - expect(result).to.be.true - - result = validation.isValidRetriesConfig(mockKey, { - runMode: 3, - openMode: 0, - }) - - expect(result).to.be.true - }) - - it('returns error message for invalid retry config', () => { - let result = validation.isValidRetriesConfig(mockKey, '1') - - expect(result).to.not.be.true - snapshot('invalid retry value', result) - - result = validation.isValidRetriesConfig(mockKey, { fakeMode: 1 }) - expect(result).to.not.be.true - snapshot('invalid retry object', result) - }) - }) - - describe('.isPlainObject', () => { - it('returns true for value=null', () => { - const result = validation.isPlainObject(mockKey, null) - - expect(result).to.be.true - }) - - it('returns true for value=number', () => { - const result = validation.isPlainObject(mockKey, { foo: 'bar' }) - - expect(result).to.be.true - }) - - it('returns error message when value is a not an object', () => { - const result = validation.isPlainObject(mockKey, 1) - - expect(result).to.not.be.true - snapshot(result) - }) - }) - - describe('.isNumber', () => { - it('returns true for value=null', () => { - const result = validation.isNumber(mockKey, null) - - expect(result).to.be.true - }) - - it('returns true for value=number', () => { - const result = validation.isNumber(mockKey, 1) - - expect(result).to.be.true - }) - - it('returns error message when value is a not a number', () => { - const result = validation.isNumber(mockKey, 'string') - - expect(result).to.not.be.true - snapshot(result) - }) - }) - - describe('.isNumberOrFalse', () => { - it('returns true for value=number', () => { - const result = validation.isNumberOrFalse(mockKey, 1) - - expect(result).to.be.true - }) - - it('returns true for value=false', () => { - const result = validation.isNumberOrFalse(mockKey, false) - - expect(result).to.be.true - }) - - it('returns error message when value is a not number or false', () => { - const result = validation.isNumberOrFalse(mockKey, null) - - expect(result).to.not.be.true - snapshot(result) - }) - }) - - describe('.isFullyQualifiedUrl', () => { - it('returns true for value=null', () => { - const result = validation.isFullyQualifiedUrl(mockKey, null) - - expect(result).to.be.true - }) - - it('returns true for value=qualified urls', () => { - let result = validation.isFullyQualifiedUrl(mockKey, 'https://url.com') - - expect(result).to.be.true - result = validation.isFullyQualifiedUrl(mockKey, 'http://url.com') - expect(result).to.be.true - }) - - it('returns error message when value is a not qualified url', () => { - let result = validation.isFullyQualifiedUrl(mockKey, 'url.com') - - expect(result).to.not.be.true - snapshot('not qualified url', result) - - result = validation.isFullyQualifiedUrl(mockKey, '') - expect(result).to.not.be.true - snapshot('empty string', result) - }) - }) - - describe('.isBoolean', () => { - it('returns true for value=null', () => { - const result = validation.isBoolean(mockKey, null) - - expect(result).to.be.true - }) - - it('returns true for value=true', () => { - const result = validation.isBoolean(mockKey, true) - - expect(result).to.be.true - }) - - it('returns true for value=false', () => { - const result = validation.isBoolean(mockKey, false) - - expect(result).to.be.true - }) - - it('returns error message when value is a not a string', () => { - const result = validation.isString(mockKey, 1) - - expect(result).to.not.be.true - snapshot(result) - }) - }) - - describe('.isString', () => { - it('returns true for value=null', () => { - const result = validation.isString(mockKey, null) - - expect(result).to.be.true - }) - - it('returns true for value=array', () => { - const result = validation.isString(mockKey, 'string') - - expect(result).to.be.true - }) - - it('returns error message when value is a not a string', () => { - const result = validation.isString(mockKey, 1) - - expect(result).to.not.be.true - snapshot(result) - }) - }) - - describe('.isArray', () => { - it('returns true for value=null', () => { - const result = validation.isArray(mockKey, null) - - expect(result).to.be.true - }) - - it('returns true for value=array', () => { - const result = validation.isArray(mockKey, [1, 2, 3]) - - expect(result).to.be.true - }) - - it('returns error message when value is a non-array', () => { - const result = validation.isArray(mockKey, 1) - - expect(result).to.not.be.true - snapshot(result) - }) - }) - - describe('.isStringOrFalse', () => { - it('returns true for value=string', () => { - const result = validation.isStringOrFalse(mockKey, 'string') - - expect(result).to.be.true - }) - - it('returns true for value=false', () => { - const result = validation.isStringOrFalse(mockKey, false) - - expect(result).to.be.true - }) - - it('returns error message when value is neither string nor false', () => { - const result = validation.isStringOrFalse(mockKey, null) - - expect(result).to.not.be.true - snapshot(result) - }) - }) - - describe('.isStringOrArrayOfStrings', () => { - it('returns true for value=string', () => { - const result = validation.isStringOrArrayOfStrings(mockKey, 'string') - - expect(result).to.be.true - }) - - it('returns true for value=array of strings', () => { - const result = validation.isStringOrArrayOfStrings(mockKey, ['string', 'other']) - - expect(result).to.be.true - }) - - it('returns error message when value is neither string nor array of string', () => { - let result = validation.isStringOrArrayOfStrings(mockKey, null) - - expect(result).to.not.be.true - snapshot('not string or array', result) - - result = validation.isStringOrArrayOfStrings(mockKey, [1, 2, 3]) - - expect(result).to.not.be.true - snapshot('array of non-strings', result) - }) - }) - - describe('.isOneOf', () => { - it('validates a string', () => { - const validate = validation.isOneOf('foo', 'bar') - - expect(validate).to.be.a('function') - expect(validate('test', 'foo')).to.be.true - expect(validate('test', 'bar')).to.be.true - - // different value - let msg = validate('test', 'nope') - - expect(msg).to.not.be.true - snapshot('not one of the strings error message', msg) - - msg = validate('test', 42) - expect(msg).to.not.be.true - snapshot('number instead of string', msg) - - msg = validate('test', null) - expect(msg).to.not.be.true - - return snapshot('null instead of string', msg) - }) - - it('validates a number', () => { - const validate = validation.isOneOf(1, 2, 3) - - expect(validate).to.be.a('function') - expect(validate('test', 1)).to.be.true - expect(validate('test', 3)).to.be.true - - // different value - let msg = validate('test', 4) - - expect(msg).to.not.be.true - snapshot('not one of the numbers error message', msg) - - msg = validate('test', 'foo') - expect(msg).to.not.be.true - snapshot('string instead of a number', msg) - - msg = validate('test', null) - expect(msg).to.not.be.true - - return snapshot('null instead of a number', msg) - }) - }) -}) diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json index 7648e38890e1..10ca773d134a 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/tsconfig.json @@ -1,19 +1,22 @@ { "extends": "../ts/tsconfig.json", "include": [ - "lib", + "src" + ], + "exclude": [ + "test", + "script" ], "compilerOptions": { - "outDir": "./dist", - "noImplicitAny": true, "strict": true, "allowJs": false, - "noUnusedLocals": false, + "rootDir": "src", + "outDir": "dist", + "noImplicitAny": true, "resolveJsonModule": true, "experimentalDecorators": true, "noUncheckedIndexedAccess": true, "importsNotUsedAsValues": "error", - "declaration": true, - "sourceMap": true + "types": [] } -} +} \ No newline at end of file From 8233a1de17789ee65b2fbaef3ed25fdef769e0ff Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 13:53:49 -0600 Subject: [PATCH 55/96] rename specs so they are picked up --- packages/config/test/unit/{index_spec.ts => index.spec.ts} | 2 +- .../config/test/unit/{validation_spec.ts => validation.spec.ts} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename packages/config/test/unit/{index_spec.ts => index.spec.ts} (99%) rename packages/config/test/unit/{validation_spec.ts => validation.spec.ts} (99%) diff --git a/packages/config/test/unit/index_spec.ts b/packages/config/test/unit/index.spec.ts similarity index 99% rename from packages/config/test/unit/index_spec.ts rename to packages/config/test/unit/index.spec.ts index cb1d6b5e48ca..b9edcf34896d 100644 --- a/packages/config/test/unit/index_spec.ts +++ b/packages/config/test/unit/index.spec.ts @@ -3,7 +3,7 @@ import snapshot from 'snap-shot-it' import sinon from 'sinon' import sinonChai from 'sinon-chai' -import * as configUtil from '../../lib/index' +import * as configUtil from '../../src/index' chai.use(sinonChai) const { expect } = chai diff --git a/packages/config/test/unit/validation_spec.ts b/packages/config/test/unit/validation.spec.ts similarity index 99% rename from packages/config/test/unit/validation_spec.ts rename to packages/config/test/unit/validation.spec.ts index 8175d1d71768..ff8566e2ddfb 100644 --- a/packages/config/test/unit/validation_spec.ts +++ b/packages/config/test/unit/validation.spec.ts @@ -1,7 +1,7 @@ import snapshot from 'snap-shot-it' import { expect } from 'chai' -import * as validation from '../../lib/validation' +import * as validation from '../../src/validation' describe('src/validation', () => { const mockKey = 'mockConfigKey' From fd6119a78fdecd9718e560c8e3fe7f83aa8d94fd Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 14:03:56 -0600 Subject: [PATCH 56/96] fix babel typescript --- packages/config/src/index.ts | 5 ++++- packages/config/tsconfig.json | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/config/src/index.ts b/packages/config/src/index.ts index 5bbf35250448..760f46e6370a 100644 --- a/packages/config/src/index.ts +++ b/packages/config/src/index.ts @@ -3,7 +3,10 @@ import Debug from 'debug' import { options, breakingOptions, breakingRootOptions, testingTypeBreakingOptions } from './options' import type { BreakingOption, BreakingOptionErrorKey } from './options' -export * as validation from './validation' +// this export has to be done in 2 lines because of a bug in babel typescript +import * as validation from './validation' + +export { validation } export { breakingOptions, BreakingOption, BreakingOptionErrorKey } diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json index 10ca773d134a..fe0025721a40 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/tsconfig.json @@ -11,12 +11,10 @@ "strict": true, "allowJs": false, "rootDir": "src", - "outDir": "dist", "noImplicitAny": true, "resolveJsonModule": true, "experimentalDecorators": true, "noUncheckedIndexedAccess": true, - "importsNotUsedAsValues": "error", - "types": [] + "importsNotUsedAsValues": "error" } } \ No newline at end of file From 81ff845467d522f20f6fb4dc75d904d4e0962762 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 14:08:46 -0600 Subject: [PATCH 57/96] add missing snapshots --- .../config/__snapshots__/index.spec.ts.js | 153 ++++++++++++ .../__snapshots__/validation.spec.ts.js | 226 ++++++++++++++++++ 2 files changed, 379 insertions(+) create mode 100644 packages/config/__snapshots__/index.spec.ts.js create mode 100644 packages/config/__snapshots__/validation.spec.ts.js diff --git a/packages/config/__snapshots__/index.spec.ts.js b/packages/config/__snapshots__/index.spec.ts.js new file mode 100644 index 000000000000..950e55900213 --- /dev/null +++ b/packages/config/__snapshots__/index.spec.ts.js @@ -0,0 +1,153 @@ +exports['src/index .getBreakingKeys returns list of breaking config keys 1'] = [ + "integrationFolder", + "componentFolder", + "testFiles", + "blacklistHosts", + "experimentalComponentTesting", + "experimentalGetCookiesSameSite", + "experimentalNetworkStubbing", + "experimentalRunEvents", + "experimentalShadowDomSupport", + "firefoxGcInterval", + "nodeVersion", + "nodeVersion" +] + +exports['src/index .getDefaultValues returns list of public config keys 1'] = { + "animationDistanceThreshold": 5, + "baseUrl": null, + "blockHosts": null, + "chromeWebSecurity": true, + "clientCertificates": [], + "component": { + "specPattern": "**/*.cy.{js,jsx,ts,tsx}" + }, + "defaultCommandTimeout": 4000, + "downloadsFolder": "cypress/downloads", + "e2e": { + "specPattern": "cypress/e2e/**/*.cy.{js,jsx,ts,tsx}" + }, + "env": {}, + "execTimeout": 60000, + "exit": true, + "experimentalFetchPolyfill": false, + "experimentalInteractiveRunEvents": false, + "experimentalSessionSupport": false, + "experimentalSourceRewriting": false, + "fileServerFolder": "", + "fixturesFolder": "cypress/fixtures", + "excludeSpecPattern": "*.hot-update.js", + "includeShadowDom": false, + "keystrokeDelay": 0, + "modifyObstructiveCode": true, + "numTestsKeptInMemory": 50, + "pageLoadTimeout": 60000, + "pluginsFile": "cypress/plugins", + "port": null, + "projectId": null, + "redirectionLimit": 20, + "reporter": "spec", + "reporterOptions": null, + "requestTimeout": 5000, + "resolvedNodePath": null, + "resolvedNodeVersion": null, + "responseTimeout": 30000, + "retries": { + "runMode": 0, + "openMode": 0 + }, + "screenshotOnRunFailure": true, + "screenshotsFolder": "cypress/screenshots", + "slowTestThreshold": 10000, + "scrollBehavior": "top", + "supportFile": "cypress/support/e2e.{js,jsx,ts,tsx}", + "supportFolder": false, + "taskTimeout": 60000, + "trashAssetsBeforeRuns": true, + "userAgent": null, + "video": true, + "videoCompression": 32, + "videosFolder": "cypress/videos", + "videoUploadOnPasses": true, + "viewportHeight": 660, + "viewportWidth": 1000, + "waitForAnimations": true, + "watchForFileChanges": true, + "autoOpen": false, + "browsers": [], + "clientRoute": "/__/", + "configFile": "cypress.config.js", + "devServerPublicPathRoute": "/__cypress/src", + "hosts": null, + "isInteractive": true, + "isTextTerminal": false, + "morgan": true, + "namespace": "__cypress", + "reporterRoute": "/__cypress/reporter", + "socketId": null, + "socketIoCookie": "__socket.io", + "socketIoRoute": "/__socket.io", + "xhrRoute": "/xhrs/" +} + +exports['src/index .getPublicConfigKeys returns list of public config keys 1'] = [ + "animationDistanceThreshold", + "arch", + "baseUrl", + "blockHosts", + "chromeWebSecurity", + "clientCertificates", + "component", + "defaultCommandTimeout", + "downloadsFolder", + "e2e", + "env", + "execTimeout", + "exit", + "experimentalFetchPolyfill", + "experimentalInteractiveRunEvents", + "experimentalSessionSupport", + "experimentalSourceRewriting", + "fileServerFolder", + "fixturesFolder", + "excludeSpecPattern", + "includeShadowDom", + "keystrokeDelay", + "modifyObstructiveCode", + "nodeVersion", + "numTestsKeptInMemory", + "platform", + "pageLoadTimeout", + "pluginsFile", + "port", + "projectId", + "redirectionLimit", + "reporter", + "reporterOptions", + "requestTimeout", + "resolvedNodePath", + "resolvedNodeVersion", + "responseTimeout", + "retries", + "screenshotOnRunFailure", + "screenshotsFolder", + "slowTestThreshold", + "scrollBehavior", + "supportFile", + "supportFolder", + "taskTimeout", + "trashAssetsBeforeRuns", + "userAgent", + "video", + "videoCompression", + "videosFolder", + "videoUploadOnPasses", + "viewportHeight", + "viewportWidth", + "waitForAnimations", + "watchForFileChanges", + "browsers", + "hosts", + "isInteractive", + "modifyObstructiveCode" +] diff --git a/packages/config/__snapshots__/validation.spec.ts.js b/packages/config/__snapshots__/validation.spec.ts.js new file mode 100644 index 000000000000..a9920482ef11 --- /dev/null +++ b/packages/config/__snapshots__/validation.spec.ts.js @@ -0,0 +1,226 @@ +exports['src/validation .isValidClientCertificatesSet returns error message for certs not passed as an array array 1'] = { + "key": "mockConfigKey", + "value": "1", + "type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls" +} + +exports['src/validation .isValidClientCertificatesSet returns error message for certs object without url 1'] = { + "key": "clientCertificates[0].url", + "type": "a URL matcher" +} + +exports['missing https protocol'] = { + "key": "clientCertificates[0].url", + "value": "http://url.com", + "type": "a valid URL" +} + +exports['invalid url'] = { + "key": "clientCertificates[0].url", + "value": "not *", + "type": "a valid URL" +} + +exports['src/validation .isValidBrowser passes valid browsers and forms error messages for invalid ones isValidBrowser 1'] = { + "name": "isValidBrowser", + "behavior": [ + { + "given": { + "name": "Chrome", + "displayName": "Chrome Browser", + "family": "chromium", + "path": "/path/to/chrome", + "version": "1.2.3", + "majorVersion": 1 + }, + "expect": true + }, + { + "given": { + "name": "FF", + "displayName": "Firefox", + "family": "firefox", + "path": "/path/to/firefox", + "version": "1.2.3", + "majorVersion": "1" + }, + "expect": true + }, + { + "given": { + "name": "Electron", + "displayName": "Electron", + "family": "chromium", + "path": "", + "version": "99.101.3", + "majorVersion": 99 + }, + "expect": true + }, + { + "given": { + "name": "No display name", + "family": "chromium" + }, + "expect": { + "key": "displayName", + "value": { + "name": "No display name", + "family": "chromium" + }, + "type": "a non-empty string" + } + }, + { + "given": { + "name": "bad family", + "displayName": "Bad family browser", + "family": "unknown family" + }, + "expect": { + "key": "family", + "value": { + "name": "bad family", + "displayName": "Bad family browser", + "family": "unknown family" + }, + "type": "either chromium or firefox" + } + } + ] +} + +exports['undefined browsers'] = ` +Missing browsers list +` + +exports['empty list of browsers'] = ` +Expected at least one browser +` + +exports['browsers list with a string'] = { + "key": "name", + "value": "foo", + "type": "a non-empty string", + "list": "browsers" +} + +exports['invalid retry value'] = { + "key": "mockConfigKey", + "value": "1", + "type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls" +} + +exports['invalid retry object'] = { + "key": "mockConfigKey", + "value": { + "fakeMode": 1 + }, + "type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls" +} + +exports['src/validation .isPlainObject returns error message when value is a not an object 1'] = { + "key": "mockConfigKey", + "value": 1, + "type": "a plain object" +} + +exports['src/validation .isNumber returns error message when value is a not a number 1'] = { + "key": "mockConfigKey", + "value": "string", + "type": "a number" +} + +exports['src/validation .isNumberOrFalse returns error message when value is a not number or false 1'] = { + "key": "mockConfigKey", + "value": null, + "type": "a number or false" +} + +exports['not qualified url'] = { + "key": "mockConfigKey", + "value": "url.com", + "type": "a fully qualified URL (starting with `http://` or `https://`)" +} + +exports['empty string'] = { + "key": "mockConfigKey", + "value": "", + "type": "a fully qualified URL (starting with `http://` or `https://`)" +} + +exports['src/validation .isBoolean returns error message when value is a not a string 1'] = { + "key": "mockConfigKey", + "value": 1, + "type": "a string" +} + +exports['src/validation .isString returns error message when value is a not a string 1'] = { + "key": "mockConfigKey", + "value": 1, + "type": "a string" +} + +exports['src/validation .isArray returns error message when value is a non-array 1'] = { + "key": "mockConfigKey", + "value": 1, + "type": "an array" +} + +exports['src/validation .isStringOrFalse returns error message when value is neither string nor false 1'] = { + "key": "mockConfigKey", + "value": null, + "type": "a string or false" +} + +exports['not string or array'] = { + "key": "mockConfigKey", + "value": null, + "type": "a string or an array of strings" +} + +exports['array of non-strings'] = { + "key": "mockConfigKey", + "value": [ + 1, + 2, + 3 + ], + "type": "a string or an array of strings" +} + +exports['not one of the strings error message'] = { + "key": "test", + "value": "nope", + "type": "one of these values: \"foo\", \"bar\"" +} + +exports['number instead of string'] = { + "key": "test", + "value": 42, + "type": "one of these values: \"foo\", \"bar\"" +} + +exports['null instead of string'] = { + "key": "test", + "value": null, + "type": "one of these values: \"foo\", \"bar\"" +} + +exports['not one of the numbers error message'] = { + "key": "test", + "value": 4, + "type": "one of these values: 1, 2, 3" +} + +exports['string instead of a number'] = { + "key": "test", + "value": "foo", + "type": "one of these values: 1, 2, 3" +} + +exports['null instead of a number'] = { + "key": "test", + "value": null, + "type": "one of these values: 1, 2, 3" +} From 2c147281f7577fff05eaf6277b5b8bf041e930c2 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 14:19:21 -0600 Subject: [PATCH 58/96] fix type errors --- packages/config/package.json | 3 +-- packages/config/src/options.ts | 17 +++++++---------- packages/config/src/validation.ts | 2 +- packages/config/tsconfig.json | 8 ++++++-- .../src/data/ProjectLifecycleManager.ts | 4 ++-- packages/errors/package.json | 2 ++ packages/errors/src/errors.ts | 3 ++- 7 files changed, 21 insertions(+), 18 deletions(-) diff --git a/packages/config/package.json b/packages/config/package.json index c841834b442a..7c5c77c3d3c2 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -10,8 +10,7 @@ "check-ts": "tsc --noEmit", "clean-deps": "rm -rf node_modules", "clean": "rm -f ./src/*.js ./src/**/*.js ./src/**/**/*.js ./test/**/*.js || echo 'cleaned'", - "test-unit": "mocha -r @packages/ts/register test/unit/**/*.spec.ts --config ./test/.mocharc.js --exit", - "test-integration": "mocha -r @packages/ts/register test/integration/**/*.spec.ts --config ./test/.mocharc.js --exit" + "test": "mocha -r @packages/ts/register test/unit/**/*.spec.ts --config ./test/.mocharc.js --exit" }, "dependencies": { "check-more-types": "2.24.0", diff --git a/packages/config/src/options.ts b/packages/config/src/options.ts index 1fa791875e24..17abd65d9af9 100644 --- a/packages/config/src/options.ts +++ b/packages/config/src/options.ts @@ -16,7 +16,7 @@ export type BreakingOptionErrorKey = | 'CONFIG_FILE_INVALID_ROOT_CONFIG' | 'CONFIG_FILE_INVALID_ROOT_CONFIG_E2E' | 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT' - | 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN' + | 'TEST_FILES_DEPRECATION' type TestingType = 'e2e' | 'component' @@ -513,21 +513,13 @@ export const options: Array = [ */ export const breakingOptions: Array = [ { - name: 'integrationFolder', - errorKey: 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN', - }, { - name: 'componentFolder', - errorKey: 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN', - }, { - name: 'testFiles', - errorKey: 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN', - }, { name: 'blacklistHosts', errorKey: 'RENAMED_CONFIG_OPTION', newName: 'blockHosts', }, { name: 'experimentalComponentTesting', errorKey: 'EXPERIMENTAL_COMPONENT_TESTING_REMOVED', + isWarning: false, }, { name: 'experimentalGetCookiesSameSite', errorKey: 'EXPERIMENTAL_SAMESITE_REMOVED', @@ -559,6 +551,11 @@ export const breakingOptions: Array = [ errorKey: 'NODE_VERSION_DEPRECATION_BUNDLED', isWarning: true, }, + { + name: 'testFiles', + errorKey: 'TEST_FILES_DEPRECATION', + isWarning: false, + }, ] export const breakingRootOptions: Array = [ diff --git a/packages/config/src/validation.ts b/packages/config/src/validation.ts index fb6df6716ecf..5debf6b1e458 100644 --- a/packages/config/src/validation.ts +++ b/packages/config/src/validation.ts @@ -1,4 +1,4 @@ -import URL from 'url' +import { URL } from 'url' import path from 'path' import * as _ from 'lodash' import * as is from 'check-more-types' diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json index fe0025721a40..38874842a655 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../ts/tsconfig.json", "include": [ - "src" + "src/*.ts" ], "exclude": [ "test", @@ -15,6 +15,10 @@ "resolveJsonModule": true, "experimentalDecorators": true, "noUncheckedIndexedAccess": true, - "importsNotUsedAsValues": "error" + "importsNotUsedAsValues": "error", + "types": ["node"], + "typeRoots": [ + "../../node_modules/@types" + ], } } \ No newline at end of file diff --git a/packages/data-context/src/data/ProjectLifecycleManager.ts b/packages/data-context/src/data/ProjectLifecycleManager.ts index 9429da4c70fa..6cdcb2b3ead6 100644 --- a/packages/data-context/src/data/ProjectLifecycleManager.ts +++ b/packages/data-context/src/data/ProjectLifecycleManager.ts @@ -21,7 +21,7 @@ import type { DataContext } from '..' import { LoadConfigReply, SetupNodeEventsReply, ProjectConfigIpc, IpcHandler } from './ProjectConfigIpc' import assert from 'assert' import type { AllModeOptions, FoundBrowser, FullConfig, TestingType } from '@packages/types' -import type { BreakingErrResult, BreakingOption } from '@packages/config' +import type { BreakingErrResult, BreakingOptionErrorKey } from '@packages/config' import { autoBindDebug } from '../util/autoBindDebug' import type { LegacyCypressConfigJson } from '../sources' @@ -40,7 +40,7 @@ export interface SetupFullConfigOptions { options: Partial } -type BreakingValidationFn = (type: BreakingOption, val: BreakingErrResult) => T +type BreakingValidationFn = (type: BreakingOptionErrorKey, val: BreakingErrResult) => T /** * All of the APIs injected from @packages/server & @packages/config diff --git a/packages/errors/package.json b/packages/errors/package.json index 38d492e2ccce..49ed97cf7913 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -21,7 +21,9 @@ "strip-ansi": "6.0.0" }, "devDependencies": { + "@packages/config": "0.0.0-development", "@packages/ts": "0.0.0-development", + "@packages/types": "0.0.0-development", "@types/chai": "4.2.15", "@types/mocha": "8.2.2", "@types/node": "14.14.31", diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index 41c20b3b48bd..97ce4d481576 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -4,7 +4,8 @@ import chalk from 'chalk' import _ from 'lodash' import path from 'path' import stripAnsi from 'strip-ansi' -import type { BreakingErrResult, TestingType } from '@packages/types' +import type { TestingType } from '@packages/types' +import type { BreakingErrResult } from '@packages/config' import { humanTime, logError, parseResolvedPattern, pluralize } from './errorUtils' import { errPartial, errTemplate, fmt, theme, PartialErr } from './errTemplate' From 99311bb68eaba1c6663a1aae4c4732a361aaf0c4 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 14:23:16 -0600 Subject: [PATCH 59/96] fix types again --- packages/server/lib/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/lib/config.ts b/packages/server/lib/config.ts index 5fd67464e67e..7d9c158fa156 100644 --- a/packages/server/lib/config.ts +++ b/packages/server/lib/config.ts @@ -4,7 +4,7 @@ import _ from 'lodash' import path from 'path' import deepDiff from 'return-deep-diff' import type { ResolvedFromConfig, ResolvedConfigurationOptionSource, AllModeOptions, FullConfig } from '@packages/types' -import configUtils from '@packages/config' +import * as configUtils from '@packages/config' import * as errors from './errors' import { getProcessEnvVars, CYPRESS_SPECIAL_ENV_VARS } from './util/config' import { fs } from './util/fs' From ff5a78329c5a64c65e9cabb33604bd903243be05 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 14:30:27 -0600 Subject: [PATCH 60/96] fix types again --- packages/server/lib/config.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/server/lib/config.ts b/packages/server/lib/config.ts index 7d9c158fa156..213957fa7c0c 100644 --- a/packages/server/lib/config.ts +++ b/packages/server/lib/config.ts @@ -128,7 +128,7 @@ export function mergeDefaults ( .chain(configUtils.allowed({ ...cliConfig, ...options })) .omit('env') .omit('browsers') - .each((val, key) => { + .each((val: any, key) => { // If users pass in testing-type specific keys (eg, specPattern), // we want to merge this with what we've read from the config file, // rather than override it entirely. @@ -511,9 +511,7 @@ export function parseEnv (cfg: Record, envCLI: Record, envCLI = envCLI != null ? envCLI : {} const configFromEnv = _.reduce(envProc, (memo: string[], val, key) => { - let cfgKey: string - - cfgKey = configUtils.matchesConfigKey(key) + const cfgKey = configUtils.matchesConfigKey(key) if (cfgKey) { // only change the value if it hasn't been From 5564ba34efd9bdfaec0bbdb70a6b69a40a0db9df Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 14:32:23 -0600 Subject: [PATCH 61/96] remove mocha config --- packages/config/package.json | 2 +- packages/config/test/.mocharc.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 packages/config/test/.mocharc.js diff --git a/packages/config/package.json b/packages/config/package.json index 7c5c77c3d3c2..ae3e9dfee115 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -10,7 +10,7 @@ "check-ts": "tsc --noEmit", "clean-deps": "rm -rf node_modules", "clean": "rm -f ./src/*.js ./src/**/*.js ./src/**/**/*.js ./test/**/*.js || echo 'cleaned'", - "test": "mocha -r @packages/ts/register test/unit/**/*.spec.ts --config ./test/.mocharc.js --exit" + "test": "mocha -r @packages/ts/register test/unit/**/*.spec.ts --exit" }, "dependencies": { "check-more-types": "2.24.0", diff --git a/packages/config/test/.mocharc.js b/packages/config/test/.mocharc.js deleted file mode 100644 index 4ba52ba2c8df..000000000000 --- a/packages/config/test/.mocharc.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = {} From 48a2c4834b7e0d4c088aab45d937cac4dae1c093 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 14:34:52 -0600 Subject: [PATCH 62/96] restore old scripts --- packages/config/package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/config/package.json b/packages/config/package.json index ae3e9dfee115..4b7f6b1449e6 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -10,7 +10,9 @@ "check-ts": "tsc --noEmit", "clean-deps": "rm -rf node_modules", "clean": "rm -f ./src/*.js ./src/**/*.js ./src/**/**/*.js ./test/**/*.js || echo 'cleaned'", - "test": "mocha -r @packages/ts/register test/unit/**/*.spec.ts --exit" + "test": "yarn test-unit", + "test-debug": "yarn test-unit --inspect-brk=5566", + "test-unit": "mocha --configFile=../../mocha-reporter-config.json -r @packages/ts/register test/unit/**/*.spec.ts --exit" }, "dependencies": { "check-more-types": "2.24.0", From 71bdd0972debb312f58415c5abedf33abe3c78bd Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 15:43:52 -0600 Subject: [PATCH 63/96] add comment --- packages/server/lib/plugins/child/run_plugins.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/server/lib/plugins/child/run_plugins.js b/packages/server/lib/plugins/child/run_plugins.js index 631614664f14..bdf46532caf5 100644 --- a/packages/server/lib/plugins/child/run_plugins.js +++ b/packages/server/lib/plugins/child/run_plugins.js @@ -274,6 +274,8 @@ function throwInvalidOptionError (errorKey, name) { throw err } +// only works if config.myProperty = 'something' +// this will not throw config = {...config, myProperty: 'something'} function setInvalidPropSetterWarning (opts, errorKey, optionName, optionNameForError = optionName) { debug('setting invalid property %s', optionName) Object.defineProperty(opts, optionName, { From 59d97a0e895168797014ac69a1d92fc260b2e378 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 15:52:49 -0600 Subject: [PATCH 64/96] extract wrap from run_plugins --- .../server/lib/plugins/child/run_plugins.js | 35 +----------------- .../plugins/child/wrap-non-migrated-config.js | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 34 deletions(-) create mode 100644 packages/server/lib/plugins/child/wrap-non-migrated-config.js diff --git a/packages/server/lib/plugins/child/run_plugins.js b/packages/server/lib/plugins/child/run_plugins.js index bdf46532caf5..370252185b6f 100644 --- a/packages/server/lib/plugins/child/run_plugins.js +++ b/packages/server/lib/plugins/child/run_plugins.js @@ -14,7 +14,7 @@ const resolve = require('../../util/resolve') const browserLaunch = require('./browser_launch') const util = require('../util') const validateEvent = require('./validate_event') -const { breakingOptions } = require('@packages/config') +const wrapNonMigratedOptions = require('./wrap-non-migrated-config') const UNDEFINED_SERIALIZED = '__cypress_undefined__' @@ -264,37 +264,4 @@ class RunPlugins { } } -function throwInvalidOptionError (errorKey, name) { - debug('throwing err %s', name) - const errInternal = new Error() - - Error.captureStackTrace(errInternal, throwInvalidOptionError) - const err = require('@packages/errors').getError(errorKey, { name }, errInternal) - - throw err -} - -// only works if config.myProperty = 'something' -// this will not throw config = {...config, myProperty: 'something'} -function setInvalidPropSetterWarning (opts, errorKey, optionName, optionNameForError = optionName) { - debug('setting invalid property %s', optionName) - Object.defineProperty(opts, optionName, { - set: throwInvalidOptionError.bind(null, errorKey, optionNameForError), - }) -} - -function wrapNonMigratedOptions (options) { - debug('wrapping non-migrated options') - breakingOptions.filter(({ isWarning }) => !isWarning).forEach(({ name, errorKey }) => { - setInvalidPropSetterWarning(options, errorKey, name) - - const testingTypes = ['component', 'e2e'] - - testingTypes.forEach((testingType) => { - options[testingType] = options[testingType] || {} - setInvalidPropSetterWarning(options[testingType], errorKey, name, `${testingType}.${name}`) - }) - }) -} - exports.RunPlugins = RunPlugins diff --git a/packages/server/lib/plugins/child/wrap-non-migrated-config.js b/packages/server/lib/plugins/child/wrap-non-migrated-config.js new file mode 100644 index 000000000000..8ec12606c8d7 --- /dev/null +++ b/packages/server/lib/plugins/child/wrap-non-migrated-config.js @@ -0,0 +1,37 @@ +const debugLib = require('debug') + +const debug = debugLib(`cypress:lifecycle:child:RunPlugins:${process.pid}`) +const { breakingOptions } = require('@packages/config') + +function throwInvalidOptionError (errorKey, name) { + debug('throwing err %s', name) + const errInternal = new Error() + + Error.captureStackTrace(errInternal, throwInvalidOptionError) + const err = require('@packages/errors').getError(errorKey, { name }, errInternal) + + throw err +} + +// only works if config.myProperty = 'something' +// this will not throw config = {...config, myProperty: 'something'} +function setInvalidPropSetterWarning (opts, errorKey, optionName, optionNameForError = optionName) { + debug('setting invalid property %s', optionName) + Object.defineProperty(opts, optionName, { + set: throwInvalidOptionError.bind(null, errorKey, optionNameForError), + }) +} + +module.exports = function wrapNonMigratedOptions (options) { + debug('wrapping non-migrated options') + breakingOptions.filter(({ isWarning }) => !isWarning).forEach(({ name, errorKey }) => { + setInvalidPropSetterWarning(options, errorKey, name) + + const testingTypes = ['component', 'e2e'] + + testingTypes.forEach((testingType) => { + options[testingType] = options[testingType] || {} + setInvalidPropSetterWarning(options[testingType], errorKey, name, `${testingType}.${name}`) + }) + }) +} From d5d2f4b476926993deeb58247ac6b3629de77b65 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 15:53:19 -0600 Subject: [PATCH 65/96] change debug --- packages/server/lib/plugins/child/wrap-non-migrated-config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/lib/plugins/child/wrap-non-migrated-config.js b/packages/server/lib/plugins/child/wrap-non-migrated-config.js index 8ec12606c8d7..66a0dd47bf0b 100644 --- a/packages/server/lib/plugins/child/wrap-non-migrated-config.js +++ b/packages/server/lib/plugins/child/wrap-non-migrated-config.js @@ -1,6 +1,6 @@ const debugLib = require('debug') -const debug = debugLib(`cypress:lifecycle:child:RunPlugins:${process.pid}`) +const debug = debugLib(`cypress:lifecycle:child:WrapNonMigrated:${process.pid}`) const { breakingOptions } = require('@packages/config') function throwInvalidOptionError (errorKey, name) { From 50421d17a7d96c302a955d16de8428be8dd68e72 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 20:00:04 -0600 Subject: [PATCH 66/96] remove some changes --- packages/data-context/src/data/index.ts | 1 + .../e2e/commands/actions/selectFile.cy.js | 2 +- .../plugins/child/wrap-non-migrated-config.js | 17 + patches/@types+mocha+8.0.3.dev.patch | 5607 ++++++++++++++++ patches/@types+mocha+8.2.2.dev.patch | 5727 ----------------- yarn.lock | 6 +- 6 files changed, 5629 insertions(+), 5731 deletions(-) create mode 100644 patches/@types+mocha+8.0.3.dev.patch delete mode 100644 patches/@types+mocha+8.2.2.dev.patch diff --git a/packages/data-context/src/data/index.ts b/packages/data-context/src/data/index.ts index 2eaa88379fd3..9204cd6c190f 100644 --- a/packages/data-context/src/data/index.ts +++ b/packages/data-context/src/data/index.ts @@ -1,6 +1,7 @@ /* eslint-disable padding-line-between-statements */ // created by autobarrel, do not modify directly +export * from './LegacyPluginsIpc' export * from './ProjectConfigIpc' export * from './ProjectLifecycleManager' export * from './coreDataShape' diff --git a/packages/driver/cypress/e2e/commands/actions/selectFile.cy.js b/packages/driver/cypress/e2e/commands/actions/selectFile.cy.js index d96b3de904e9..fdcb604a7d8e 100644 --- a/packages/driver/cypress/e2e/commands/actions/selectFile.cy.js +++ b/packages/driver/cypress/e2e/commands/actions/selectFile.cy.js @@ -336,7 +336,7 @@ describe('src/cy/commands/actions/selectFile', () => { }) describe('errors', { - defaultCommandTimeout: 100, + defaultCommandTimeout: 50, }, () => { it('is a child command', (done) => { cy.on('fail', (err) => { diff --git a/packages/server/lib/plugins/child/wrap-non-migrated-config.js b/packages/server/lib/plugins/child/wrap-non-migrated-config.js index 66a0dd47bf0b..f34306b70b35 100644 --- a/packages/server/lib/plugins/child/wrap-non-migrated-config.js +++ b/packages/server/lib/plugins/child/wrap-non-migrated-config.js @@ -3,6 +3,11 @@ const debugLib = require('debug') const debug = debugLib(`cypress:lifecycle:child:WrapNonMigrated:${process.pid}`) const { breakingOptions } = require('@packages/config') +/** + * Throw the error with the proper codeFrame + * @param {string} errorKey + * @param {string} name + */ function throwInvalidOptionError (errorKey, name) { debug('throwing err %s', name) const errInternal = new Error() @@ -22,6 +27,18 @@ function setInvalidPropSetterWarning (opts, errorKey, optionName, optionNameForE }) } +/** + * When using setupNodeEvents, setting some config values is invalid. + * We validate this after running the function. + * The config that the function returns is checked for those invalid values. + * But this after-the-fact error only tells them: "you can't do that" + * + * The wrapNonMigratedOptions function wraps the config object and throws + * an error at the line the user tries to set a value that is not allowed. + * This way, the user can simply click on the codeFrame that the error + * has generated. Cypress opens the file and they can fix the problem. + * @param {Cypress.Config} options the config object passed to setupNodeEvents + */ module.exports = function wrapNonMigratedOptions (options) { debug('wrapping non-migrated options') breakingOptions.filter(({ isWarning }) => !isWarning).forEach(({ name, errorKey }) => { diff --git a/patches/@types+mocha+8.0.3.dev.patch b/patches/@types+mocha+8.0.3.dev.patch new file mode 100644 index 000000000000..5081b5c7b859 --- /dev/null +++ b/patches/@types+mocha+8.0.3.dev.patch @@ -0,0 +1,5607 @@ +diff --git a/node_modules/@types/mocha/index.d.ts b/node_modules/@types/mocha/index.d.ts +index 8d4c6db..307f232 100644 +--- a/node_modules/@types/mocha/index.d.ts ++++ b/node_modules/@types/mocha/index.d.ts +@@ -1,2801 +1,2801 @@ +-// Type definitions for mocha 8.0 +-// Project: https://mochajs.org +-// Definitions by: Kazi Manzur Rashid +-// otiai10 +-// Vadim Macagon +-// Andrew Bradley +-// Dmitrii Sorin +-// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +-// TypeScript Version: 2.1 +- +-/** +- * Mocha API +- * +- * @see https://mochajs.org/api/mocha +- */ +-declare class Mocha { +- private _growl; +- private _reporter; +- private _ui; +- +- constructor(options?: Mocha.MochaOptions); +- +- suite: Mocha.Suite; +- files: string[]; +- options: Mocha.MochaInstanceOptions; +- +- /** +- * Enable or disable bailing on the first failure. +- * +- * @see https://mochajs.org/api/mocha#bail +- */ +- bail(bail?: boolean): this; +- +- /** +- * Add test `file`. +- * +- * @see https://mochajs.org/api/mocha#addFile +- */ +- addFile(file: string): this; +- +- /** +- * Set reporter to one of the built-in reporters. +- * +- * @see https://mochajs.org/api/mocha#reporter +- */ +- reporter(reporter: Mocha.Reporter, reporterOptions?: any): this; +- +- /** +- * Set reporter to the provided constructor, one of the built-in reporters, or loads a reporter +- * from a module path. Defaults to `"spec"`. +- * +- * @see https://mochajs.org/api/mocha#reporter +- */ +- reporter(reporter?: string | Mocha.ReporterConstructor, reporterOptions?: any): this; +- +- /** +- * Set test UI to one of the built-in test interfaces. +- * +- * @see https://mochajs.org/api/mocha#ui +- */ +- ui(name: Mocha.Interface): this; +- +- /** +- * Set test UI to one of the built-in test interfaces or loads a test interface from a module +- * path. Defaults to `"bdd"`. +- * +- * @see https://mochajs.org/api/mocha#ui +- */ +- ui(name?: string): this; +- +- /** +- * Escape string and add it to grep as a RegExp. +- * +- * @see https://mochajs.org/api/mocha#fgrep +- */ +- fgrep(str: string): this; +- +- /** +- * Add regexp to grep, if `re` is a string it is escaped. +- * +- * @see https://mochajs.org/api/mocha#grep +- */ +- grep(re: string | RegExp): this; +- +- /** +- * Invert `.grep()` matches. +- * +- * @see https://mochajs.org/api/mocha#invert +- */ +- invert(): this; +- +- /** +- * Enable global leak checking. +- * +- * @see https://mochajs.org/api/mocha#checkLeaks +- */ +- checkLeaks(): this; +- +- /** +- * Display long stack-trace on failing +- * +- * @see https://mochajs.org/api/mocha#fullTrace +- */ +- fullTrace(): this; +- +- /** +- * Enable growl support. +- * +- * @see https://mochajs.org/api/mocha#growl +- */ +- growl(): this; +- +- /** +- * Ignore `globals` array or string. +- * +- * @see https://mochajs.org/api/mocha#globals +- */ +- globals(globals: string | ReadonlyArray): this; +- +- /** +- * Set the timeout in milliseconds. +- * +- * @see https://mochajs.org/api/mocha#timeout +- */ +- timeout(timeout: string | number): this; +- +- /** +- * Set the number of times to retry failed tests. +- * +- * @see https://mochajs.org/api/mocha#retries +- */ +- retries(n: number): this; +- +- /** +- * Set slowness threshold in milliseconds. +- * +- * @see https://mochajs.org/api/mocha#slow +- */ +- slow(slow: string | number): this; +- +- /** +- * Makes all tests async (accepting a callback) +- * +- * @see https://mochajs.org/api/mocha#asyncOnly. +- */ +- asyncOnly(): this; +- +- /** +- * Disable syntax highlighting (in browser). +- * +- * @see https://mochajs.org/api/mocha#noHighlighting +- */ +- noHighlighting(): this; +- +- /** +- * Enable uncaught errors to propagate (in browser). +- * +- * @see https://mochajs.org/api/mocha#allowUncaught +- */ +- allowUncaught(): boolean; +- +- /** +- * Delay root suite execution. +- * +- * @see https://mochajs.org/api/mocha#delay +- */ +- delay(): boolean; +- +- /** +- * Tests marked only fail the suite +- * +- * @see https://mochajs.org/api/mocha#forbidOnly +- */ +- forbidOnly(): boolean; +- +- /** +- * Pending tests and tests marked skip fail the suite +- * +- * @see https://mochajs.org/api/mocha#forbidPending +- */ +- forbidPending(): boolean; +- +- /** +- * Run tests and invoke `fn()` when complete. +- * +- * Note that `run` relies on Node's `require` to execute +- * the test interface functions and will be subject to the +- * cache - if the files are already in the `require` cache, +- * they will effectively be skipped. Therefore, to run tests +- * multiple times or to run tests in files that are already +- * in the `require` cache, make sure to clear them from the +- * cache first in whichever manner best suits your needs. +- * +- * @see https://mochajs.org/api/mocha#run +- */ +- run(fn?: (failures: number) => void): Mocha.Runner; +- +- /** +- * Loads ESM (and CJS) test files asynchronously. +- * +- * @see https://mochajs.org/api/mocha#loadFilesAsync +- */ +- loadFilesAsync(): Promise; +- +- /** +- * Load registered files. +- * +- * @see https://mochajs.org/api/mocha#loadFiles +- */ +- protected loadFiles(fn?: () => void): void; +- +- /** +- * Unloads `files` from Node's `require` cache. +- * +- * This allows required files to be "freshly" reloaded, providing the ability +- * to reuse a Mocha instance programmatically. +- * Note: does not clear ESM module files from the cache +- */ +- unloadFiles(): this; +- +- /** +- * Toggles parallel mode. +- * +- * Must be run before calling `run`. Changes the `Runner` class to +- * use; also enables lazy file loading if not already done so. +- * +- * @see https://mochajs.org/api/mocha#parallelMode +- */ +- parallelMode(enabled?: boolean): this; +- +- /** +- * Assigns hooks to the root suite. +- * +- * @see https://mochajs.org/api/mocha#rootHooks +- */ +- rootHooks(hooks: Mocha.RootHookObject): this; +-} +- +-declare namespace Mocha { +- namespace utils { +- /** +- * Compute a slug from the given `str`. +- * +- * @see https://mochajs.org/api/module-utils.html#.slug +- */ +- function slug(str: string): string; +- +- /** +- * Strip the function definition from `str`, and re-indent for pre whitespace. +- * +- * @see https://mochajs.org/api/module-utils.html#.clean +- */ +- function clean(str: string): string; +- +- /** +- * Highlight the given string of `js`. +- */ +- function highlight(js: string): string; +- +- /** +- * Takes some variable and asks `Object.prototype.toString()` what it thinks it is. +- */ +- function type(value: any): string; +- +- /** +- * Stringify `value`. Different behavior depending on type of value: +- * +- * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively. +- * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes. +- * - If `value` is an *empty* object, function, or array, returns `'{}'`, `'[Function]'`, or `'[]'` respectively. +- * - If `value` has properties, call canonicalize} on it, then return result of `JSON.stringify()` +- * +- * @see https://mochajs.org/api/module-utils.html#.stringify +- */ +- function stringify(value: any): string; +- +- /** +- * Return a new Thing that has the keys in sorted order. Recursive. +- * +- * If the Thing... +- * - has already been seen, return string `'[Circular]'` +- * - is `undefined`, return string `'[undefined]'` +- * - is `null`, return value `null` +- * - is some other primitive, return the value +- * - is not a primitive or an `Array`, `Object`, or `Function`, return the value of the Thing's `toString()` method +- * - is a non-empty `Array`, `Object`, or `Function`, return the result of calling this function again. +- * - is an empty `Array`, `Object`, or `Function`, returns `'[]'`, `'{}'`, or `'[Function]'` respectively. +- * +- * @see https://mochajs.org/api/module-utils.html#.canonicalize +- */ +- function canonicalize(value: any, stack: any[], typeHint: string): any; +- +- /** +- * Lookup file names at the given `path`. +- * +- * @see https://mochajs.org/api/Mocha.utils.html#.exports.lookupFiles +- */ +- function lookupFiles(filepath: string, extensions?: string[], recursive?: boolean): string[]; +- +- /** +- * Generate an undefined error with a message warning the user. +- * +- * @see https://mochajs.org/api/module-utils.html#.undefinedError +- */ +- function undefinedError(): Error; +- +- /** +- * Generate an undefined error if `err` is not defined. +- * +- * @see https://mochajs.org/api/module-utils.html#.getError +- */ +- function getError(err: Error | undefined): Error; +- +- /** +- * When invoking this function you get a filter function that get the Error.stack as an +- * input, and return a prettify output. (i.e: strip Mocha and internal node functions from +- * stack trace). +- * +- * @see https://mochajs.org/api/module-utils.html#.stackTraceFilter +- */ +- function stackTraceFilter(): (stack: string) => string; +- } +- +- namespace interfaces { +- function bdd(suite: Suite): void; +- function tdd(suite: Suite): void; +- function qunit(suite: Suite): void; +- function exports(suite: Suite): void; +- } +- +- // #region Test interface augmentations +- +- interface HookFunction { +- /** +- * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the +- * function is used as the name of the hook. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (fn: Func): void; +- +- /** +- * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the +- * function is used as the name of the hook. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (fn: AsyncFunc): void; +- +- /** +- * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (name: string, fn?: Func): void; +- +- /** +- * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (name: string, fn?: AsyncFunc): void; +- } +- +- interface SuiteFunction { +- /** +- * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing +- * nested suites. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string, fn: (this: Suite) => void): Suite; +- +- /** +- * [qunit] Describe a "suite" with the given `title`. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string): Suite; +- +- /** +- * [bdd, tdd, qunit] Indicates this suite should be executed exclusively. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- only: ExclusiveSuiteFunction; +- +- /** +- * [bdd, tdd] Indicates this suite should not be executed. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- skip: PendingSuiteFunction; +- } +- +- interface ExclusiveSuiteFunction { +- /** +- * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing +- * nested suites. Indicates this suite should be executed exclusively. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string, fn: (this: Suite) => void): Suite; +- +- /** +- * [qunit] Describe a "suite" with the given `title`. Indicates this suite should be executed +- * exclusively. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string): Suite; +- } +- +- /** +- * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing +- * nested suites. Indicates this suite should not be executed. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @returns [bdd] `Suite` +- * @returns [tdd] `void` +- */ +- interface PendingSuiteFunction { +- (title: string, fn: (this: Suite) => void): Suite | void; +- } +- +- interface TestFunction { +- /** +- * Describe a specification or test-case with the given callback `fn` acting as a thunk. +- * The name of the function is used as the name of the test. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (fn: Func): Test; +- +- /** +- * Describe a specification or test-case with the given callback `fn` acting as a thunk. +- * The name of the function is used as the name of the test. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (fn: AsyncFunc): Test; +- +- /** +- * Describe a specification or test-case with the given `title` and callback `fn` acting +- * as a thunk. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string, fn?: Func): Test; +- +- /** +- * Describe a specification or test-case with the given `title` and callback `fn` acting +- * as a thunk. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string, fn?: AsyncFunc): Test; +- +- /** +- * Indicates this test should be executed exclusively. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- only: ExclusiveTestFunction; +- +- /** +- * Indicates this test should not be executed. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- skip: PendingTestFunction; +- +- /** +- * Number of attempts to retry. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- retries(n: number): void; +- } +- +- interface ExclusiveTestFunction { +- /** +- * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` +- * acting as a thunk. The name of the function is used as the name of the test. Indicates +- * this test should be executed exclusively. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (fn: Func): Test; +- +- /** +- * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` +- * acting as a thunk. The name of the function is used as the name of the test. Indicates +- * this test should be executed exclusively. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (fn: AsyncFunc): Test; +- +- /** +- * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and +- * callback `fn` acting as a thunk. Indicates this test should be executed exclusively. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string, fn?: Func): Test; +- +- /** +- * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and +- * callback `fn` acting as a thunk. Indicates this test should be executed exclusively. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string, fn?: AsyncFunc): Test; +- } +- +- interface PendingTestFunction { +- /** +- * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` +- * acting as a thunk. The name of the function is used as the name of the test. Indicates +- * this test should not be executed. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (fn: Func): Test; +- +- /** +- * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` +- * acting as a thunk. The name of the function is used as the name of the test. Indicates +- * this test should not be executed. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (fn: AsyncFunc): Test; +- +- /** +- * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and +- * callback `fn` acting as a thunk. Indicates this test should not be executed. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string, fn?: Func): Test; +- +- /** +- * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and +- * callback `fn` acting as a thunk. Indicates this test should not be executed. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- (title: string, fn?: AsyncFunc): Test; +- } +- +- /** +- * Execute after each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#afterEach +- */ +- let afterEach: HookFunction; +- +- /** +- * Execute after running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#after +- */ +- let after: HookFunction; +- +- /** +- * Execute before each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#beforeEach +- */ +- let beforeEach: HookFunction; +- +- /** +- * Execute before running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#before +- */ +- let before: HookFunction; +- +- /** +- * Describe a "suite" containing nested suites and tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- let describe: SuiteFunction; +- +- /** +- * Describes a test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- let it: TestFunction; +- +- /** +- * Describes a pending test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- let xit: PendingTestFunction; +- +- /** +- * Execute before each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#beforeEach +- */ +- let setup: HookFunction; +- +- /** +- * Execute before running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#before +- */ +- let suiteSetup: HookFunction; +- +- /** +- * Execute after running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#after +- */ +- let suiteTeardown: HookFunction; +- +- /** +- * Describe a "suite" containing nested suites and tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- let suite: SuiteFunction; +- +- /** +- * Execute after each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#afterEach +- */ +- let teardown: HookFunction; +- +- /** +- * Describes a test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- let test: TestFunction; +- +- /** +- * Triggers root suite execution. +- * +- * - _Only available if flag --delay is passed into Mocha._ +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#runWithSuite +- */ +- function run(): void; +- +- // #endregion Test interface augmentations +- +- namespace reporters { +- /** +- * Initialize a new `Base` reporter. +- * +- * All other reporters generally inherit from this reporter, providing stats such as test duration, +- * number of tests passed / failed, etc. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Base.html +- */ +- class Base { +- constructor(runner: Runner, options?: MochaOptions); +- +- /** +- * Test run statistics +- */ +- stats: Stats; +- +- /** +- * Test failures +- */ +- failures: Test[]; +- +- /** +- * The configured runner +- */ +- runner: Runner; +- +- /** +- * Output common epilogue used by many of the bundled reporters. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Base.html#.Base#epilogue +- */ +- epilogue(): void; +- +- done?(failures: number, fn?: (failures: number) => void): void; +- } +- +- namespace Base { +- /** +- * Enables coloring by default +- * +- * @see https://mochajs.org/api/module-base#.useColors +- */ +- let useColors: boolean; +- +- /** +- * Inline diffs instead of +/- +- * +- * @see https://mochajs.org/api/module-base#.inlineDiffs +- */ +- let inlineDiffs: boolean; +- +- /** +- * Default color map +- * +- * @see https://mochajs.org/api/module-base#.colors +- */ +- const colors: ColorMap; +- +- /** +- * Default color map +- * +- * @see https://mochajs.org/api/module-base#.colors +- */ +- interface ColorMap { +- // added by Base +- pass: number; +- fail: number; +- "bright pass": number; +- "bright fail": number; +- "bright yellow": number; +- pending: number; +- suite: number; +- "error title": number; +- "error message": number; +- "error stack": number; +- checkmark: number; +- fast: number; +- medium: number; +- slow: number; +- green: number; +- light: number; +- "diff gutter": number; +- "diff added": number; +- "diff removed": number; +- +- // added by Progress +- progress: number; +- +- // added by Landing +- plane: number; +- "plane crash": number; +- runway: number; +- +- [key: string]: number; +- } +- +- /** +- * Default symbol map +- * +- * @see https://mochajs.org/api/module-base#.symbols +- */ +- const symbols: SymbolMap; +- +- /** +- * Default symbol map +- * +- * @see https://mochajs.org/api/module-base#.symbols +- */ +- interface SymbolMap { +- ok: string; +- err: string; +- dot: string; +- comma: string; +- bang: string; +- [key: string]: string; +- } +- +- /** +- * Color `str` with the given `type` (from `colors`) +- * +- * @see https://mochajs.org/api/module-base#.color +- */ +- function color(type: string, str: string): string; +- +- /** +- * Expose terminal window size +- * +- * @see https://mochajs.org/api/module-base#.window +- */ +- const window: { +- width: number; +- }; +- +- /** +- * ANSI TTY control sequences common among reporters. +- * +- * @see https://mochajs.org/api/module-base#.cursor +- */ +- namespace cursor { +- /** +- * Hides the cursor +- */ +- function hide(): void; +- +- /** +- * Shows the cursor +- */ +- function show(): void; +- +- /** +- * Deletes the current line +- */ +- function deleteLine(): void; +- +- /** +- * Moves to the beginning of the line +- */ +- function beginningOfLine(): void; +- +- /** +- * Clears the line and moves to the beginning of the line. +- */ +- function CR(): void; +- } +- +- /** +- * Returns a diff between two strings with colored ANSI output. +- * +- * @see https://mochajs.org/api/module-base#.generateDiff +- */ +- function generateDiff(actual: string, expected: string): string; +- +- /** +- * Output the given `failures` as a list. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Base.html#.exports.list1 +- */ +- function list(failures: Test[]): void; +- } +- +- /** +- * Initialize a new `Dot` matrix test reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Dot.html +- */ +- class Dot extends Base { +- } +- +- /** +- * Initialize a new `Doc` reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Doc.html +- */ +- class Doc extends Base { +- } +- +- /** +- * Initialize a new `TAP` test reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.TAP.html +- */ +- class TAP extends Base { +- } +- +- /** +- * Initialize a new `JSON` reporter +- * +- * @see https://mochajs.org/api/Mocha.reporters.JSON.html +- */ +- class JSON extends Base { +- } +- +- /** +- * Initialize a new `HTML` reporter. +- * +- * - _This reporter cannot be used on the console._ +- * +- * @see https://mochajs.org/api/Mocha.reporters.HTML.html +- */ +- class HTML extends Base { +- /** +- * Provide suite URL. +- * +- * @see https://mochajs.org/api/Mocha.reporters.HTML.html#suiteURL +- */ +- suiteURL(suite: Suite): string; +- +- /** +- * Provide test URL. +- * +- * @see https://mochajs.org/api/Mocha.reporters.HTML.html#testURL +- */ +- testURL(test: Test): string; +- +- /** +- * Adds code toggle functionality for the provided test's list element. +- * +- * @see https://mochajs.org/api/Mocha.reporters.HTML.html#addCodeToggle +- */ +- addCodeToggle(el: HTMLLIElement, contents: string): void; +- } +- +- /** +- * Initialize a new `List` test reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.List.html +- */ +- class List extends Base { +- } +- +- /** +- * Initialize a new `Min` minimal test reporter (best used with --watch). +- * +- * @see https://mochajs.org/api/Mocha.reporters.Min.html +- */ +- class Min extends Base { +- } +- +- /** +- * Initialize a new `Spec` test reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Spec.html +- */ +- class Spec extends Base { +- } +- +- /** +- * Initialize a new `NyanCat` test reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Nyan.html +- */ +- class Nyan extends Base { +- private colorIndex; +- private numberOfLines; +- private rainbowColors; +- private scoreboardWidth; +- private tick; +- private trajectories; +- private trajectoryWidthMax; +- private draw; +- private drawScoreboard; +- private appendRainbow; +- private drawRainbow; +- private drawNyanCat; +- private face; +- private cursorUp; +- private cursorDown; +- private generateColors; +- private rainbowify; +- } +- +- /** +- * Initialize a new `XUnit` test reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.XUnit.html +- */ +- class XUnit extends Base { +- constructor(runner: Runner, options?: XUnit.MochaOptions); +- +- /** +- * Override done to close the stream (if it's a file). +- * +- * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#done +- */ +- done(failures: number, fn: (failures: number) => void): void; +- +- /** +- * Write out the given line. +- * +- * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#write +- */ +- write(line: string): void; +- +- /** +- * Output tag for the given `test.` +- * +- * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#test +- */ +- test(test: Test): void; +- } +- +- namespace XUnit { +- interface MochaOptions extends Mocha.MochaOptions { +- reporterOptions?: ReporterOptions; +- } +- +- interface ReporterOptions { +- output?: string; +- suiteName?: string; +- } +- } +- +- /** +- * Initialize a new `Markdown` test reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Markdown.html +- */ +- class Markdown extends Base { +- } +- +- /** +- * Initialize a new `Progress` bar test reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Progress.html +- */ +- class Progress extends Base { +- constructor(runner: Runner, options?: Progress.MochaOptions); +- } +- +- namespace Progress { +- interface MochaOptions extends Mocha.MochaOptions { +- reporterOptions?: ReporterOptions; +- } +- +- interface ReporterOptions { +- open?: string; +- complete?: string; +- incomplete?: string; +- close?: string; +- verbose?: boolean; +- } +- } +- +- /** +- * Initialize a new `Landing` reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.Landing.html +- */ +- class Landing extends Base { +- } +- +- /** +- * Initialize a new `JSONStream` test reporter. +- * +- * @see https://mochajs.org/api/Mocha.reporters.JSONStream.html +- */ +- class JSONStream extends Base { +- } +- +- // value-only aliases +- const base: typeof Base; +- const dot: typeof Dot; +- const doc: typeof Doc; +- const tap: typeof TAP; +- const json: typeof JSON; +- const html: typeof HTML; +- const list: typeof List; +- const spec: typeof Spec; +- const nyan: typeof Nyan; +- const xunit: typeof XUnit; +- const markdown: typeof Markdown; +- const progress: typeof Progress; +- const landing: typeof Landing; +- // NOTE: not possible to type this correctly: +- // const "json-stream": typeof JSONStream; +- } +- +- /** +- * Initialize a new `Runnable` with the given `title` and callback `fn`. +- * +- * @see https://mochajs.org/api/Runnable.html +- */ +- class Runnable { +- private _slow; +- private _retries; +- private _currentRetry; +- private _timeout; +- private _timeoutError; +- +- constructor(title: string, fn?: Func | AsyncFunc); +- +- title: string; +- fn: Func | AsyncFunc | undefined; +- body: string; +- async: boolean; +- sync: boolean; +- timedOut: boolean; +- pending: boolean; +- duration?: number; +- parent?: Suite; +- state?: "failed" | "passed"; +- timer?: any; +- ctx?: Context; +- callback?: Done; +- allowUncaught?: boolean; +- file?: string; +- +- /** +- * Get test timeout. +- * +- * @see https://mochajs.org/api/Runnable.html#timeout +- */ +- timeout(): number; +- +- /** +- * Set test timeout. +- * +- * @see https://mochajs.org/api/Runnable.html#timeout +- */ +- timeout(ms: string | number): this; +- +- /** +- * Get test slowness threshold. +- * +- * @see https://mochajs.org/api/Runnable.html#slow +- */ +- slow(): number; +- +- /** +- * Set test slowness threshold. +- * +- * @see https://mochajs.org/api/Runnable.html#slow +- */ +- slow(ms: string | number): this; +- +- /** +- * Halt and mark as pending. +- */ +- skip(): never; +- +- /** +- * Check if this runnable or its parent suite is marked as pending. +- * +- * @see https://mochajs.org/api/Runnable.html#isPending +- */ +- isPending(): boolean; +- +- /** +- * Return `true` if this Runnable has failed. +- */ +- isFailed(): boolean; +- +- /** +- * Return `true` if this Runnable has passed. +- */ +- isPassed(): boolean; +- +- /** +- * Set or get number of retries. +- * +- * @see https://mochajs.org/api/Runnable.html#retries +- */ +- retries(): number; +- +- /** +- * Set or get number of retries. +- * +- * @see https://mochajs.org/api/Runnable.html#retries +- */ +- retries(n: number): void; +- +- /** +- * Set or get current retry +- * +- * @see https://mochajs.org/api/Runnable.html#currentRetry +- */ +- protected currentRetry(): number; +- +- /** +- * Set or get current retry +- * +- * @see https://mochajs.org/api/Runnable.html#currentRetry +- */ +- protected currentRetry(n: number): void; +- +- /** +- * Return the full title generated by recursively concatenating the parent's full title. +- */ +- fullTitle(): string; +- +- /** +- * Return the title path generated by concatenating the parent's title path with the title. +- */ +- titlePath(): string[]; +- +- /** +- * Clear the timeout. +- * +- * @see https://mochajs.org/api/Runnable.html#clearTimeout +- */ +- clearTimeout(): void; +- +- /** +- * Inspect the runnable void of private properties. +- * +- * @see https://mochajs.org/api/Runnable.html#inspect +- */ +- inspect(): string; +- +- /** +- * Reset the timeout. +- * +- * @see https://mochajs.org/api/Runnable.html#resetTimeout +- */ +- resetTimeout(): void; +- +- /** +- * Get a list of whitelisted globals for this test run. +- * +- * @see https://mochajs.org/api/Runnable.html#globals +- */ +- globals(): string[]; +- +- /** +- * Set a list of whitelisted globals for this test run. +- * +- * @see https://mochajs.org/api/Runnable.html#globals +- */ +- globals(globals: ReadonlyArray): void; +- +- /** +- * Run the test and invoke `fn(err)`. +- * +- * @see https://mochajs.org/api/Runnable.html#run +- */ +- run(fn: Done): void; +- } +- +- // #region Runnable "error" event +- interface Runnable extends NodeJS.EventEmitter { +- on(event: "error", listener: (error: any) => void): this; +- once(event: "error", listener: (error: any) => void): this; +- addListener(event: "error", listener: (error: any) => void): this; +- removeListener(event: "error", listener: (error: any) => void): this; +- prependListener(event: "error", listener: (error: any) => void): this; +- prependOnceListener(event: "error", listener: (error: any) => void): this; +- emit(name: "error", error: any): boolean; +- } +- // #endregion Runnable "error" event +- // #region Runnable untyped events +- interface Runnable extends NodeJS.EventEmitter { +- on(event: string, listener: (...args: any[]) => void): this; +- once(event: string, listener: (...args: any[]) => void): this; +- addListener(event: string, listener: (...args: any[]) => void): this; +- removeListener(event: string, listener: (...args: any[]) => void): this; +- prependListener(event: string, listener: (...args: any[]) => void): this; +- prependOnceListener(event: string, listener: (...args: any[]) => void): this; +- emit(name: string, ...args: any[]): boolean; +- } +- // #endregion Runnable untyped events +- +- /** +- * Test context +- * +- * @see https://mochajs.org/api/module-Context.html#~Context +- */ +- class Context { +- private _runnable; +- +- test?: Runnable; +- currentTest?: Test; +- +- /** +- * Get the context `Runnable`. +- */ +- runnable(): Runnable; +- +- /** +- * Set the context `Runnable`. +- */ +- runnable(runnable: Runnable): this; +- +- /** +- * Get test timeout. +- */ +- timeout(): number; +- +- /** +- * Set test timeout. +- */ +- timeout(ms: string | number): this; +- +- /** +- * Get test slowness threshold. +- */ +- slow(): number; +- +- /** +- * Set test slowness threshold. +- */ +- slow(ms: string | number): this; +- +- /** +- * Mark a test as skipped. +- */ +- skip(): never; +- +- /** +- * Get the number of allowed retries on failed tests. +- */ +- retries(): number; +- +- /** +- * Set the number of allowed retries on failed tests. +- */ +- retries(n: number): this; +- +- [key: string]: any; +- } +- +- interface RunnerConstants { +- readonly EVENT_HOOK_BEGIN: 'hook'; +- readonly EVENT_HOOK_END: 'hook end'; +- readonly EVENT_RUN_BEGIN: 'start'; +- readonly EVENT_DELAY_BEGIN: 'waiting'; +- readonly EVENT_DELAY_END: 'ready'; +- readonly EVENT_RUN_END: 'end'; +- readonly EVENT_SUITE_BEGIN: 'suite'; +- readonly EVENT_SUITE_END: 'suite end'; +- readonly EVENT_TEST_BEGIN: 'test'; +- readonly EVENT_TEST_END: 'test end'; +- readonly EVENT_TEST_FAIL: 'fail'; +- readonly EVENT_TEST_PASS: 'pass'; +- readonly EVENT_TEST_PENDING: 'pending'; +- readonly EVENT_TEST_RETRY: 'retry'; +- } +- +- /** +- * Initialize a `Runner` for the given `suite`. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html +- */ +- class Runner { +- private _globals; +- private _abort; +- private _delay; +- private _defaultGrep; +- private next; +- private hookErr; +- private prevGlobalsLength; +- private nextSuite; +- +- static readonly constants: RunnerConstants; +- +- constructor(suite: Suite, delay: boolean); +- +- suite: Suite; +- started: boolean; +- total: number; +- failures: number; +- asyncOnly?: boolean; +- allowUncaught?: boolean; +- fullStackTrace?: boolean; +- forbidOnly?: boolean; +- forbidPending?: boolean; +- checkLeaks?: boolean; +- test?: Test; +- currentRunnable?: Runnable; +- stats?: Stats; // added by reporters +- +- /** +- * Run tests with full titles matching `re`. Updates runner.total +- * with number of tests matched. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grep +- */ +- grep(re: RegExp, invert: boolean): this; +- +- /** +- * Returns the number of tests matching the grep search for the +- * given suite. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grepTotal +- */ +- grepTotal(suite: Suite): number; +- +- /** +- * Gets the allowed globals. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals +- */ +- globals(): string[]; +- +- /** +- * Allow the given `arr` of globals. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals +- */ +- globals(arr: ReadonlyArray): this; +- +- /** +- * Run the root suite and invoke `fn(failures)` on completion. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#run +- */ +- run(fn?: (failures: number) => void): this; +- +- /** +- * Cleanly abort execution. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#abort +- */ +- abort(): this; +- +- /** +- * Handle uncaught exceptions. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#uncaught +- */ +- uncaught(err: any): void; +- +- /** +- * Wrapper for setImmediate, process.nextTick, or browser polyfill. +- */ +- protected static immediately(callback: Function): void; +- +- /** +- * Return a list of global properties. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#globalProps +- */ +- protected globalProps(): string[]; +- +- /** +- * Check for global variable leaks. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#checkGlobals +- */ +- protected checkGlobals(test: Test): void; +- +- /** +- * Fail the given `test`. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#fail +- */ +- protected fail(test: Test, err: any): void; +- +- /** +- * Fail the given `hook` with `err`. +- * +- * Hook failures work in the following pattern: +- * - If bail, then exit +- * - Failed `before` hook skips all tests in a suite and subsuites, +- * but jumps to corresponding `after` hook +- * - Failed `before each` hook skips remaining tests in a +- * suite and jumps to corresponding `after each` hook, +- * which is run only once +- * - Failed `after` hook does not alter +- * execution order +- * - Failed `after each` hook skips remaining tests in a +- * suite and subsuites, but executes other `after each` +- * hooks +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#failHook +- */ +- protected failHook(hook: Hook, err: any): void; +- +- /** +- * Run hook `name` callbacks and then invoke `fn()`. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#hook +- */ +- protected hook(name: string, fn: () => void): void; +- +- /** +- * Run hook `name` for the given array of `suites` +- * in order, and callback `fn(err, errSuite)`. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#hooks +- */ +- protected hooks(name: string, suites: Suite[], fn: (err?: any, errSuite?: Suite) => void): void; +- +- /** +- * Run hooks from the top level down. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#hookUp +- */ +- protected hookUp(name: string, fn: (err?: any, errSuite?: Suite) => void): void; +- +- /** +- * Run hooks from the bottom up. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#hookDown +- */ +- protected hookDown(name: string, fn: (err?: any, errSuite?: Suite) => void): void; +- +- /** +- * Return an array of parent Suites from closest to furthest. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#parents +- */ +- protected parents(): Suite[]; +- +- /** +- * Run the current test and callback `fn(err)`. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#runTest +- */ +- protected runTest(fn: Done): any; +- +- /** +- * Run tests in the given `suite` and invoke the callback `fn()` when complete. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#runTests +- */ +- protected runTests(suite: Suite, fn: (errSuite?: Suite) => void): void; +- +- /** +- * Run the given `suite` and invoke the callback `fn()` when complete. +- * +- * @see https://mochajs.org/api/Mocha.Runner.html#runSuite +- */ +- protected runSuite(suite: Suite, fn: (errSuite?: Suite) => void): void; +- } +- +- // #region Runner "waiting" event +- interface Runner { +- on(event: "waiting", listener: (rootSuite: Suite) => void): this; +- once(event: "waiting", listener: (rootSuite: Suite) => void): this; +- addListener(event: "waiting", listener: (rootSuite: Suite) => void): this; +- removeListener(event: "waiting", listener: (rootSuite: Suite) => void): this; +- prependListener(event: "waiting", listener: (rootSuite: Suite) => void): this; +- prependOnceListener(event: "waiting", listener: (rootSuite: Suite) => void): this; +- emit(name: "waiting", rootSuite: Suite): boolean; +- } +- // #endregion Runner "waiting" event +- // #region Runner "start" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "start", listener: () => void): this; +- once(event: "start", listener: () => void): this; +- addListener(event: "start", listener: () => void): this; +- removeListener(event: "start", listener: () => void): this; +- prependListener(event: "start", listener: () => void): this; +- prependOnceListener(event: "start", listener: () => void): this; +- emit(name: "start"): boolean; +- } +- // #endregion Runner "start" event +- // #region Runner "end" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "end", listener: () => void): this; +- once(event: "end", listener: () => void): this; +- addListener(event: "end", listener: () => void): this; +- removeListener(event: "end", listener: () => void): this; +- prependListener(event: "end", listener: () => void): this; +- prependOnceListener(event: "end", listener: () => void): this; +- emit(name: "end"): boolean; +- } +- // #endregion Runner "end" event +- // #region Runner "suite" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "suite", listener: (suite: Suite) => void): this; +- once(event: "suite", listener: (suite: Suite) => void): this; +- addListener(event: "suite", listener: (suite: Suite) => void): this; +- removeListener(event: "suite", listener: (suite: Suite) => void): this; +- prependListener(event: "suite", listener: (suite: Suite) => void): this; +- prependOnceListener(event: "suite", listener: (suite: Suite) => void): this; +- emit(name: "suite", suite: Suite): boolean; +- } +- // #endregion Runner "suite" event +- // #region Runner "suite end" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "suite end", listener: (suite: Suite) => void): this; +- once(event: "suite end", listener: (suite: Suite) => void): this; +- addListener(event: "suite end", listener: (suite: Suite) => void): this; +- removeListener(event: "suite end", listener: (suite: Suite) => void): this; +- prependListener(event: "suite end", listener: (suite: Suite) => void): this; +- prependOnceListener(event: "suite end", listener: (suite: Suite) => void): this; +- emit(name: "suite end", suite: Suite): boolean; +- } +- // #endregion Runner "suite end" event +- // #region Runner "test" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "test", listener: (test: Test) => void): this; +- once(event: "test", listener: (test: Test) => void): this; +- addListener(event: "test", listener: (test: Test) => void): this; +- removeListener(event: "test", listener: (test: Test) => void): this; +- prependListener(event: "test", listener: (test: Test) => void): this; +- prependOnceListener(event: "test", listener: (test: Test) => void): this; +- emit(name: "test", test: Test): boolean; +- } +- // #endregion Runner "test" event +- // #region Runner "test end" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "test end", listener: (test: Test) => void): this; +- once(event: "test end", listener: (test: Test) => void): this; +- addListener(event: "test end", listener: (test: Test) => void): this; +- removeListener(event: "test end", listener: (test: Test) => void): this; +- prependListener(event: "test end", listener: (test: Test) => void): this; +- prependOnceListener(event: "test end", listener: (test: Test) => void): this; +- emit(name: "test end", test: Test): boolean; +- } +- // #endregion Runner "test end" event +- // #region Runner "hook" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "hook", listener: (hook: Hook) => void): this; +- once(event: "hook", listener: (hook: Hook) => void): this; +- addListener(event: "hook", listener: (hook: Hook) => void): this; +- removeListener(event: "hook", listener: (hook: Hook) => void): this; +- prependListener(event: "hook", listener: (hook: Hook) => void): this; +- prependOnceListener(event: "hook", listener: (hook: Hook) => void): this; +- emit(name: "hook", hook: Hook): boolean; +- } +- // #endregion Runner "hook" event +- // #region Runner "hook end" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "hook end", listener: (hook: Hook) => void): this; +- once(event: "hook end", listener: (hook: Hook) => void): this; +- addListener(event: "hook end", listener: (hook: Hook) => void): this; +- removeListener(event: "hook end", listener: (hook: Hook) => void): this; +- prependListener(event: "hook end", listener: (hook: Hook) => void): this; +- prependOnceListener(event: "hook end", listener: (hook: Hook) => void): this; +- emit(name: "hook end", hook: Hook): boolean; +- } +- // #endregion Runner "hook end" event +- // #region Runner "pass" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "pass", listener: (test: Test) => void): this; +- once(event: "pass", listener: (test: Test) => void): this; +- addListener(event: "pass", listener: (test: Test) => void): this; +- removeListener(event: "pass", listener: (test: Test) => void): this; +- prependListener(event: "pass", listener: (test: Test) => void): this; +- prependOnceListener(event: "pass", listener: (test: Test) => void): this; +- emit(name: "pass", test: Test): boolean; +- } +- // #endregion Runner "pass" event +- // #region Runner "fail" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "fail", listener: (test: Test, err: any) => void): this; +- once(event: "fail", listener: (test: Test, err: any) => void): this; +- addListener(event: "fail", listener: (test: Test, err: any) => void): this; +- removeListener(event: "fail", listener: (test: Test, err: any) => void): this; +- prependListener(event: "fail", listener: (test: Test, err: any) => void): this; +- prependOnceListener(event: "fail", listener: (test: Test, err: any) => void): this; +- emit(name: "fail", test: Test, err: any): boolean; +- } +- // #endregion Runner "fail" event +- // #region Runner "pending" event +- interface Runner extends NodeJS.EventEmitter { +- on(event: "pending", listener: (test: Test) => void): this; +- once(event: "pending", listener: (test: Test) => void): this; +- addListener(event: "pending", listener: (test: Test) => void): this; +- removeListener(event: "pending", listener: (test: Test) => void): this; +- prependListener(event: "pending", listener: (test: Test) => void): this; +- prependOnceListener(event: "pending", listener: (test: Test) => void): this; +- emit(name: "pending", test: Test): boolean; +- } +- // #endregion Runner "pending" event +- // #region Runner untyped events +- interface Runner extends NodeJS.EventEmitter { +- on(event: string, listener: (...args: any[]) => void): this; +- once(event: string, listener: (...args: any[]) => void): this; +- addListener(event: string, listener: (...args: any[]) => void): this; +- removeListener(event: string, listener: (...args: any[]) => void): this; +- prependListener(event: string, listener: (...args: any[]) => void): this; +- prependOnceListener(event: string, listener: (...args: any[]) => void): this; +- emit(name: string, ...args: any[]): boolean; +- } +- // #endregion Runner untyped events +- +- interface SuiteConstants { +- readonly EVENT_FILE_POST_REQUIRE: 'post-require'; +- readonly EVENT_FILE_PRE_REQUIRE: 'pre-require'; +- readonly EVENT_FILE_REQUIRE: 'require'; +- readonly EVENT_ROOT_SUITE_RUN: 'run'; +- +- readonly HOOK_TYPE_AFTER_ALL: 'afterAll'; +- readonly HOOK_TYPE_AFTER_EACH: 'afterEach'; +- readonly HOOK_TYPE_BEFORE_ALL: 'beforeAll'; +- readonly HOOK_TYPE_BEFORE_EACH: 'beforeEach'; +- +- readonly EVENT_SUITE_ADD_HOOK_AFTER_ALL: 'afterAll'; +- readonly EVENT_SUITE_ADD_HOOK_AFTER_EACH: 'afterEach'; +- readonly EVENT_SUITE_ADD_HOOK_BEFORE_ALL: 'beforeAll'; +- readonly EVENT_SUITE_ADD_HOOK_BEFORE_EACH: 'beforeEach'; +- readonly EVENT_SUITE_ADD_SUITE: 'suite'; +- readonly EVENT_SUITE_ADD_TEST: 'test'; +- } +- +- /** +- * Initialize a new `Suite` with the given `title` and `ctx`. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html +- */ +- class Suite { +- private _beforeEach; +- private _beforeAll; +- private _afterEach; +- private _afterAll; +- private _timeout; +- private _slow; +- private _bail; +- private _retries; +- private _onlyTests; +- private _onlySuites; +- +- static readonly constants: SuiteConstants; +- +- constructor(title: string, parentContext?: Context); +- +- ctx: Context; +- suites: Suite[]; +- tests: Test[]; +- pending: boolean; +- file?: string; +- root: boolean; +- delayed: boolean; +- parent: Suite | undefined; +- title: string; +- +- /** +- * Create a new `Suite` with the given `title` and parent `Suite`. When a suite +- * with the same title is already present, that suite is returned to provide +- * nicer reporter and more flexible meta-testing. +- * +- * @see https://mochajs.org/api/mocha#.exports.create +- */ +- static create(parent: Suite, title: string): Suite; +- +- /** +- * Return a clone of this `Suite`. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#clone +- */ +- clone(): Suite; +- +- /** +- * Get timeout `ms`. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#timeout +- */ +- timeout(): number; +- +- /** +- * Set timeout `ms` or short-hand such as "2s". +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#timeout +- */ +- timeout(ms: string | number): this; +- +- /** +- * Get number of times to retry a failed test. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#retries +- */ +- retries(): number; +- +- /** +- * Set number of times to retry a failed test. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#retries +- */ +- retries(n: string | number): this; +- +- /** +- * Get slow `ms`. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#slow +- */ +- slow(): number; +- +- /** +- * Set slow `ms` or short-hand such as "2s". +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#slow +- */ +- slow(ms: string | number): this; +- +- /** +- * Get whether to bail after first error. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#bail +- */ +- bail(): boolean; +- +- /** +- * Set whether to bail after first error. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#bail +- */ +- bail(bail: boolean): this; +- +- /** +- * Check if this suite or its parent suite is marked as pending. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#isPending +- */ +- isPending(): boolean; +- +- /** +- * Run `fn(test[, done])` before running tests. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll +- */ +- beforeAll(fn?: Func): this; +- +- /** +- * Run `fn(test[, done])` before running tests. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll +- */ +- beforeAll(fn?: AsyncFunc): this; +- +- /** +- * Run `fn(test[, done])` before running tests. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll +- */ +- beforeAll(title: string, fn?: Func): this; +- +- /** +- * Run `fn(test[, done])` before running tests. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll +- */ +- beforeAll(title: string, fn?: AsyncFunc): this; +- +- /** +- * Run `fn(test[, done])` after running tests. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#afterAll +- */ +- afterAll(fn?: Func): this; +- +- /** +- * Run `fn(test[, done])` after running tests. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#afterAll +- */ +- afterAll(fn?: AsyncFunc): this; +- +- /** +- * Run `fn(test[, done])` after running tests. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#afterAll +- */ +- afterAll(title: string, fn?: Func): this; +- +- /** +- * Run `fn(test[, done])` after running tests. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#afterAll +- */ +- afterAll(title: string, fn?: AsyncFunc): this; +- +- /** +- * Run `fn(test[, done])` before each test case. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach +- */ +- beforeEach(fn?: Func): this; +- +- /** +- * Run `fn(test[, done])` before each test case. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach +- */ +- beforeEach(fn?: AsyncFunc): this; +- +- /** +- * Run `fn(test[, done])` before each test case. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach +- */ +- beforeEach(title: string, fn?: Func): this; +- +- /** +- * Run `fn(test[, done])` before each test case. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach +- */ +- beforeEach(title: string, fn?: AsyncFunc): this; +- +- /** +- * Run `fn(test[, done])` after each test case. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#afterEach +- */ +- afterEach(fn?: Func): this; +- +- /** +- * Run `fn(test[, done])` after each test case. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#afterEach +- */ +- afterEach(fn?: AsyncFunc): this; +- +- /** +- * Run `fn(test[, done])` after each test case. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#afterEach +- */ +- afterEach(title: string, fn?: Func): this; +- +- /** +- * Run `fn(test[, done])` after each test case. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#afterEach +- */ +- afterEach(title: string, fn?: AsyncFunc): this; +- +- /** +- * Add a test `suite`. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#addSuite +- */ +- addSuite(suite: Suite): this; +- +- /** +- * Add a `test` to this suite. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#addTest +- */ +- addTest(test: Test): this; +- +- /** +- * Return the full title generated by recursively concatenating the parent's +- * full title. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#fullTitle +- */ +- fullTitle(): string; +- +- /** +- * Return the title path generated by recursively concatenating the parent's +- * title path. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#titlePath +- */ +- titlePath(): string[]; +- +- /** +- * Return the total number of tests. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#total +- */ +- total(): number; +- +- /** +- * Iterates through each suite recursively to find all tests. Applies a +- * function in the format `fn(test)`. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#eachTest +- */ +- eachTest(fn: (test: Test) => void): this; +- +- /** +- * This will run the root suite if we happen to be running in delayed mode. +- * +- * @see https://mochajs.org/api/Mocha.Suite.html#run +- */ +- run(): void; +- +- /** +- * Generic hook-creator. +- */ +- protected _createHook(title: string, fn?: Func | AsyncFunc): Hook; +- } +- +- // #region Suite "beforeAll" event +- interface Suite extends NodeJS.EventEmitter { +- on(event: "beforeAll", listener: (hook: Hook) => void): this; +- once(event: "beforeAll", listener: (hook: Hook) => void): this; +- addListener(event: "beforeAll", listener: (hook: Hook) => void): this; +- removeListener(event: "beforeAll", listener: (hook: Hook) => void): this; +- prependListener(event: "beforeAll", listener: (hook: Hook) => void): this; +- prependOnceListener(event: "beforeAll", listener: (hook: Hook) => void): this; +- emit(name: "beforeAll", hook: Hook): boolean; +- } +- // #endregion Suite "beforeAll" event +- // #region Suite "afterAll" event +- interface Suite extends NodeJS.EventEmitter { +- on(event: "afterAll", listener: (hook: Hook) => void): this; +- once(event: "afterAll", listener: (hook: Hook) => void): this; +- addListener(event: "afterAll", listener: (hook: Hook) => void): this; +- removeListener(event: "afterAll", listener: (hook: Hook) => void): this; +- prependListener(event: "afterAll", listener: (hook: Hook) => void): this; +- prependOnceListener(event: "afterAll", listener: (hook: Hook) => void): this; +- emit(name: "afterAll", hook: Hook): boolean; +- } +- // #endregion Suite "afterAll" event +- // #region Suite "beforeEach" event +- interface Suite extends NodeJS.EventEmitter { +- on(event: "beforeEach", listener: (hook: Hook) => void): this; +- once(event: "beforeEach", listener: (hook: Hook) => void): this; +- addListener(event: "beforeEach", listener: (hook: Hook) => void): this; +- removeListener(event: "beforeEach", listener: (hook: Hook) => void): this; +- prependListener(event: "beforeEach", listener: (hook: Hook) => void): this; +- prependOnceListener(event: "beforeEach", listener: (hook: Hook) => void): this; +- emit(name: "beforeEach", hook: Hook): boolean; +- } +- // #endregion Suite "beforeEach" event +- // #region Suite "afterEach" event +- interface Suite extends NodeJS.EventEmitter { +- on(event: "afterEach", listener: (hook: Hook) => void): this; +- once(event: "afterEach", listener: (hook: Hook) => void): this; +- addListener(event: "afterEach", listener: (hook: Hook) => void): this; +- removeListener(event: "afterEach", listener: (hook: Hook) => void): this; +- prependListener(event: "afterEach", listener: (hook: Hook) => void): this; +- prependOnceListener(event: "afterEach", listener: (hook: Hook) => void): this; +- emit(name: "afterEach", hook: Hook): boolean; +- } +- // #endregion Suite "afterEach" event +- // #region Suite "suite" event +- interface Suite extends NodeJS.EventEmitter { +- on(event: "suite", listener: (suite: Suite) => void): this; +- once(event: "suite", listener: (suite: Suite) => void): this; +- addListener(event: "suite", listener: (suite: Suite) => void): this; +- removeListener(event: "suite", listener: (suite: Suite) => void): this; +- prependListener(event: "suite", listener: (suite: Suite) => void): this; +- prependOnceListener(event: "suite", listener: (suite: Suite) => void): this; +- emit(name: "suite", suite: Suite): boolean; +- } +- // #endregion Suite "suite" event +- // #region Suite "test" event +- interface Suite { +- on(event: "test", listener: (test: Test) => void): this; +- once(event: "test", listener: (test: Test) => void): this; +- addListener(event: "test", listener: (test: Test) => void): this; +- removeListener(event: "test", listener: (test: Test) => void): this; +- prependListener(event: "test", listener: (test: Test) => void): this; +- prependOnceListener(event: "test", listener: (test: Test) => void): this; +- emit(name: "test", test: Test): boolean; +- } +- // #endregion Suite "test" event +- // #region Suite "run" event +- interface Suite extends NodeJS.EventEmitter { +- on(event: "run", listener: () => void): this; +- once(event: "run", listener: () => void): this; +- addListener(event: "run", listener: () => void): this; +- removeListener(event: "run", listener: () => void): this; +- prependListener(event: "run", listener: () => void): this; +- prependOnceListener(event: "run", listener: () => void): this; +- emit(name: "run"): boolean; +- } +- // #endregion Suite "run" event +- // #region Suite "pre-require" event +- interface Suite extends NodeJS.EventEmitter { +- on(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- once(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- addListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- removeListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- prependListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- prependOnceListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- emit(name: "pre-require", context: MochaGlobals, file: string, mocha: Mocha): boolean; +- } +- // #endregion Suite "pre-require" event +- // #region Suite "require" event +- interface Suite extends NodeJS.EventEmitter { +- on(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; +- once(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; +- addListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; +- removeListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; +- prependListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; +- prependOnceListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; +- emit(name: "require", module: any, file: string, mocha: Mocha): boolean; +- } +- // #endregion Suite "require" event +- // #region Suite "post-require" event +- interface Suite extends NodeJS.EventEmitter { +- on(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- once(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- addListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- removeListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- prependListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- prependOnceListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; +- emit(name: "post-require", context: MochaGlobals, file: string, mocha: Mocha): boolean; +- } +- // #endregion Suite "post-require" event +- // #region Suite untyped events +- interface Suite extends NodeJS.EventEmitter { +- on(event: string, listener: (...args: any[]) => void): this; +- once(event: string, listener: (...args: any[]) => void): this; +- addListener(event: string, listener: (...args: any[]) => void): this; +- removeListener(event: string, listener: (...args: any[]) => void): this; +- prependListener(event: string, listener: (...args: any[]) => void): this; +- prependOnceListener(event: string, listener: (...args: any[]) => void): this; +- emit(name: string, ...args: any[]): boolean; +- } +- // #endregion Runner untyped events +- +- /** +- * Initialize a new `Hook` with the given `title` and callback `fn` +- * +- * @see https://mochajs.org/api/Hook.html +- */ +- class Hook extends Runnable { +- private _error; +- +- type: "hook"; +- originalTitle?: string; // added by Runner +- +- /** +- * Get the test `err`. +- * +- * @see https://mochajs.org/api/Hook.html#error +- */ +- error(): any; +- +- /** +- * Set the test `err`. +- * +- * @see https://mochajs.org/api/Hook.html#error +- */ +- error(err: any): void; +- } +- +- /** +- * An alternative way to define root hooks that works with parallel runs. +- * +- * Root hooks work with any interface, but the property names do not change. +- * In other words, if you are using the tdd interface, suiteSetup maps to beforeAll, and setup maps to beforeEach. +- * +- * As with other hooks, `this` refers to to the current context object. +- * +- * @see https://mochajs.org/#root-hook-plugins +- */ +- interface RootHookObject { +- /** +- * In serial mode, run after all tests end, once only. +- * In parallel mode, run after all tests end, for each file. +- */ +- afterAll?: Func | AsyncFunc | Func[] | AsyncFunc[]; +- /** +- * In serial mode (Mocha's default), before all tests begin, once only. +- * In parallel mode, run before all tests begin, for each file. +- */ +- beforeAll?: Func | AsyncFunc | Func[] | AsyncFunc[]; +- /** +- * In both modes, run after every test. +- */ +- afterEach?: Func | AsyncFunc | Func[] | AsyncFunc[]; +- /** +- * In both modes, run before each test. +- */ +- beforeEach?: Func | AsyncFunc | Func[] | AsyncFunc[]; +- } +- +- /** +- * Initialize a new `Test` with the given `title` and callback `fn`. +- * +- * @see https://mochajs.org/api/Test.html +- */ +- class Test extends Runnable { +- type: "test"; +- speed?: "slow" | "medium" | "fast"; // added by reporters +- err?: Error; // added by reporters +- clone(): Test; +- } +- +- /** +- * Test statistics +- */ +- interface Stats { +- suites: number; +- tests: number; +- passes: number; +- pending: number; +- failures: number; +- start?: Date; +- end?: Date; +- duration?: number; +- } +- +- type TestInterface = (suite: Suite) => void; +- +- interface ReporterConstructor { +- new (runner: Runner, options: MochaOptions): reporters.Base; +- } +- +- type Done = (err?: any) => void; +- +- /** +- * Callback function used for tests and hooks. +- */ +- type Func = (this: Context, done: Done) => void; +- +- /** +- * Async callback function used for tests and hooks. +- */ +- type AsyncFunc = (this: Context) => PromiseLike; +- +- /** +- * Options to pass to Mocha. +- */ +- interface MochaOptions { +- /** Test interfaces ("bdd", "tdd", "exports", etc.). */ +- ui?: Interface; +- +- /** +- * Reporter constructor, built-in reporter name, or reporter module path. Defaults to +- * `"spec"`. +- */ +- reporter?: string | ReporterConstructor; +- +- /** Options to pass to the reporter. */ +- reporterOptions?: any; +- +- /** Array of accepted globals. */ +- globals?: string[]; +- +- /** timeout in milliseconds or time string like '1s'. */ +- timeout?: number | string; +- +- /** number of times to retry failed tests. */ +- retries?: number; +- +- /** bail on the first test failure. */ +- bail?: boolean; +- +- /** milliseconds to wait before considering a test slow. */ +- slow?: number; +- +- /** check for global variable leaks. */ +- checkLeaks?: boolean; +- +- /** display the full stack trace on failure. */ +- fullStackTrace?: boolean; +- +- /** string or regexp to filter tests with. */ +- grep?: string | RegExp; +- +- /** Enable growl support. */ +- growl?: boolean; +- +- /** Color TTY output from reporter */ +- color?: boolean; +- +- /** Use inline diffs rather than +/-. */ +- inlineDiffs?: boolean; +- +- /** Do not show diffs at all. */ +- hideDiff?: boolean; +- +- /** Run job in parallel */ +- parallel?: boolean; +- +- /** Max number of worker processes for parallel runs */ +- jobs?: number; +- +- /** Assigns hooks to the root suite */ +- rootHooks?: RootHookObject; +- +- asyncOnly?: boolean; +- delay?: boolean; +- forbidOnly?: boolean; +- forbidPending?: boolean; +- noHighlighting?: boolean; +- allowUncaught?: boolean; +- fullTrace?: boolean; +- } +- +- interface MochaInstanceOptions extends MochaOptions { +- files?: string[]; +- } +- +- /** +- * Variables added to the global scope by Mocha when run in the CLI. +- */ +- interface MochaGlobals { +- /** +- * Execute before running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#before +- */ +- before: HookFunction; +- +- /** +- * Execute after running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#after +- */ +- after: HookFunction; +- +- /** +- * Execute before each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#beforeEach +- */ +- beforeEach: HookFunction; +- +- /** +- * Execute after each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#afterEach +- */ +- afterEach: HookFunction; +- +- /** +- * Describe a "suite" containing nested suites and tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- describe: SuiteFunction; +- +- /** +- * Describe a "suite" containing nested suites and tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- context: SuiteFunction; +- +- /** +- * Pending suite. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- xdescribe: PendingSuiteFunction; +- +- /** +- * Pending suite. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- xcontext: PendingSuiteFunction; +- +- /** +- * Describes a test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- it: TestFunction; +- +- /** +- * Describes a test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- specify: TestFunction; +- +- /** +- * Describes a pending test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- xit: PendingTestFunction; +- +- /** +- * Describes a pending test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- xspecify: PendingTestFunction; +- +- /** +- * Execute before running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#before +- */ +- suiteSetup: HookFunction; +- +- /** +- * Execute after running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#after +- */ +- suiteTeardown: HookFunction; +- +- /** +- * Execute before each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#beforeEach +- */ +- setup: HookFunction; +- +- /** +- * Execute after each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#afterEach +- */ +- teardown: HookFunction; +- +- /** +- * Describe a "suite" containing nested suites and tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- suite: SuiteFunction; +- +- /** +- * Describes a test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +- test: TestFunction; +- +- run: typeof run; +- } +- +- /** +- * Third-party declarations that want to add new entries to the `Reporter` union can +- * contribute names here. +- */ +- interface ReporterContributions { +- Base: never; +- base: never; +- Dot: never; +- dot: never; +- TAP: never; +- tap: never; +- JSON: never; +- json: never; +- HTML: never; +- html: never; +- List: never; +- list: never; +- Min: never; +- min: never; +- Spec: never; +- spec: never; +- Nyan: never; +- nyan: never; +- XUnit: never; +- xunit: never; +- Markdown: never; +- markdown: never; +- Progress: never; +- progress: never; +- Landing: never; +- landing: never; +- JSONStream: never; +- "json-stream": never; +- } +- +- type Reporter = keyof ReporterContributions; +- +- /** +- * Third-party declarations that want to add new entries to the `Interface` union can +- * contribute names here. +- */ +- interface InterfaceContributions { +- bdd: never; +- tdd: never; +- qunit: never; +- exports: never; +- } +- +- type Interface = keyof InterfaceContributions; +-} +- +-// #region Test interface augmentations +- +-/** +- * Triggers root suite execution. +- * +- * - _Only available if flag --delay is passed into Mocha._ +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#runWithSuite +- */ +-declare function run(): void; +- +-/** +- * Execute before running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#before +- */ +-declare var before: Mocha.HookFunction; +- +-/** +- * Execute before running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#before +- */ +-declare var suiteSetup: Mocha.HookFunction; +- +-/** +- * Execute after running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#after +- */ +-declare var after: Mocha.HookFunction; +- +-/** +- * Execute after running tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#after +- */ +-declare var suiteTeardown: Mocha.HookFunction; +- +-/** +- * Execute before each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#beforeEach +- */ +-declare var beforeEach: Mocha.HookFunction; +- +-/** +- * Execute before each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#beforeEach +- */ +-declare var setup: Mocha.HookFunction; +- +-/** +- * Execute after each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#afterEach +- */ +-declare var afterEach: Mocha.HookFunction; +- +-/** +- * Execute after each test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- * +- * @see https://mochajs.org/api/global.html#afterEach +- */ +-declare var teardown: Mocha.HookFunction; +- +-/** +- * Describe a "suite" containing nested suites and tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var describe: Mocha.SuiteFunction; +- +-/** +- * Describe a "suite" containing nested suites and tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var context: Mocha.SuiteFunction; +- +-/** +- * Describe a "suite" containing nested suites and tests. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var suite: Mocha.SuiteFunction; +- +-/** +- * Pending suite. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var xdescribe: Mocha.PendingSuiteFunction; +- +-/** +- * Pending suite. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var xcontext: Mocha.PendingSuiteFunction; +- +-/** +- * Describes a test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var it: Mocha.TestFunction; +- +-/** +- * Describes a test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var specify: Mocha.TestFunction; +- +-/** +- * Describes a test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var test: Mocha.TestFunction; +- +-/** +- * Describes a pending test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var xit: Mocha.PendingTestFunction; +- +-/** +- * Describes a pending test case. +- * +- * - _Only available when invoked via the mocha CLI._ +- */ +-declare var xspecify: Mocha.PendingTestFunction; +- +-// #endregion Test interface augmentations +- +-// #region Reporter augmentations +- +-// Forward declaration for `HTMLLIElement` from lib.dom.d.ts. +-// Required by Mocha.reporters.HTML. +-// NOTE: Mocha *must not* have a direct dependency on DOM types. +-// tslint:disable-next-line no-empty-interface +-interface HTMLLIElement { } +- +-// Augments the DOM `Window` object when lib.dom.d.ts is loaded. +-// tslint:disable-next-line no-empty-interface +-interface Window extends Mocha.MochaGlobals { } +- +-declare namespace NodeJS { +- // Forward declaration for `NodeJS.EventEmitter` from node.d.ts. +- // Required by Mocha.Runnable, Mocha.Runner, and Mocha.Suite. +- // NOTE: Mocha *must not* have a direct dependency on @types/node. +- // tslint:disable-next-line no-empty-interface +- interface EventEmitter { } +- +- // Augments NodeJS's `global` object when node.d.ts is loaded +- // tslint:disable-next-line no-empty-interface +- interface Global extends Mocha.MochaGlobals { } +-} +- +-// #endregion Reporter augmentations +- +-// #region Browser augmentations +- +-/** +- * Mocha global. +- * +- * - _Only supported in the browser._ +- */ +-declare const mocha: BrowserMocha; +- +-interface BrowserMocha extends Mocha { +- /** +- * Function to allow assertion libraries to throw errors directly into mocha. +- * This is useful when running tests in a browser because window.onerror will +- * only receive the 'message' attribute of the Error. +- * +- * - _Only supported in the browser._ +- */ +- throwError(err: any): never; +- +- /** +- * Setup mocha with the given settings options. +- * +- * - _Only supported in the browser._ +- */ +- setup(opts?: Mocha.Interface | Mocha.MochaOptions): this; +-} +- +-// #endregion Browser augmentations +- +-declare module "mocha" { +- export = Mocha; +-} +- +-declare module "mocha/lib/ms" { +- export = milliseconds; +- /** +- * Parse the given `str` and return milliseconds. +- * +- * @see {@link https://mochajs.org/api/module-milliseconds.html} +- * @see {@link https://mochajs.org/api/module-milliseconds.html#~parse} +- */ +- function milliseconds(val: string): number; +- +- /** +- * Format for `ms`. +- * +- * @see {@link https://mochajs.org/api/module-milliseconds.html} +- * @see {@link https://mochajs.org/api/module-milliseconds.html#~format} +- */ +- function milliseconds(val: number): string; +-} +- +-declare module "mocha/lib/interfaces/common" { +- export = common; +- +- function common(suites: Mocha.Suite[], context: Mocha.MochaGlobals, mocha: Mocha): common.CommonFunctions; +- +- namespace common { +- interface CommonFunctions { +- /** +- * This is only present if flag --delay is passed into Mocha. It triggers +- * root suite execution. +- */ +- runWithSuite(suite: Mocha.Suite): () => void; +- +- /** +- * Execute before running tests. +- */ +- before(fn?: Mocha.Func | Mocha.AsyncFunc): void; +- +- /** +- * Execute before running tests. +- */ +- before(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; +- +- /** +- * Execute after running tests. +- */ +- after(fn?: Mocha.Func | Mocha.AsyncFunc): void; +- +- /** +- * Execute after running tests. +- */ +- after(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; +- +- /** +- * Execute before each test case. +- */ +- beforeEach(fn?: Mocha.Func | Mocha.AsyncFunc): void; +- +- /** +- * Execute before each test case. +- */ +- beforeEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; +- +- /** +- * Execute after each test case. +- */ +- afterEach(fn?: Mocha.Func | Mocha.AsyncFunc): void; +- +- /** +- * Execute after each test case. +- */ +- afterEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; +- +- suite: SuiteFunctions; +- test: TestFunctions; +- } +- +- interface CreateOptions { +- /** Title of suite */ +- title: string; +- +- /** Suite function */ +- fn?: (this: Mocha.Suite) => void; +- +- /** Is suite pending? */ +- pending?: boolean; +- +- /** Filepath where this Suite resides */ +- file?: string; +- +- /** Is suite exclusive? */ +- isOnly?: boolean; +- } +- +- interface SuiteFunctions { +- /** +- * Create an exclusive Suite; convenience function +- */ +- only(opts: CreateOptions): Mocha.Suite; +- +- /** +- * Create a Suite, but skip it; convenience function +- */ +- skip(opts: CreateOptions): Mocha.Suite; +- +- /** +- * Creates a suite. +- */ +- create(opts: CreateOptions): Mocha.Suite; +- } +- +- interface TestFunctions { +- /** +- * Exclusive test-case. +- */ +- only(mocha: Mocha, test: Mocha.Test): Mocha.Test; +- +- /** +- * Pending test case. +- */ +- skip(title: string): void; +- +- /** +- * Number of retry attempts +- */ +- retries(n: number): void; +- } +- } +-} ++//z // Type definitions for mocha 8.0 ++//z // Project: https://mochajs.org ++//z // Definitions by: Kazi Manzur Rashid ++//z // otiai10 ++//z // Vadim Macagon ++//z // Andrew Bradley ++//z // Dmitrii Sorin ++//z // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped ++//z // TypeScript Version: 2.1 ++ ++//z /** ++//z * Mocha API ++//z * ++//z * @see https://mochajs.org/api/mocha ++//z */ ++//z declare class Mocha { ++//z private _growl; ++//z private _reporter; ++//z private _ui; ++ ++//z constructor(options?: Mocha.MochaOptions); ++ ++//z suite: Mocha.Suite; ++//z files: string[]; ++//z options: Mocha.MochaInstanceOptions; ++ ++//z /** ++//z * Enable or disable bailing on the first failure. ++//z * ++//z * @see https://mochajs.org/api/mocha#bail ++//z */ ++//z bail(bail?: boolean): this; ++ ++//z /** ++//z * Add test `file`. ++//z * ++//z * @see https://mochajs.org/api/mocha#addFile ++//z */ ++//z addFile(file: string): this; ++ ++//z /** ++//z * Set reporter to one of the built-in reporters. ++//z * ++//z * @see https://mochajs.org/api/mocha#reporter ++//z */ ++//z reporter(reporter: Mocha.Reporter, reporterOptions?: any): this; ++ ++//z /** ++//z * Set reporter to the provided constructor, one of the built-in reporters, or loads a reporter ++//z * from a module path. Defaults to `"spec"`. ++//z * ++//z * @see https://mochajs.org/api/mocha#reporter ++//z */ ++//z reporter(reporter?: string | Mocha.ReporterConstructor, reporterOptions?: any): this; ++ ++//z /** ++//z * Set test UI to one of the built-in test interfaces. ++//z * ++//z * @see https://mochajs.org/api/mocha#ui ++//z */ ++//z ui(name: Mocha.Interface): this; ++ ++//z /** ++//z * Set test UI to one of the built-in test interfaces or loads a test interface from a module ++//z * path. Defaults to `"bdd"`. ++//z * ++//z * @see https://mochajs.org/api/mocha#ui ++//z */ ++//z ui(name?: string): this; ++ ++//z /** ++//z * Escape string and add it to grep as a RegExp. ++//z * ++//z * @see https://mochajs.org/api/mocha#fgrep ++//z */ ++//z fgrep(str: string): this; ++ ++//z /** ++//z * Add regexp to grep, if `re` is a string it is escaped. ++//z * ++//z * @see https://mochajs.org/api/mocha#grep ++//z */ ++//z grep(re: string | RegExp): this; ++ ++//z /** ++//z * Invert `.grep()` matches. ++//z * ++//z * @see https://mochajs.org/api/mocha#invert ++//z */ ++//z invert(): this; ++ ++//z /** ++//z * Enable global leak checking. ++//z * ++//z * @see https://mochajs.org/api/mocha#checkLeaks ++//z */ ++//z checkLeaks(): this; ++ ++//z /** ++//z * Display long stack-trace on failing ++//z * ++//z * @see https://mochajs.org/api/mocha#fullTrace ++//z */ ++//z fullTrace(): this; ++ ++//z /** ++//z * Enable growl support. ++//z * ++//z * @see https://mochajs.org/api/mocha#growl ++//z */ ++//z growl(): this; ++ ++//z /** ++//z * Ignore `globals` array or string. ++//z * ++//z * @see https://mochajs.org/api/mocha#globals ++//z */ ++//z globals(globals: string | ReadonlyArray): this; ++ ++//z /** ++//z * Set the timeout in milliseconds. ++//z * ++//z * @see https://mochajs.org/api/mocha#timeout ++//z */ ++//z timeout(timeout: string | number): this; ++ ++//z /** ++//z * Set the number of times to retry failed tests. ++//z * ++//z * @see https://mochajs.org/api/mocha#retries ++//z */ ++//z retries(n: number): this; ++ ++//z /** ++//z * Set slowness threshold in milliseconds. ++//z * ++//z * @see https://mochajs.org/api/mocha#slow ++//z */ ++//z slow(slow: string | number): this; ++ ++//z /** ++//z * Makes all tests async (accepting a callback) ++//z * ++//z * @see https://mochajs.org/api/mocha#asyncOnly. ++//z */ ++//z asyncOnly(): this; ++ ++//z /** ++//z * Disable syntax highlighting (in browser). ++//z * ++//z * @see https://mochajs.org/api/mocha#noHighlighting ++//z */ ++//z noHighlighting(): this; ++ ++//z /** ++//z * Enable uncaught errors to propagate (in browser). ++//z * ++//z * @see https://mochajs.org/api/mocha#allowUncaught ++//z */ ++//z allowUncaught(): boolean; ++ ++//z /** ++//z * Delay root suite execution. ++//z * ++//z * @see https://mochajs.org/api/mocha#delay ++//z */ ++//z delay(): boolean; ++ ++//z /** ++//z * Tests marked only fail the suite ++//z * ++//z * @see https://mochajs.org/api/mocha#forbidOnly ++//z */ ++//z forbidOnly(): boolean; ++ ++//z /** ++//z * Pending tests and tests marked skip fail the suite ++//z * ++//z * @see https://mochajs.org/api/mocha#forbidPending ++//z */ ++//z forbidPending(): boolean; ++ ++//z /** ++//z * Run tests and invoke `fn()` when complete. ++//z * ++//z * Note that `run` relies on Node's `require` to execute ++//z * the test interface functions and will be subject to the ++//z * cache - if the files are already in the `require` cache, ++//z * they will effectively be skipped. Therefore, to run tests ++//z * multiple times or to run tests in files that are already ++//z * in the `require` cache, make sure to clear them from the ++//z * cache first in whichever manner best suits your needs. ++//z * ++//z * @see https://mochajs.org/api/mocha#run ++//z */ ++//z run(fn?: (failures: number) => void): Mocha.Runner; ++ ++//z /** ++//z * Loads ESM (and CJS) test files asynchronously. ++//z * ++//z * @see https://mochajs.org/api/mocha#loadFilesAsync ++//z */ ++//z loadFilesAsync(): Promise; ++ ++//z /** ++//z * Load registered files. ++//z * ++//z * @see https://mochajs.org/api/mocha#loadFiles ++//z */ ++//z protected loadFiles(fn?: () => void): void; ++ ++//z /** ++//z * Unloads `files` from Node's `require` cache. ++//z * ++//z * This allows required files to be "freshly" reloaded, providing the ability ++//z * to reuse a Mocha instance programmatically. ++//z * Note: does not clear ESM module files from the cache ++//z */ ++//z unloadFiles(): this; ++ ++//z /** ++//z * Toggles parallel mode. ++//z * ++//z * Must be run before calling `run`. Changes the `Runner` class to ++//z * use; also enables lazy file loading if not already done so. ++//z * ++//z * @see https://mochajs.org/api/mocha#parallelMode ++//z */ ++//z parallelMode(enabled?: boolean): this; ++ ++//z /** ++//z * Assigns hooks to the root suite. ++//z * ++//z * @see https://mochajs.org/api/mocha#rootHooks ++//z */ ++//z rootHooks(hooks: Mocha.RootHookObject): this; ++//z } ++ ++//z declare namespace Mocha { ++//z namespace utils { ++//z /** ++//z * Compute a slug from the given `str`. ++//z * ++//z * @see https://mochajs.org/api/module-utils.html#.slug ++//z */ ++//z function slug(str: string): string; ++ ++//z /** ++//z * Strip the function definition from `str`, and re-indent for pre whitespace. ++//z * ++//z * @see https://mochajs.org/api/module-utils.html#.clean ++//z */ ++//z function clean(str: string): string; ++ ++//z /** ++//z * Highlight the given string of `js`. ++//z */ ++//z function highlight(js: string): string; ++ ++//z /** ++//z * Takes some variable and asks `Object.prototype.toString()` what it thinks it is. ++//z */ ++//z function type(value: any): string; ++ ++//z /** ++//z * Stringify `value`. Different behavior depending on type of value: ++//z * ++//z * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively. ++//z * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes. ++//z * - If `value` is an *empty* object, function, or array, returns `'{}'`, `'[Function]'`, or `'[]'` respectively. ++//z * - If `value` has properties, call canonicalize} on it, then return result of `JSON.stringify()` ++//z * ++//z * @see https://mochajs.org/api/module-utils.html#.stringify ++//z */ ++//z function stringify(value: any): string; ++ ++//z /** ++//z * Return a new Thing that has the keys in sorted order. Recursive. ++//z * ++//z * If the Thing... ++//z * - has already been seen, return string `'[Circular]'` ++//z * - is `undefined`, return string `'[undefined]'` ++//z * - is `null`, return value `null` ++//z * - is some other primitive, return the value ++//z * - is not a primitive or an `Array`, `Object`, or `Function`, return the value of the Thing's `toString()` method ++//z * - is a non-empty `Array`, `Object`, or `Function`, return the result of calling this function again. ++//z * - is an empty `Array`, `Object`, or `Function`, returns `'[]'`, `'{}'`, or `'[Function]'` respectively. ++//z * ++//z * @see https://mochajs.org/api/module-utils.html#.canonicalize ++//z */ ++//z function canonicalize(value: any, stack: any[], typeHint: string): any; ++ ++//z /** ++//z * Lookup file names at the given `path`. ++//z * ++//z * @see https://mochajs.org/api/Mocha.utils.html#.exports.lookupFiles ++//z */ ++//z function lookupFiles(filepath: string, extensions?: string[], recursive?: boolean): string[]; ++ ++//z /** ++//z * Generate an undefined error with a message warning the user. ++//z * ++//z * @see https://mochajs.org/api/module-utils.html#.undefinedError ++//z */ ++//z function undefinedError(): Error; ++ ++//z /** ++//z * Generate an undefined error if `err` is not defined. ++//z * ++//z * @see https://mochajs.org/api/module-utils.html#.getError ++//z */ ++//z function getError(err: Error | undefined): Error; ++ ++//z /** ++//z * When invoking this function you get a filter function that get the Error.stack as an ++//z * input, and return a prettify output. (i.e: strip Mocha and internal node functions from ++//z * stack trace). ++//z * ++//z * @see https://mochajs.org/api/module-utils.html#.stackTraceFilter ++//z */ ++//z function stackTraceFilter(): (stack: string) => string; ++//z } ++ ++//z namespace interfaces { ++//z function bdd(suite: Suite): void; ++//z function tdd(suite: Suite): void; ++//z function qunit(suite: Suite): void; ++//z function exports(suite: Suite): void; ++//z } ++ ++//z // #region Test interface augmentations ++ ++//z interface HookFunction { ++//z /** ++//z * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the ++//z * function is used as the name of the hook. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (fn: Func): void; ++ ++//z /** ++//z * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the ++//z * function is used as the name of the hook. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (fn: AsyncFunc): void; ++ ++//z /** ++//z * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (name: string, fn?: Func): void; ++ ++//z /** ++//z * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (name: string, fn?: AsyncFunc): void; ++//z } ++ ++//z interface SuiteFunction { ++//z /** ++//z * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing ++//z * nested suites. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (title: string, fn: (this: Suite) => void): Suite; ++ ++//z /** ++//z * [qunit] Describe a "suite" with the given `title`. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (title: string): Suite; ++ ++//z /** ++//z * [bdd, tdd, qunit] Indicates this suite should be executed exclusively. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z only: ExclusiveSuiteFunction; ++ ++//z /** ++//z * [bdd, tdd] Indicates this suite should not be executed. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z skip: PendingSuiteFunction; ++//z } ++ ++//z interface ExclusiveSuiteFunction { ++//z /** ++//z * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing ++//z * nested suites. Indicates this suite should be executed exclusively. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (title: string, fn: (this: Suite) => void): Suite; ++ ++//z /** ++//z * [qunit] Describe a "suite" with the given `title`. Indicates this suite should be executed ++//z * exclusively. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (title: string): Suite; ++//z } ++ ++//z /** ++//z * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing ++//z * nested suites. Indicates this suite should not be executed. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @returns [bdd] `Suite` ++//z * @returns [tdd] `void` ++//z */ ++//z interface PendingSuiteFunction { ++//z (title: string, fn: (this: Suite) => void): Suite | void; ++//z } ++ ++//z interface TestFunction { ++//z /** ++//z * Describe a specification or test-case with the given callback `fn` acting as a thunk. ++//z * The name of the function is used as the name of the test. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (fn: Func): Test; ++ ++//z /** ++//z * Describe a specification or test-case with the given callback `fn` acting as a thunk. ++//z * The name of the function is used as the name of the test. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (fn: AsyncFunc): Test; ++ ++//z /** ++//z * Describe a specification or test-case with the given `title` and callback `fn` acting ++//z * as a thunk. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (title: string, fn?: Func): Test; ++ ++//z /** ++//z * Describe a specification or test-case with the given `title` and callback `fn` acting ++//z * as a thunk. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (title: string, fn?: AsyncFunc): Test; ++ ++//z /** ++//z * Indicates this test should be executed exclusively. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z only: ExclusiveTestFunction; ++ ++//z /** ++//z * Indicates this test should not be executed. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z skip: PendingTestFunction; ++ ++//z /** ++//z * Number of attempts to retry. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z retries(n: number): void; ++//z } ++ ++//z interface ExclusiveTestFunction { ++//z /** ++//z * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` ++//z * acting as a thunk. The name of the function is used as the name of the test. Indicates ++//z * this test should be executed exclusively. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (fn: Func): Test; ++ ++//z /** ++//z * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` ++//z * acting as a thunk. The name of the function is used as the name of the test. Indicates ++//z * this test should be executed exclusively. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (fn: AsyncFunc): Test; ++ ++//z /** ++//z * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and ++//z * callback `fn` acting as a thunk. Indicates this test should be executed exclusively. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (title: string, fn?: Func): Test; ++ ++//z /** ++//z * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and ++//z * callback `fn` acting as a thunk. Indicates this test should be executed exclusively. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (title: string, fn?: AsyncFunc): Test; ++//z } ++ ++//z interface PendingTestFunction { ++//z /** ++//z * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` ++//z * acting as a thunk. The name of the function is used as the name of the test. Indicates ++//z * this test should not be executed. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (fn: Func): Test; ++ ++//z /** ++//z * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` ++//z * acting as a thunk. The name of the function is used as the name of the test. Indicates ++//z * this test should not be executed. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (fn: AsyncFunc): Test; ++ ++//z /** ++//z * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and ++//z * callback `fn` acting as a thunk. Indicates this test should not be executed. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (title: string, fn?: Func): Test; ++ ++//z /** ++//z * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and ++//z * callback `fn` acting as a thunk. Indicates this test should not be executed. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z (title: string, fn?: AsyncFunc): Test; ++//z } ++ ++//z /** ++//z * Execute after each test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#afterEach ++//z */ ++//z let afterEach: HookFunction; ++ ++//z /** ++//z * Execute after running tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#after ++//z */ ++//z let after: HookFunction; ++ ++//z /** ++//z * Execute before each test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#beforeEach ++//z */ ++//z let beforeEach: HookFunction; ++ ++//z /** ++//z * Execute before running tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#before ++//z */ ++//z let before: HookFunction; ++ ++//z /** ++//z * Describe a "suite" containing nested suites and tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z let describe: SuiteFunction; ++ ++//z /** ++//z * Describes a test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z let it: TestFunction; ++ ++//z /** ++//z * Describes a pending test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z let xit: PendingTestFunction; ++ ++//z /** ++//z * Execute before each test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#beforeEach ++//z */ ++//z let setup: HookFunction; ++ ++//z /** ++//z * Execute before running tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#before ++//z */ ++//z let suiteSetup: HookFunction; ++ ++//z /** ++//z * Execute after running tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#after ++//z */ ++//z let suiteTeardown: HookFunction; ++ ++//z /** ++//z * Describe a "suite" containing nested suites and tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z let suite: SuiteFunction; ++ ++//z /** ++//z * Execute after each test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#afterEach ++//z */ ++//z let teardown: HookFunction; ++ ++//z /** ++//z * Describes a test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z let test: TestFunction; ++ ++//z /** ++//z * Triggers root suite execution. ++//z * ++//z * - _Only available if flag --delay is passed into Mocha._ ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#runWithSuite ++//z */ ++//z function run(): void; ++ ++//z // #endregion Test interface augmentations ++ ++//z namespace reporters { ++//z /** ++//z * Initialize a new `Base` reporter. ++//z * ++//z * All other reporters generally inherit from this reporter, providing stats such as test duration, ++//z * number of tests passed / failed, etc. ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.Base.html ++//z */ ++//z class Base { ++//z constructor(runner: Runner, options?: MochaOptions); ++ ++//z /** ++//z * Test run statistics ++//z */ ++//z stats: Stats; ++ ++//z /** ++//z * Test failures ++//z */ ++//z failures: Test[]; ++ ++//z /** ++//z * The configured runner ++//z */ ++//z runner: Runner; ++ ++//z /** ++//z * Output common epilogue used by many of the bundled reporters. ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.Base.html#.Base#epilogue ++//z */ ++//z epilogue(): void; ++ ++//z done?(failures: number, fn?: (failures: number) => void): void; ++//z } ++ ++//z namespace Base { ++//z /** ++//z * Enables coloring by default ++//z * ++//z * @see https://mochajs.org/api/module-base#.useColors ++//z */ ++//z let useColors: boolean; ++ ++//z /** ++//z * Inline diffs instead of +/- ++//z * ++//z * @see https://mochajs.org/api/module-base#.inlineDiffs ++//z */ ++//z let inlineDiffs: boolean; ++ ++//z /** ++//z * Default color map ++//z * ++//z * @see https://mochajs.org/api/module-base#.colors ++//z */ ++//z const colors: ColorMap; ++ ++//z /** ++//z * Default color map ++//z * ++//z * @see https://mochajs.org/api/module-base#.colors ++//z */ ++//z interface ColorMap { ++//z // added by Base ++//z pass: number; ++//z fail: number; ++//z "bright pass": number; ++//z "bright fail": number; ++//z "bright yellow": number; ++//z pending: number; ++//z suite: number; ++//z "error title": number; ++//z "error message": number; ++//z "error stack": number; ++//z checkmark: number; ++//z fast: number; ++//z medium: number; ++//z slow: number; ++//z green: number; ++//z light: number; ++//z "diff gutter": number; ++//z "diff added": number; ++//z "diff removed": number; ++ ++//z // added by Progress ++//z progress: number; ++ ++//z // added by Landing ++//z plane: number; ++//z "plane crash": number; ++//z runway: number; ++ ++//z [key: string]: number; ++//z } ++ ++//z /** ++//z * Default symbol map ++//z * ++//z * @see https://mochajs.org/api/module-base#.symbols ++//z */ ++//z const symbols: SymbolMap; ++ ++//z /** ++//z * Default symbol map ++//z * ++//z * @see https://mochajs.org/api/module-base#.symbols ++//z */ ++//z interface SymbolMap { ++//z ok: string; ++//z err: string; ++//z dot: string; ++//z comma: string; ++//z bang: string; ++//z [key: string]: string; ++//z } ++ ++//z /** ++//z * Color `str` with the given `type` (from `colors`) ++//z * ++//z * @see https://mochajs.org/api/module-base#.color ++//z */ ++//z function color(type: string, str: string): string; ++ ++//z /** ++//z * Expose terminal window size ++//z * ++//z * @see https://mochajs.org/api/module-base#.window ++//z */ ++//z const window: { ++//z width: number; ++//z }; ++ ++//z /** ++//z * ANSI TTY control sequences common among reporters. ++//z * ++//z * @see https://mochajs.org/api/module-base#.cursor ++//z */ ++//z namespace cursor { ++//z /** ++//z * Hides the cursor ++//z */ ++//z function hide(): void; ++ ++//z /** ++//z * Shows the cursor ++//z */ ++//z function show(): void; ++ ++//z /** ++//z * Deletes the current line ++//z */ ++//z function deleteLine(): void; ++ ++//z /** ++//z * Moves to the beginning of the line ++//z */ ++//z function beginningOfLine(): void; ++ ++//z /** ++//z * Clears the line and moves to the beginning of the line. ++//z */ ++//z function CR(): void; ++//z } ++ ++//z /** ++//z * Returns a diff between two strings with colored ANSI output. ++//z * ++//z * @see https://mochajs.org/api/module-base#.generateDiff ++//z */ ++//z function generateDiff(actual: string, expected: string): string; ++ ++//z /** ++//z * Output the given `failures` as a list. ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.Base.html#.exports.list1 ++//z */ ++//z function list(failures: Test[]): void; ++//z } ++ ++//z /** ++//z * Initialize a new `Dot` matrix test reporter. ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.Dot.html ++//z */ ++//z class Dot extends Base { ++//z } ++ ++//z /** ++//z * Initialize a new `Doc` reporter. ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.Doc.html ++//z */ ++//z class Doc extends Base { ++//z } ++ ++//z /** ++//z * Initialize a new `TAP` test reporter. ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.TAP.html ++//z */ ++//z class TAP extends Base { ++//z } ++ ++//z /** ++//z * Initialize a new `JSON` reporter ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.JSON.html ++//z */ ++//z class JSON extends Base { ++//z } ++ ++//z /** ++//z * Initialize a new `HTML` reporter. ++//z * ++//z * - _This reporter cannot be used on the console._ ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.HTML.html ++//z */ ++//z class HTML extends Base { ++//z /** ++//z * Provide suite URL. ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.HTML.html#suiteURL ++//z */ ++//z suiteURL(suite: Suite): string; ++ ++//z /** ++//z * Provide test URL. ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.HTML.html#testURL ++//z */ ++//z testURL(test: Test): string; ++ ++//z /** ++//z * Adds code toggle functionality for the provided test's list element. ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.HTML.html#addCodeToggle ++//z */ ++//z addCodeToggle(el: HTMLLIElement, contents: string): void; ++//z } ++ ++//z /** ++//z * Initialize a new `List` test reporter. ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.List.html ++//z */ ++//z class List extends Base { ++//z } ++ ++//z /** ++//z * Initialize a new `Min` minimal test reporter (best used with --watch). ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.Min.html ++//z */ ++//z class Min extends Base { ++//z } ++ ++//z /** ++//z * Initialize a new `Spec` test reporter. ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.Spec.html ++//z */ ++//z class Spec extends Base { ++//z } ++ ++//z /** ++//z * Initialize a new `NyanCat` test reporter. ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.Nyan.html ++//z */ ++//z class Nyan extends Base { ++//z private colorIndex; ++//z private numberOfLines; ++//z private rainbowColors; ++//z private scoreboardWidth; ++//z private tick; ++//z private trajectories; ++//z private trajectoryWidthMax; ++//z private draw; ++//z private drawScoreboard; ++//z private appendRainbow; ++//z private drawRainbow; ++//z private drawNyanCat; ++//z private face; ++//z private cursorUp; ++//z private cursorDown; ++//z private generateColors; ++//z private rainbowify; ++//z } ++ ++//z /** ++//z * Initialize a new `XUnit` test reporter. ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.XUnit.html ++//z */ ++//z class XUnit extends Base { ++//z constructor(runner: Runner, options?: XUnit.MochaOptions); ++ ++//z /** ++//z * Override done to close the stream (if it's a file). ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#done ++//z */ ++//z done(failures: number, fn: (failures: number) => void): void; ++ ++//z /** ++//z * Write out the given line. ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#write ++//z */ ++//z write(line: string): void; ++ ++//z /** ++//z * Output tag for the given `test.` ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#test ++//z */ ++//z test(test: Test): void; ++//z } ++ ++//z namespace XUnit { ++//z interface MochaOptions extends Mocha.MochaOptions { ++//z reporterOptions?: ReporterOptions; ++//z } ++ ++//z interface ReporterOptions { ++//z output?: string; ++//z suiteName?: string; ++//z } ++//z } ++ ++//z /** ++//z * Initialize a new `Markdown` test reporter. ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.Markdown.html ++//z */ ++//z class Markdown extends Base { ++//z } ++ ++//z /** ++//z * Initialize a new `Progress` bar test reporter. ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.Progress.html ++//z */ ++//z class Progress extends Base { ++//z constructor(runner: Runner, options?: Progress.MochaOptions); ++//z } ++ ++//z namespace Progress { ++//z interface MochaOptions extends Mocha.MochaOptions { ++//z reporterOptions?: ReporterOptions; ++//z } ++ ++//z interface ReporterOptions { ++//z open?: string; ++//z complete?: string; ++//z incomplete?: string; ++//z close?: string; ++//z verbose?: boolean; ++//z } ++//z } ++ ++//z /** ++//z * Initialize a new `Landing` reporter. ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.Landing.html ++//z */ ++//z class Landing extends Base { ++//z } ++ ++//z /** ++//z * Initialize a new `JSONStream` test reporter. ++//z * ++//z * @see https://mochajs.org/api/Mocha.reporters.JSONStream.html ++//z */ ++//z class JSONStream extends Base { ++//z } ++ ++//z // value-only aliases ++//z const base: typeof Base; ++//z const dot: typeof Dot; ++//z const doc: typeof Doc; ++//z const tap: typeof TAP; ++//z const json: typeof JSON; ++//z const html: typeof HTML; ++//z const list: typeof List; ++//z const spec: typeof Spec; ++//z const nyan: typeof Nyan; ++//z const xunit: typeof XUnit; ++//z const markdown: typeof Markdown; ++//z const progress: typeof Progress; ++//z const landing: typeof Landing; ++//z // NOTE: not possible to type this correctly: ++//z // const "json-stream": typeof JSONStream; ++//z } ++ ++//z /** ++//z * Initialize a new `Runnable` with the given `title` and callback `fn`. ++//z * ++//z * @see https://mochajs.org/api/Runnable.html ++//z */ ++//z class Runnable { ++//z private _slow; ++//z private _retries; ++//z private _currentRetry; ++//z private _timeout; ++//z private _timeoutError; ++ ++//z constructor(title: string, fn?: Func | AsyncFunc); ++ ++//z title: string; ++//z fn: Func | AsyncFunc | undefined; ++//z body: string; ++//z async: boolean; ++//z sync: boolean; ++//z timedOut: boolean; ++//z pending: boolean; ++//z duration?: number; ++//z parent?: Suite; ++//z state?: "failed" | "passed"; ++//z timer?: any; ++//z ctx?: Context; ++//z callback?: Done; ++//z allowUncaught?: boolean; ++//z file?: string; ++ ++//z /** ++//z * Get test timeout. ++//z * ++//z * @see https://mochajs.org/api/Runnable.html#timeout ++//z */ ++//z timeout(): number; ++ ++//z /** ++//z * Set test timeout. ++//z * ++//z * @see https://mochajs.org/api/Runnable.html#timeout ++//z */ ++//z timeout(ms: string | number): this; ++ ++//z /** ++//z * Get test slowness threshold. ++//z * ++//z * @see https://mochajs.org/api/Runnable.html#slow ++//z */ ++//z slow(): number; ++ ++//z /** ++//z * Set test slowness threshold. ++//z * ++//z * @see https://mochajs.org/api/Runnable.html#slow ++//z */ ++//z slow(ms: string | number): this; ++ ++//z /** ++//z * Halt and mark as pending. ++//z */ ++//z skip(): never; ++ ++//z /** ++//z * Check if this runnable or its parent suite is marked as pending. ++//z * ++//z * @see https://mochajs.org/api/Runnable.html#isPending ++//z */ ++//z isPending(): boolean; ++ ++//z /** ++//z * Return `true` if this Runnable has failed. ++//z */ ++//z isFailed(): boolean; ++ ++//z /** ++//z * Return `true` if this Runnable has passed. ++//z */ ++//z isPassed(): boolean; ++ ++//z /** ++//z * Set or get number of retries. ++//z * ++//z * @see https://mochajs.org/api/Runnable.html#retries ++//z */ ++//z retries(): number; ++ ++//z /** ++//z * Set or get number of retries. ++//z * ++//z * @see https://mochajs.org/api/Runnable.html#retries ++//z */ ++//z retries(n: number): void; ++ ++//z /** ++//z * Set or get current retry ++//z * ++//z * @see https://mochajs.org/api/Runnable.html#currentRetry ++//z */ ++//z protected currentRetry(): number; ++ ++//z /** ++//z * Set or get current retry ++//z * ++//z * @see https://mochajs.org/api/Runnable.html#currentRetry ++//z */ ++//z protected currentRetry(n: number): void; ++ ++//z /** ++//z * Return the full title generated by recursively concatenating the parent's full title. ++//z */ ++//z fullTitle(): string; ++ ++//z /** ++//z * Return the title path generated by concatenating the parent's title path with the title. ++//z */ ++//z titlePath(): string[]; ++ ++//z /** ++//z * Clear the timeout. ++//z * ++//z * @see https://mochajs.org/api/Runnable.html#clearTimeout ++//z */ ++//z clearTimeout(): void; ++ ++//z /** ++//z * Inspect the runnable void of private properties. ++//z * ++//z * @see https://mochajs.org/api/Runnable.html#inspect ++//z */ ++//z inspect(): string; ++ ++//z /** ++//z * Reset the timeout. ++//z * ++//z * @see https://mochajs.org/api/Runnable.html#resetTimeout ++//z */ ++//z resetTimeout(): void; ++ ++//z /** ++//z * Get a list of whitelisted globals for this test run. ++//z * ++//z * @see https://mochajs.org/api/Runnable.html#globals ++//z */ ++//z globals(): string[]; ++ ++//z /** ++//z * Set a list of whitelisted globals for this test run. ++//z * ++//z * @see https://mochajs.org/api/Runnable.html#globals ++//z */ ++//z globals(globals: ReadonlyArray): void; ++ ++//z /** ++//z * Run the test and invoke `fn(err)`. ++//z * ++//z * @see https://mochajs.org/api/Runnable.html#run ++//z */ ++//z run(fn: Done): void; ++//z } ++ ++//z // #region Runnable "error" event ++//z interface Runnable extends NodeJS.EventEmitter { ++//z on(event: "error", listener: (error: any) => void): this; ++//z once(event: "error", listener: (error: any) => void): this; ++//z addListener(event: "error", listener: (error: any) => void): this; ++//z removeListener(event: "error", listener: (error: any) => void): this; ++//z prependListener(event: "error", listener: (error: any) => void): this; ++//z prependOnceListener(event: "error", listener: (error: any) => void): this; ++//z emit(name: "error", error: any): boolean; ++//z } ++//z // #endregion Runnable "error" event ++//z // #region Runnable untyped events ++//z interface Runnable extends NodeJS.EventEmitter { ++//z on(event: string, listener: (...args: any[]) => void): this; ++//z once(event: string, listener: (...args: any[]) => void): this; ++//z addListener(event: string, listener: (...args: any[]) => void): this; ++//z removeListener(event: string, listener: (...args: any[]) => void): this; ++//z prependListener(event: string, listener: (...args: any[]) => void): this; ++//z prependOnceListener(event: string, listener: (...args: any[]) => void): this; ++//z emit(name: string, ...args: any[]): boolean; ++//z } ++//z // #endregion Runnable untyped events ++ ++//z /** ++//z * Test context ++//z * ++//z * @see https://mochajs.org/api/module-Context.html#~Context ++//z */ ++//z class Context { ++//z private _runnable; ++ ++//z test?: Runnable; ++//z currentTest?: Test; ++ ++//z /** ++//z * Get the context `Runnable`. ++//z */ ++//z runnable(): Runnable; ++ ++//z /** ++//z * Set the context `Runnable`. ++//z */ ++//z runnable(runnable: Runnable): this; ++ ++//z /** ++//z * Get test timeout. ++//z */ ++//z timeout(): number; ++ ++//z /** ++//z * Set test timeout. ++//z */ ++//z timeout(ms: string | number): this; ++ ++//z /** ++//z * Get test slowness threshold. ++//z */ ++//z slow(): number; ++ ++//z /** ++//z * Set test slowness threshold. ++//z */ ++//z slow(ms: string | number): this; ++ ++//z /** ++//z * Mark a test as skipped. ++//z */ ++//z skip(): never; ++ ++//z /** ++//z * Get the number of allowed retries on failed tests. ++//z */ ++//z retries(): number; ++ ++//z /** ++//z * Set the number of allowed retries on failed tests. ++//z */ ++//z retries(n: number): this; ++ ++//z [key: string]: any; ++//z } ++ ++//z interface RunnerConstants { ++//z readonly EVENT_HOOK_BEGIN: 'hook'; ++//z readonly EVENT_HOOK_END: 'hook end'; ++//z readonly EVENT_RUN_BEGIN: 'start'; ++//z readonly EVENT_DELAY_BEGIN: 'waiting'; ++//z readonly EVENT_DELAY_END: 'ready'; ++//z readonly EVENT_RUN_END: 'end'; ++//z readonly EVENT_SUITE_BEGIN: 'suite'; ++//z readonly EVENT_SUITE_END: 'suite end'; ++//z readonly EVENT_TEST_BEGIN: 'test'; ++//z readonly EVENT_TEST_END: 'test end'; ++//z readonly EVENT_TEST_FAIL: 'fail'; ++//z readonly EVENT_TEST_PASS: 'pass'; ++//z readonly EVENT_TEST_PENDING: 'pending'; ++//z readonly EVENT_TEST_RETRY: 'retry'; ++//z } ++ ++//z /** ++//z * Initialize a `Runner` for the given `suite`. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html ++//z */ ++//z class Runner { ++//z private _globals; ++//z private _abort; ++//z private _delay; ++//z private _defaultGrep; ++//z private next; ++//z private hookErr; ++//z private prevGlobalsLength; ++//z private nextSuite; ++ ++//z static readonly constants: RunnerConstants; ++ ++//z constructor(suite: Suite, delay: boolean); ++ ++//z suite: Suite; ++//z started: boolean; ++//z total: number; ++//z failures: number; ++//z asyncOnly?: boolean; ++//z allowUncaught?: boolean; ++//z fullStackTrace?: boolean; ++//z forbidOnly?: boolean; ++//z forbidPending?: boolean; ++//z checkLeaks?: boolean; ++//z test?: Test; ++//z currentRunnable?: Runnable; ++//z stats?: Stats; // added by reporters ++ ++//z /** ++//z * Run tests with full titles matching `re`. Updates runner.total ++//z * with number of tests matched. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grep ++//z */ ++//z grep(re: RegExp, invert: boolean): this; ++ ++//z /** ++//z * Returns the number of tests matching the grep search for the ++//z * given suite. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grepTotal ++//z */ ++//z grepTotal(suite: Suite): number; ++ ++//z /** ++//z * Gets the allowed globals. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals ++//z */ ++//z globals(): string[]; ++ ++//z /** ++//z * Allow the given `arr` of globals. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals ++//z */ ++//z globals(arr: ReadonlyArray): this; ++ ++//z /** ++//z * Run the root suite and invoke `fn(failures)` on completion. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#run ++//z */ ++//z run(fn?: (failures: number) => void): this; ++ ++//z /** ++//z * Cleanly abort execution. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#abort ++//z */ ++//z abort(): this; ++ ++//z /** ++//z * Handle uncaught exceptions. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#uncaught ++//z */ ++//z uncaught(err: any): void; ++ ++//z /** ++//z * Wrapper for setImmediate, process.nextTick, or browser polyfill. ++//z */ ++//z protected static immediately(callback: Function): void; ++ ++//z /** ++//z * Return a list of global properties. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#globalProps ++//z */ ++//z protected globalProps(): string[]; ++ ++//z /** ++//z * Check for global variable leaks. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#checkGlobals ++//z */ ++//z protected checkGlobals(test: Test): void; ++ ++//z /** ++//z * Fail the given `test`. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#fail ++//z */ ++//z protected fail(test: Test, err: any): void; ++ ++//z /** ++//z * Fail the given `hook` with `err`. ++//z * ++//z * Hook failures work in the following pattern: ++//z * - If bail, then exit ++//z * - Failed `before` hook skips all tests in a suite and subsuites, ++//z * but jumps to corresponding `after` hook ++//z * - Failed `before each` hook skips remaining tests in a ++//z * suite and jumps to corresponding `after each` hook, ++//z * which is run only once ++//z * - Failed `after` hook does not alter ++//z * execution order ++//z * - Failed `after each` hook skips remaining tests in a ++//z * suite and subsuites, but executes other `after each` ++//z * hooks ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#failHook ++//z */ ++//z protected failHook(hook: Hook, err: any): void; ++ ++//z /** ++//z * Run hook `name` callbacks and then invoke `fn()`. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#hook ++//z */ ++//z protected hook(name: string, fn: () => void): void; ++ ++//z /** ++//z * Run hook `name` for the given array of `suites` ++//z * in order, and callback `fn(err, errSuite)`. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#hooks ++//z */ ++//z protected hooks(name: string, suites: Suite[], fn: (err?: any, errSuite?: Suite) => void): void; ++ ++//z /** ++//z * Run hooks from the top level down. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#hookUp ++//z */ ++//z protected hookUp(name: string, fn: (err?: any, errSuite?: Suite) => void): void; ++ ++//z /** ++//z * Run hooks from the bottom up. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#hookDown ++//z */ ++//z protected hookDown(name: string, fn: (err?: any, errSuite?: Suite) => void): void; ++ ++//z /** ++//z * Return an array of parent Suites from closest to furthest. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#parents ++//z */ ++//z protected parents(): Suite[]; ++ ++//z /** ++//z * Run the current test and callback `fn(err)`. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#runTest ++//z */ ++//z protected runTest(fn: Done): any; ++ ++//z /** ++//z * Run tests in the given `suite` and invoke the callback `fn()` when complete. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#runTests ++//z */ ++//z protected runTests(suite: Suite, fn: (errSuite?: Suite) => void): void; ++ ++//z /** ++//z * Run the given `suite` and invoke the callback `fn()` when complete. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Runner.html#runSuite ++//z */ ++//z protected runSuite(suite: Suite, fn: (errSuite?: Suite) => void): void; ++//z } ++ ++//z // #region Runner "waiting" event ++//z interface Runner { ++//z on(event: "waiting", listener: (rootSuite: Suite) => void): this; ++//z once(event: "waiting", listener: (rootSuite: Suite) => void): this; ++//z addListener(event: "waiting", listener: (rootSuite: Suite) => void): this; ++//z removeListener(event: "waiting", listener: (rootSuite: Suite) => void): this; ++//z prependListener(event: "waiting", listener: (rootSuite: Suite) => void): this; ++//z prependOnceListener(event: "waiting", listener: (rootSuite: Suite) => void): this; ++//z emit(name: "waiting", rootSuite: Suite): boolean; ++//z } ++//z // #endregion Runner "waiting" event ++//z // #region Runner "start" event ++//z interface Runner extends NodeJS.EventEmitter { ++//z on(event: "start", listener: () => void): this; ++//z once(event: "start", listener: () => void): this; ++//z addListener(event: "start", listener: () => void): this; ++//z removeListener(event: "start", listener: () => void): this; ++//z prependListener(event: "start", listener: () => void): this; ++//z prependOnceListener(event: "start", listener: () => void): this; ++//z emit(name: "start"): boolean; ++//z } ++//z // #endregion Runner "start" event ++//z // #region Runner "end" event ++//z interface Runner extends NodeJS.EventEmitter { ++//z on(event: "end", listener: () => void): this; ++//z once(event: "end", listener: () => void): this; ++//z addListener(event: "end", listener: () => void): this; ++//z removeListener(event: "end", listener: () => void): this; ++//z prependListener(event: "end", listener: () => void): this; ++//z prependOnceListener(event: "end", listener: () => void): this; ++//z emit(name: "end"): boolean; ++//z } ++//z // #endregion Runner "end" event ++//z // #region Runner "suite" event ++//z interface Runner extends NodeJS.EventEmitter { ++//z on(event: "suite", listener: (suite: Suite) => void): this; ++//z once(event: "suite", listener: (suite: Suite) => void): this; ++//z addListener(event: "suite", listener: (suite: Suite) => void): this; ++//z removeListener(event: "suite", listener: (suite: Suite) => void): this; ++//z prependListener(event: "suite", listener: (suite: Suite) => void): this; ++//z prependOnceListener(event: "suite", listener: (suite: Suite) => void): this; ++//z emit(name: "suite", suite: Suite): boolean; ++//z } ++//z // #endregion Runner "suite" event ++//z // #region Runner "suite end" event ++//z interface Runner extends NodeJS.EventEmitter { ++//z on(event: "suite end", listener: (suite: Suite) => void): this; ++//z once(event: "suite end", listener: (suite: Suite) => void): this; ++//z addListener(event: "suite end", listener: (suite: Suite) => void): this; ++//z removeListener(event: "suite end", listener: (suite: Suite) => void): this; ++//z prependListener(event: "suite end", listener: (suite: Suite) => void): this; ++//z prependOnceListener(event: "suite end", listener: (suite: Suite) => void): this; ++//z emit(name: "suite end", suite: Suite): boolean; ++//z } ++//z // #endregion Runner "suite end" event ++//z // #region Runner "test" event ++//z interface Runner extends NodeJS.EventEmitter { ++//z on(event: "test", listener: (test: Test) => void): this; ++//z once(event: "test", listener: (test: Test) => void): this; ++//z addListener(event: "test", listener: (test: Test) => void): this; ++//z removeListener(event: "test", listener: (test: Test) => void): this; ++//z prependListener(event: "test", listener: (test: Test) => void): this; ++//z prependOnceListener(event: "test", listener: (test: Test) => void): this; ++//z emit(name: "test", test: Test): boolean; ++//z } ++//z // #endregion Runner "test" event ++//z // #region Runner "test end" event ++//z interface Runner extends NodeJS.EventEmitter { ++//z on(event: "test end", listener: (test: Test) => void): this; ++//z once(event: "test end", listener: (test: Test) => void): this; ++//z addListener(event: "test end", listener: (test: Test) => void): this; ++//z removeListener(event: "test end", listener: (test: Test) => void): this; ++//z prependListener(event: "test end", listener: (test: Test) => void): this; ++//z prependOnceListener(event: "test end", listener: (test: Test) => void): this; ++//z emit(name: "test end", test: Test): boolean; ++//z } ++//z // #endregion Runner "test end" event ++//z // #region Runner "hook" event ++//z interface Runner extends NodeJS.EventEmitter { ++//z on(event: "hook", listener: (hook: Hook) => void): this; ++//z once(event: "hook", listener: (hook: Hook) => void): this; ++//z addListener(event: "hook", listener: (hook: Hook) => void): this; ++//z removeListener(event: "hook", listener: (hook: Hook) => void): this; ++//z prependListener(event: "hook", listener: (hook: Hook) => void): this; ++//z prependOnceListener(event: "hook", listener: (hook: Hook) => void): this; ++//z emit(name: "hook", hook: Hook): boolean; ++//z } ++//z // #endregion Runner "hook" event ++//z // #region Runner "hook end" event ++//z interface Runner extends NodeJS.EventEmitter { ++//z on(event: "hook end", listener: (hook: Hook) => void): this; ++//z once(event: "hook end", listener: (hook: Hook) => void): this; ++//z addListener(event: "hook end", listener: (hook: Hook) => void): this; ++//z removeListener(event: "hook end", listener: (hook: Hook) => void): this; ++//z prependListener(event: "hook end", listener: (hook: Hook) => void): this; ++//z prependOnceListener(event: "hook end", listener: (hook: Hook) => void): this; ++//z emit(name: "hook end", hook: Hook): boolean; ++//z } ++//z // #endregion Runner "hook end" event ++//z // #region Runner "pass" event ++//z interface Runner extends NodeJS.EventEmitter { ++//z on(event: "pass", listener: (test: Test) => void): this; ++//z once(event: "pass", listener: (test: Test) => void): this; ++//z addListener(event: "pass", listener: (test: Test) => void): this; ++//z removeListener(event: "pass", listener: (test: Test) => void): this; ++//z prependListener(event: "pass", listener: (test: Test) => void): this; ++//z prependOnceListener(event: "pass", listener: (test: Test) => void): this; ++//z emit(name: "pass", test: Test): boolean; ++//z } ++//z // #endregion Runner "pass" event ++//z // #region Runner "fail" event ++//z interface Runner extends NodeJS.EventEmitter { ++//z on(event: "fail", listener: (test: Test, err: any) => void): this; ++//z once(event: "fail", listener: (test: Test, err: any) => void): this; ++//z addListener(event: "fail", listener: (test: Test, err: any) => void): this; ++//z removeListener(event: "fail", listener: (test: Test, err: any) => void): this; ++//z prependListener(event: "fail", listener: (test: Test, err: any) => void): this; ++//z prependOnceListener(event: "fail", listener: (test: Test, err: any) => void): this; ++//z emit(name: "fail", test: Test, err: any): boolean; ++//z } ++//z // #endregion Runner "fail" event ++//z // #region Runner "pending" event ++//z interface Runner extends NodeJS.EventEmitter { ++//z on(event: "pending", listener: (test: Test) => void): this; ++//z once(event: "pending", listener: (test: Test) => void): this; ++//z addListener(event: "pending", listener: (test: Test) => void): this; ++//z removeListener(event: "pending", listener: (test: Test) => void): this; ++//z prependListener(event: "pending", listener: (test: Test) => void): this; ++//z prependOnceListener(event: "pending", listener: (test: Test) => void): this; ++//z emit(name: "pending", test: Test): boolean; ++//z } ++//z // #endregion Runner "pending" event ++//z // #region Runner untyped events ++//z interface Runner extends NodeJS.EventEmitter { ++//z on(event: string, listener: (...args: any[]) => void): this; ++//z once(event: string, listener: (...args: any[]) => void): this; ++//z addListener(event: string, listener: (...args: any[]) => void): this; ++//z removeListener(event: string, listener: (...args: any[]) => void): this; ++//z prependListener(event: string, listener: (...args: any[]) => void): this; ++//z prependOnceListener(event: string, listener: (...args: any[]) => void): this; ++//z emit(name: string, ...args: any[]): boolean; ++//z } ++//z // #endregion Runner untyped events ++ ++//z interface SuiteConstants { ++//z readonly EVENT_FILE_POST_REQUIRE: 'post-require'; ++//z readonly EVENT_FILE_PRE_REQUIRE: 'pre-require'; ++//z readonly EVENT_FILE_REQUIRE: 'require'; ++//z readonly EVENT_ROOT_SUITE_RUN: 'run'; ++ ++//z readonly HOOK_TYPE_AFTER_ALL: 'afterAll'; ++//z readonly HOOK_TYPE_AFTER_EACH: 'afterEach'; ++//z readonly HOOK_TYPE_BEFORE_ALL: 'beforeAll'; ++//z readonly HOOK_TYPE_BEFORE_EACH: 'beforeEach'; ++ ++//z readonly EVENT_SUITE_ADD_HOOK_AFTER_ALL: 'afterAll'; ++//z readonly EVENT_SUITE_ADD_HOOK_AFTER_EACH: 'afterEach'; ++//z readonly EVENT_SUITE_ADD_HOOK_BEFORE_ALL: 'beforeAll'; ++//z readonly EVENT_SUITE_ADD_HOOK_BEFORE_EACH: 'beforeEach'; ++//z readonly EVENT_SUITE_ADD_SUITE: 'suite'; ++//z readonly EVENT_SUITE_ADD_TEST: 'test'; ++//z } ++ ++//z /** ++//z * Initialize a new `Suite` with the given `title` and `ctx`. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html ++//z */ ++//z class Suite { ++//z private _beforeEach; ++//z private _beforeAll; ++//z private _afterEach; ++//z private _afterAll; ++//z private _timeout; ++//z private _slow; ++//z private _bail; ++//z private _retries; ++//z private _onlyTests; ++//z private _onlySuites; ++ ++//z static readonly constants: SuiteConstants; ++ ++//z constructor(title: string, parentContext?: Context); ++ ++//z ctx: Context; ++//z suites: Suite[]; ++//z tests: Test[]; ++//z pending: boolean; ++//z file?: string; ++//z root: boolean; ++//z delayed: boolean; ++//z parent: Suite | undefined; ++//z title: string; ++ ++//z /** ++//z * Create a new `Suite` with the given `title` and parent `Suite`. When a suite ++//z * with the same title is already present, that suite is returned to provide ++//z * nicer reporter and more flexible meta-testing. ++//z * ++//z * @see https://mochajs.org/api/mocha#.exports.create ++//z */ ++//z static create(parent: Suite, title: string): Suite; ++ ++//z /** ++//z * Return a clone of this `Suite`. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#clone ++//z */ ++//z clone(): Suite; ++ ++//z /** ++//z * Get timeout `ms`. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#timeout ++//z */ ++//z timeout(): number; ++ ++//z /** ++//z * Set timeout `ms` or short-hand such as "2s". ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#timeout ++//z */ ++//z timeout(ms: string | number): this; ++ ++//z /** ++//z * Get number of times to retry a failed test. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#retries ++//z */ ++//z retries(): number; ++ ++//z /** ++//z * Set number of times to retry a failed test. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#retries ++//z */ ++//z retries(n: string | number): this; ++ ++//z /** ++//z * Get slow `ms`. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#slow ++//z */ ++//z slow(): number; ++ ++//z /** ++//z * Set slow `ms` or short-hand such as "2s". ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#slow ++//z */ ++//z slow(ms: string | number): this; ++ ++//z /** ++//z * Get whether to bail after first error. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#bail ++//z */ ++//z bail(): boolean; ++ ++//z /** ++//z * Set whether to bail after first error. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#bail ++//z */ ++//z bail(bail: boolean): this; ++ ++//z /** ++//z * Check if this suite or its parent suite is marked as pending. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#isPending ++//z */ ++//z isPending(): boolean; ++ ++//z /** ++//z * Run `fn(test[, done])` before running tests. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll ++//z */ ++//z beforeAll(fn?: Func): this; ++ ++//z /** ++//z * Run `fn(test[, done])` before running tests. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll ++//z */ ++//z beforeAll(fn?: AsyncFunc): this; ++ ++//z /** ++//z * Run `fn(test[, done])` before running tests. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll ++//z */ ++//z beforeAll(title: string, fn?: Func): this; ++ ++//z /** ++//z * Run `fn(test[, done])` before running tests. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll ++//z */ ++//z beforeAll(title: string, fn?: AsyncFunc): this; ++ ++//z /** ++//z * Run `fn(test[, done])` after running tests. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#afterAll ++//z */ ++//z afterAll(fn?: Func): this; ++ ++//z /** ++//z * Run `fn(test[, done])` after running tests. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#afterAll ++//z */ ++//z afterAll(fn?: AsyncFunc): this; ++ ++//z /** ++//z * Run `fn(test[, done])` after running tests. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#afterAll ++//z */ ++//z afterAll(title: string, fn?: Func): this; ++ ++//z /** ++//z * Run `fn(test[, done])` after running tests. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#afterAll ++//z */ ++//z afterAll(title: string, fn?: AsyncFunc): this; ++ ++//z /** ++//z * Run `fn(test[, done])` before each test case. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach ++//z */ ++//z beforeEach(fn?: Func): this; ++ ++//z /** ++//z * Run `fn(test[, done])` before each test case. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach ++//z */ ++//z beforeEach(fn?: AsyncFunc): this; ++ ++//z /** ++//z * Run `fn(test[, done])` before each test case. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach ++//z */ ++//z beforeEach(title: string, fn?: Func): this; ++ ++//z /** ++//z * Run `fn(test[, done])` before each test case. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach ++//z */ ++//z beforeEach(title: string, fn?: AsyncFunc): this; ++ ++//z /** ++//z * Run `fn(test[, done])` after each test case. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#afterEach ++//z */ ++//z afterEach(fn?: Func): this; ++ ++//z /** ++//z * Run `fn(test[, done])` after each test case. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#afterEach ++//z */ ++//z afterEach(fn?: AsyncFunc): this; ++ ++//z /** ++//z * Run `fn(test[, done])` after each test case. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#afterEach ++//z */ ++//z afterEach(title: string, fn?: Func): this; ++ ++//z /** ++//z * Run `fn(test[, done])` after each test case. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#afterEach ++//z */ ++//z afterEach(title: string, fn?: AsyncFunc): this; ++ ++//z /** ++//z * Add a test `suite`. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#addSuite ++//z */ ++//z addSuite(suite: Suite): this; ++ ++//z /** ++//z * Add a `test` to this suite. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#addTest ++//z */ ++//z addTest(test: Test): this; ++ ++//z /** ++//z * Return the full title generated by recursively concatenating the parent's ++//z * full title. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#fullTitle ++//z */ ++//z fullTitle(): string; ++ ++//z /** ++//z * Return the title path generated by recursively concatenating the parent's ++//z * title path. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#titlePath ++//z */ ++//z titlePath(): string[]; ++ ++//z /** ++//z * Return the total number of tests. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#total ++//z */ ++//z total(): number; ++ ++//z /** ++//z * Iterates through each suite recursively to find all tests. Applies a ++//z * function in the format `fn(test)`. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#eachTest ++//z */ ++//z eachTest(fn: (test: Test) => void): this; ++ ++//z /** ++//z * This will run the root suite if we happen to be running in delayed mode. ++//z * ++//z * @see https://mochajs.org/api/Mocha.Suite.html#run ++//z */ ++//z run(): void; ++ ++//z /** ++//z * Generic hook-creator. ++//z */ ++//z protected _createHook(title: string, fn?: Func | AsyncFunc): Hook; ++//z } ++ ++//z // #region Suite "beforeAll" event ++//z interface Suite extends NodeJS.EventEmitter { ++//z on(event: "beforeAll", listener: (hook: Hook) => void): this; ++//z once(event: "beforeAll", listener: (hook: Hook) => void): this; ++//z addListener(event: "beforeAll", listener: (hook: Hook) => void): this; ++//z removeListener(event: "beforeAll", listener: (hook: Hook) => void): this; ++//z prependListener(event: "beforeAll", listener: (hook: Hook) => void): this; ++//z prependOnceListener(event: "beforeAll", listener: (hook: Hook) => void): this; ++//z emit(name: "beforeAll", hook: Hook): boolean; ++//z } ++//z // #endregion Suite "beforeAll" event ++//z // #region Suite "afterAll" event ++//z interface Suite extends NodeJS.EventEmitter { ++//z on(event: "afterAll", listener: (hook: Hook) => void): this; ++//z once(event: "afterAll", listener: (hook: Hook) => void): this; ++//z addListener(event: "afterAll", listener: (hook: Hook) => void): this; ++//z removeListener(event: "afterAll", listener: (hook: Hook) => void): this; ++//z prependListener(event: "afterAll", listener: (hook: Hook) => void): this; ++//z prependOnceListener(event: "afterAll", listener: (hook: Hook) => void): this; ++//z emit(name: "afterAll", hook: Hook): boolean; ++//z } ++//z // #endregion Suite "afterAll" event ++//z // #region Suite "beforeEach" event ++//z interface Suite extends NodeJS.EventEmitter { ++//z on(event: "beforeEach", listener: (hook: Hook) => void): this; ++//z once(event: "beforeEach", listener: (hook: Hook) => void): this; ++//z addListener(event: "beforeEach", listener: (hook: Hook) => void): this; ++//z removeListener(event: "beforeEach", listener: (hook: Hook) => void): this; ++//z prependListener(event: "beforeEach", listener: (hook: Hook) => void): this; ++//z prependOnceListener(event: "beforeEach", listener: (hook: Hook) => void): this; ++//z emit(name: "beforeEach", hook: Hook): boolean; ++//z } ++//z // #endregion Suite "beforeEach" event ++//z // #region Suite "afterEach" event ++//z interface Suite extends NodeJS.EventEmitter { ++//z on(event: "afterEach", listener: (hook: Hook) => void): this; ++//z once(event: "afterEach", listener: (hook: Hook) => void): this; ++//z addListener(event: "afterEach", listener: (hook: Hook) => void): this; ++//z removeListener(event: "afterEach", listener: (hook: Hook) => void): this; ++//z prependListener(event: "afterEach", listener: (hook: Hook) => void): this; ++//z prependOnceListener(event: "afterEach", listener: (hook: Hook) => void): this; ++//z emit(name: "afterEach", hook: Hook): boolean; ++//z } ++//z // #endregion Suite "afterEach" event ++//z // #region Suite "suite" event ++//z interface Suite extends NodeJS.EventEmitter { ++//z on(event: "suite", listener: (suite: Suite) => void): this; ++//z once(event: "suite", listener: (suite: Suite) => void): this; ++//z addListener(event: "suite", listener: (suite: Suite) => void): this; ++//z removeListener(event: "suite", listener: (suite: Suite) => void): this; ++//z prependListener(event: "suite", listener: (suite: Suite) => void): this; ++//z prependOnceListener(event: "suite", listener: (suite: Suite) => void): this; ++//z emit(name: "suite", suite: Suite): boolean; ++//z } ++//z // #endregion Suite "suite" event ++//z // #region Suite "test" event ++//z interface Suite { ++//z on(event: "test", listener: (test: Test) => void): this; ++//z once(event: "test", listener: (test: Test) => void): this; ++//z addListener(event: "test", listener: (test: Test) => void): this; ++//z removeListener(event: "test", listener: (test: Test) => void): this; ++//z prependListener(event: "test", listener: (test: Test) => void): this; ++//z prependOnceListener(event: "test", listener: (test: Test) => void): this; ++//z emit(name: "test", test: Test): boolean; ++//z } ++//z // #endregion Suite "test" event ++//z // #region Suite "run" event ++//z interface Suite extends NodeJS.EventEmitter { ++//z on(event: "run", listener: () => void): this; ++//z once(event: "run", listener: () => void): this; ++//z addListener(event: "run", listener: () => void): this; ++//z removeListener(event: "run", listener: () => void): this; ++//z prependListener(event: "run", listener: () => void): this; ++//z prependOnceListener(event: "run", listener: () => void): this; ++//z emit(name: "run"): boolean; ++//z } ++//z // #endregion Suite "run" event ++//z // #region Suite "pre-require" event ++//z interface Suite extends NodeJS.EventEmitter { ++//z on(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++//z once(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++//z addListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++//z removeListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++//z prependListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++//z prependOnceListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++//z emit(name: "pre-require", context: MochaGlobals, file: string, mocha: Mocha): boolean; ++//z } ++//z // #endregion Suite "pre-require" event ++//z // #region Suite "require" event ++//z interface Suite extends NodeJS.EventEmitter { ++//z on(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; ++//z once(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; ++//z addListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; ++//z removeListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; ++//z prependListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; ++//z prependOnceListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; ++//z emit(name: "require", module: any, file: string, mocha: Mocha): boolean; ++//z } ++//z // #endregion Suite "require" event ++//z // #region Suite "post-require" event ++//z interface Suite extends NodeJS.EventEmitter { ++//z on(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++//z once(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++//z addListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++//z removeListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++//z prependListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++//z prependOnceListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; ++//z emit(name: "post-require", context: MochaGlobals, file: string, mocha: Mocha): boolean; ++//z } ++//z // #endregion Suite "post-require" event ++//z // #region Suite untyped events ++//z interface Suite extends NodeJS.EventEmitter { ++//z on(event: string, listener: (...args: any[]) => void): this; ++//z once(event: string, listener: (...args: any[]) => void): this; ++//z addListener(event: string, listener: (...args: any[]) => void): this; ++//z removeListener(event: string, listener: (...args: any[]) => void): this; ++//z prependListener(event: string, listener: (...args: any[]) => void): this; ++//z prependOnceListener(event: string, listener: (...args: any[]) => void): this; ++//z emit(name: string, ...args: any[]): boolean; ++//z } ++//z // #endregion Runner untyped events ++ ++//z /** ++//z * Initialize a new `Hook` with the given `title` and callback `fn` ++//z * ++//z * @see https://mochajs.org/api/Hook.html ++//z */ ++//z class Hook extends Runnable { ++//z private _error; ++ ++//z type: "hook"; ++//z originalTitle?: string; // added by Runner ++ ++//z /** ++//z * Get the test `err`. ++//z * ++//z * @see https://mochajs.org/api/Hook.html#error ++//z */ ++//z error(): any; ++ ++//z /** ++//z * Set the test `err`. ++//z * ++//z * @see https://mochajs.org/api/Hook.html#error ++//z */ ++//z error(err: any): void; ++//z } ++ ++//z /** ++//z * An alternative way to define root hooks that works with parallel runs. ++//z * ++//z * Root hooks work with any interface, but the property names do not change. ++//z * In other words, if you are using the tdd interface, suiteSetup maps to beforeAll, and setup maps to beforeEach. ++//z * ++//z * As with other hooks, `this` refers to to the current context object. ++//z * ++//z * @see https://mochajs.org/#root-hook-plugins ++//z */ ++//z interface RootHookObject { ++//z /** ++//z * In serial mode, run after all tests end, once only. ++//z * In parallel mode, run after all tests end, for each file. ++//z */ ++//z afterAll?: Func | AsyncFunc | Func[] | AsyncFunc[]; ++//z /** ++//z * In serial mode (Mocha's default), before all tests begin, once only. ++//z * In parallel mode, run before all tests begin, for each file. ++//z */ ++//z beforeAll?: Func | AsyncFunc | Func[] | AsyncFunc[]; ++//z /** ++//z * In both modes, run after every test. ++//z */ ++//z afterEach?: Func | AsyncFunc | Func[] | AsyncFunc[]; ++//z /** ++//z * In both modes, run before each test. ++//z */ ++//z beforeEach?: Func | AsyncFunc | Func[] | AsyncFunc[]; ++//z } ++ ++//z /** ++//z * Initialize a new `Test` with the given `title` and callback `fn`. ++//z * ++//z * @see https://mochajs.org/api/Test.html ++//z */ ++//z class Test extends Runnable { ++//z type: "test"; ++//z speed?: "slow" | "medium" | "fast"; // added by reporters ++//z err?: Error; // added by reporters ++//z clone(): Test; ++//z } ++ ++//z /** ++//z * Test statistics ++//z */ ++//z interface Stats { ++//z suites: number; ++//z tests: number; ++//z passes: number; ++//z pending: number; ++//z failures: number; ++//z start?: Date; ++//z end?: Date; ++//z duration?: number; ++//z } ++ ++//z type TestInterface = (suite: Suite) => void; ++ ++//z interface ReporterConstructor { ++//z new (runner: Runner, options: MochaOptions): reporters.Base; ++//z } ++ ++//z type Done = (err?: any) => void; ++ ++//z /** ++//z * Callback function used for tests and hooks. ++//z */ ++//z type Func = (this: Context, done: Done) => void; ++ ++//z /** ++//z * Async callback function used for tests and hooks. ++//z */ ++//z type AsyncFunc = (this: Context) => PromiseLike; ++ ++//z /** ++//z * Options to pass to Mocha. ++//z */ ++//z interface MochaOptions { ++//z /** Test interfaces ("bdd", "tdd", "exports", etc.). */ ++//z ui?: Interface; ++ ++//z /** ++//z * Reporter constructor, built-in reporter name, or reporter module path. Defaults to ++//z * `"spec"`. ++//z */ ++//z reporter?: string | ReporterConstructor; ++ ++//z /** Options to pass to the reporter. */ ++//z reporterOptions?: any; ++ ++//z /** Array of accepted globals. */ ++//z globals?: string[]; ++ ++//z /** timeout in milliseconds or time string like '1s'. */ ++//z timeout?: number | string; ++ ++//z /** number of times to retry failed tests. */ ++//z retries?: number; ++ ++//z /** bail on the first test failure. */ ++//z bail?: boolean; ++ ++//z /** milliseconds to wait before considering a test slow. */ ++//z slow?: number; ++ ++//z /** check for global variable leaks. */ ++//z checkLeaks?: boolean; ++ ++//z /** display the full stack trace on failure. */ ++//z fullStackTrace?: boolean; ++ ++//z /** string or regexp to filter tests with. */ ++//z grep?: string | RegExp; ++ ++//z /** Enable growl support. */ ++//z growl?: boolean; ++ ++//z /** Color TTY output from reporter */ ++//z color?: boolean; ++ ++//z /** Use inline diffs rather than +/-. */ ++//z inlineDiffs?: boolean; ++ ++//z /** Do not show diffs at all. */ ++//z hideDiff?: boolean; ++ ++//z /** Run job in parallel */ ++//z parallel?: boolean; ++ ++//z /** Max number of worker processes for parallel runs */ ++//z jobs?: number; ++ ++//z /** Assigns hooks to the root suite */ ++//z rootHooks?: RootHookObject; ++ ++//z asyncOnly?: boolean; ++//z delay?: boolean; ++//z forbidOnly?: boolean; ++//z forbidPending?: boolean; ++//z noHighlighting?: boolean; ++//z allowUncaught?: boolean; ++//z fullTrace?: boolean; ++//z } ++ ++//z interface MochaInstanceOptions extends MochaOptions { ++//z files?: string[]; ++//z } ++ ++//z /** ++//z * Variables added to the global scope by Mocha when run in the CLI. ++//z */ ++//z interface MochaGlobals { ++//z /** ++//z * Execute before running tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#before ++//z */ ++//z before: HookFunction; ++ ++//z /** ++//z * Execute after running tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#after ++//z */ ++//z after: HookFunction; ++ ++//z /** ++//z * Execute before each test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#beforeEach ++//z */ ++//z beforeEach: HookFunction; ++ ++//z /** ++//z * Execute after each test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#afterEach ++//z */ ++//z afterEach: HookFunction; ++ ++//z /** ++//z * Describe a "suite" containing nested suites and tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z describe: SuiteFunction; ++ ++//z /** ++//z * Describe a "suite" containing nested suites and tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z context: SuiteFunction; ++ ++//z /** ++//z * Pending suite. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z xdescribe: PendingSuiteFunction; ++ ++//z /** ++//z * Pending suite. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z xcontext: PendingSuiteFunction; ++ ++//z /** ++//z * Describes a test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z it: TestFunction; ++ ++//z /** ++//z * Describes a test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z specify: TestFunction; ++ ++//z /** ++//z * Describes a pending test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z xit: PendingTestFunction; ++ ++//z /** ++//z * Describes a pending test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z xspecify: PendingTestFunction; ++ ++//z /** ++//z * Execute before running tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#before ++//z */ ++//z suiteSetup: HookFunction; ++ ++//z /** ++//z * Execute after running tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#after ++//z */ ++//z suiteTeardown: HookFunction; ++ ++//z /** ++//z * Execute before each test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#beforeEach ++//z */ ++//z setup: HookFunction; ++ ++//z /** ++//z * Execute after each test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#afterEach ++//z */ ++//z teardown: HookFunction; ++ ++//z /** ++//z * Describe a "suite" containing nested suites and tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z suite: SuiteFunction; ++ ++//z /** ++//z * Describes a test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z test: TestFunction; ++ ++//z run: typeof run; ++//z } ++ ++//z /** ++//z * Third-party declarations that want to add new entries to the `Reporter` union can ++//z * contribute names here. ++//z */ ++//z interface ReporterContributions { ++//z Base: never; ++//z base: never; ++//z Dot: never; ++//z dot: never; ++//z TAP: never; ++//z tap: never; ++//z JSON: never; ++//z json: never; ++//z HTML: never; ++//z html: never; ++//z List: never; ++//z list: never; ++//z Min: never; ++//z min: never; ++//z Spec: never; ++//z spec: never; ++//z Nyan: never; ++//z nyan: never; ++//z XUnit: never; ++//z xunit: never; ++//z Markdown: never; ++//z markdown: never; ++//z Progress: never; ++//z progress: never; ++//z Landing: never; ++//z landing: never; ++//z JSONStream: never; ++//z "json-stream": never; ++//z } ++ ++//z type Reporter = keyof ReporterContributions; ++ ++//z /** ++//z * Third-party declarations that want to add new entries to the `Interface` union can ++//z * contribute names here. ++//z */ ++//z interface InterfaceContributions { ++//z bdd: never; ++//z tdd: never; ++//z qunit: never; ++//z exports: never; ++//z } ++ ++//z type Interface = keyof InterfaceContributions; ++//z } ++ ++//z // #region Test interface augmentations ++ ++//z /** ++//z * Triggers root suite execution. ++//z * ++//z * - _Only available if flag --delay is passed into Mocha._ ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#runWithSuite ++//z */ ++//z declare function run(): void; ++ ++//z /** ++//z * Execute before running tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#before ++//z */ ++//z declare var before: Mocha.HookFunction; ++ ++//z /** ++//z * Execute before running tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#before ++//z */ ++//z declare var suiteSetup: Mocha.HookFunction; ++ ++//z /** ++//z * Execute after running tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#after ++//z */ ++//z declare var after: Mocha.HookFunction; ++ ++//z /** ++//z * Execute after running tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#after ++//z */ ++//z declare var suiteTeardown: Mocha.HookFunction; ++ ++//z /** ++//z * Execute before each test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#beforeEach ++//z */ ++//z declare var beforeEach: Mocha.HookFunction; ++ ++//z /** ++//z * Execute before each test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#beforeEach ++//z */ ++//z declare var setup: Mocha.HookFunction; ++ ++//z /** ++//z * Execute after each test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#afterEach ++//z */ ++//z declare var afterEach: Mocha.HookFunction; ++ ++//z /** ++//z * Execute after each test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z * ++//z * @see https://mochajs.org/api/global.html#afterEach ++//z */ ++//z declare var teardown: Mocha.HookFunction; ++ ++//z /** ++//z * Describe a "suite" containing nested suites and tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z declare var describe: Mocha.SuiteFunction; ++ ++//z /** ++//z * Describe a "suite" containing nested suites and tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z declare var context: Mocha.SuiteFunction; ++ ++//z /** ++//z * Describe a "suite" containing nested suites and tests. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z declare var suite: Mocha.SuiteFunction; ++ ++//z /** ++//z * Pending suite. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z declare var xdescribe: Mocha.PendingSuiteFunction; ++ ++//z /** ++//z * Pending suite. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z declare var xcontext: Mocha.PendingSuiteFunction; ++ ++//z /** ++//z * Describes a test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z declare var it: Mocha.TestFunction; ++ ++//z /** ++//z * Describes a test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z declare var specify: Mocha.TestFunction; ++ ++//z /** ++//z * Describes a test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z declare var test: Mocha.TestFunction; ++ ++//z /** ++//z * Describes a pending test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z declare var xit: Mocha.PendingTestFunction; ++ ++//z /** ++//z * Describes a pending test case. ++//z * ++//z * - _Only available when invoked via the mocha CLI._ ++//z */ ++//z declare var xspecify: Mocha.PendingTestFunction; ++ ++//z // #endregion Test interface augmentations ++ ++//z // #region Reporter augmentations ++ ++//z // Forward declaration for `HTMLLIElement` from lib.dom.d.ts. ++//z // Required by Mocha.reporters.HTML. ++//z // NOTE: Mocha *must not* have a direct dependency on DOM types. ++//z // tslint:disable-next-line no-empty-interface ++//z interface HTMLLIElement { } ++ ++//z // Augments the DOM `Window` object when lib.dom.d.ts is loaded. ++//z // tslint:disable-next-line no-empty-interface ++//z interface Window extends Mocha.MochaGlobals { } ++ ++//z declare namespace NodeJS { ++//z // Forward declaration for `NodeJS.EventEmitter` from node.d.ts. ++//z // Required by Mocha.Runnable, Mocha.Runner, and Mocha.Suite. ++//z // NOTE: Mocha *must not* have a direct dependency on @types/node. ++//z // tslint:disable-next-line no-empty-interface ++//z interface EventEmitter { } ++ ++//z // Augments NodeJS's `global` object when node.d.ts is loaded ++//z // tslint:disable-next-line no-empty-interface ++//z interface Global extends Mocha.MochaGlobals { } ++//z } ++ ++//z // #endregion Reporter augmentations ++ ++//z // #region Browser augmentations ++ ++//z /** ++//z * Mocha global. ++//z * ++//z * - _Only supported in the browser._ ++//z */ ++//z declare const mocha: BrowserMocha; ++ ++//z interface BrowserMocha extends Mocha { ++//z /** ++//z * Function to allow assertion libraries to throw errors directly into mocha. ++//z * This is useful when running tests in a browser because window.onerror will ++//z * only receive the 'message' attribute of the Error. ++//z * ++//z * - _Only supported in the browser._ ++//z */ ++//z throwError(err: any): never; ++ ++//z /** ++//z * Setup mocha with the given settings options. ++//z * ++//z * - _Only supported in the browser._ ++//z */ ++//z setup(opts?: Mocha.Interface | Mocha.MochaOptions): this; ++//z } ++ ++//z // #endregion Browser augmentations ++ ++//z declare module "mocha" { ++//z export = Mocha; ++//z } ++ ++//z declare module "mocha/lib/ms" { ++//z export = milliseconds; ++//z /** ++//z * Parse the given `str` and return milliseconds. ++//z * ++//z * @see {@link https://mochajs.org/api/module-milliseconds.html} ++//z * @see {@link https://mochajs.org/api/module-milliseconds.html#~parse} ++//z */ ++//z function milliseconds(val: string): number; ++ ++//z /** ++//z * Format for `ms`. ++//z * ++//z * @see {@link https://mochajs.org/api/module-milliseconds.html} ++//z * @see {@link https://mochajs.org/api/module-milliseconds.html#~format} ++//z */ ++//z function milliseconds(val: number): string; ++//z } ++ ++//z declare module "mocha/lib/interfaces/common" { ++//z export = common; ++ ++//z function common(suites: Mocha.Suite[], context: Mocha.MochaGlobals, mocha: Mocha): common.CommonFunctions; ++ ++//z namespace common { ++//z interface CommonFunctions { ++//z /** ++//z * This is only present if flag --delay is passed into Mocha. It triggers ++//z * root suite execution. ++//z */ ++//z runWithSuite(suite: Mocha.Suite): () => void; ++ ++//z /** ++//z * Execute before running tests. ++//z */ ++//z before(fn?: Mocha.Func | Mocha.AsyncFunc): void; ++ ++//z /** ++//z * Execute before running tests. ++//z */ ++//z before(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; ++ ++//z /** ++//z * Execute after running tests. ++//z */ ++//z after(fn?: Mocha.Func | Mocha.AsyncFunc): void; ++ ++//z /** ++//z * Execute after running tests. ++//z */ ++//z after(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; ++ ++//z /** ++//z * Execute before each test case. ++//z */ ++//z beforeEach(fn?: Mocha.Func | Mocha.AsyncFunc): void; ++ ++//z /** ++//z * Execute before each test case. ++//z */ ++//z beforeEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; ++ ++//z /** ++//z * Execute after each test case. ++//z */ ++//z afterEach(fn?: Mocha.Func | Mocha.AsyncFunc): void; ++ ++//z /** ++//z * Execute after each test case. ++//z */ ++//z afterEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; ++ ++//z suite: SuiteFunctions; ++//z test: TestFunctions; ++//z } ++ ++//z interface CreateOptions { ++//z /** Title of suite */ ++//z title: string; ++ ++//z /** Suite function */ ++//z fn?: (this: Mocha.Suite) => void; ++ ++//z /** Is suite pending? */ ++//z pending?: boolean; ++ ++//z /** Filepath where this Suite resides */ ++//z file?: string; ++ ++//z /** Is suite exclusive? */ ++//z isOnly?: boolean; ++//z } ++ ++//z interface SuiteFunctions { ++//z /** ++//z * Create an exclusive Suite; convenience function ++//z */ ++//z only(opts: CreateOptions): Mocha.Suite; ++ ++//z /** ++//z * Create a Suite, but skip it; convenience function ++//z */ ++//z skip(opts: CreateOptions): Mocha.Suite; ++ ++//z /** ++//z * Creates a suite. ++//z */ ++//z create(opts: CreateOptions): Mocha.Suite; ++//z } ++ ++//z interface TestFunctions { ++//z /** ++//z * Exclusive test-case. ++//z */ ++//z only(mocha: Mocha, test: Mocha.Test): Mocha.Test; ++ ++//z /** ++//z * Pending test case. ++//z */ ++//z skip(title: string): void; ++ ++//z /** ++//z * Number of retry attempts ++//z */ ++//z retries(n: number): void; ++//z } ++//z } ++//z } diff --git a/patches/@types+mocha+8.2.2.dev.patch b/patches/@types+mocha+8.2.2.dev.patch deleted file mode 100644 index 4255ec648827..000000000000 --- a/patches/@types+mocha+8.2.2.dev.patch +++ /dev/null @@ -1,5727 +0,0 @@ -diff --git a/node_modules/@types/mocha/index.d.ts b/node_modules/@types/mocha/index.d.ts -index 52a15fa..485198f 100644 ---- a/node_modules/@types/mocha/index.d.ts -+++ b/node_modules/@types/mocha/index.d.ts -@@ -1,2861 +1,2861 @@ --// Type definitions for mocha 8.2 --// Project: https://mochajs.org --// Definitions by: Kazi Manzur Rashid --// otiai10 --// Vadim Macagon --// Andrew Bradley --// Dmitrii Sorin --// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped --// TypeScript Version: 2.1 -- --/** -- * Mocha API -- * -- * @see https://mochajs.org/api/mocha -- */ --declare class Mocha { -- private _growl; -- private _reporter; -- private _ui; -- -- constructor(options?: Mocha.MochaOptions); -- -- suite: Mocha.Suite; -- files: string[]; -- options: Mocha.MochaInstanceOptions; -- -- /** -- * Add test `file`. -- * -- * @see https://mochajs.org/api/mocha#addFile -- */ -- addFile(file: string): this; -- -- /** -- * Enable or disable bailing on the first failure. -- * -- * @see https://mochajs.org/api/mocha#bail -- */ -- bail(bail?: boolean): this; -- -- /** -- * Manually dispose this mocha instance. Mark this instance as `disposed` and unable to run more tests. -- * It also removes function references to tests functions and hooks, so variables trapped in closures can be cleaned by the garbage collector. -- * -- * @see https://mochajs.org/api/mocha#dispose -- */ -- dispose(): void; -- -- /** -- * Set reporter to one of the built-in reporters. -- * -- * @see https://mochajs.org/api/mocha#reporter -- */ -- reporter(reporter: Mocha.Reporter, reporterOptions?: any): this; -- -- /** -- * Set reporter to the provided constructor, one of the built-in reporters, or loads a reporter -- * from a module path. Defaults to `"spec"`. -- * -- * @see https://mochajs.org/api/mocha#reporter -- */ -- reporter(reporter?: string | Mocha.ReporterConstructor, reporterOptions?: any): this; -- -- /** -- * Set test UI to one of the built-in test interfaces. -- * -- * @see https://mochajs.org/api/mocha#ui -- */ -- ui(name: Mocha.Interface): this; -- -- /** -- * Set test UI to one of the built-in test interfaces or loads a test interface from a module -- * path. Defaults to `"bdd"`. -- * -- * @see https://mochajs.org/api/mocha#ui -- */ -- ui(name?: string): this; -- -- /** -- * Escape string and add it to grep as a RegExp. -- * -- * @see https://mochajs.org/api/mocha#fgrep -- */ -- fgrep(str: string): this; -- -- /** -- * Add regexp to grep, if `re` is a string it is escaped. -- * -- * @see https://mochajs.org/api/mocha#grep -- */ -- grep(re: string | RegExp): this; -- -- /** -- * Invert `.grep()` matches. -- * -- * @see https://mochajs.org/api/mocha#invert -- */ -- invert(): this; -- -- /** -- * Enable global leak checking. -- * -- * @see https://mochajs.org/api/mocha#checkLeaks -- */ -- checkLeaks(): this; -- -- /** -- * Display long stack-trace on failing -- * -- * @see https://mochajs.org/api/mocha#fullTrace -- */ -- fullTrace(): this; -- -- /** -- * Enable growl support. -- * -- * @see https://mochajs.org/api/mocha#growl -- */ -- growl(): this; -- -- /** -- * Ignore `globals` array or string. -- * -- * @see https://mochajs.org/api/mocha#globals -- */ -- globals(globals: string | ReadonlyArray): this; -- -- /** -- * Set the timeout in milliseconds. -- * -- * @see https://mochajs.org/api/mocha#timeout -- */ -- timeout(timeout: string | number): this; -- -- /** -- * Set the number of times to retry failed tests. -- * -- * @see https://mochajs.org/api/mocha#retries -- */ -- retries(n: number): this; -- -- /** -- * Set slowness threshold in milliseconds. -- * -- * @see https://mochajs.org/api/mocha#slow -- */ -- slow(slow: string | number): this; -- -- /** -- * Makes all tests async (accepting a callback) -- * -- * @see https://mochajs.org/api/mocha#asyncOnly. -- */ -- asyncOnly(): this; -- -- /** -- * Disable syntax highlighting (in browser). -- * -- * @see https://mochajs.org/api/mocha#noHighlighting -- */ -- noHighlighting(): this; -- -- /** -- * Enable uncaught errors to propagate (in browser). -- * -- * @see https://mochajs.org/api/mocha#allowUncaught -- */ -- allowUncaught(): boolean; -- -- /** -- * Delay root suite execution. -- * -- * @see https://mochajs.org/api/mocha#delay -- */ -- delay(): boolean; -- -- /** -- * Tests marked only fail the suite -- * -- * @see https://mochajs.org/api/mocha#forbidOnly -- */ -- forbidOnly(): boolean; -- -- /** -- * Pending tests and tests marked skip fail the suite -- * -- * @see https://mochajs.org/api/mocha#forbidPending -- */ -- forbidPending(): boolean; -- -- /** -- * Run tests and invoke `fn()` when complete. -- * -- * Note that `run` relies on Node's `require` to execute -- * the test interface functions and will be subject to the -- * cache - if the files are already in the `require` cache, -- * they will effectively be skipped. Therefore, to run tests -- * multiple times or to run tests in files that are already -- * in the `require` cache, make sure to clear them from the -- * cache first in whichever manner best suits your needs. -- * -- * @see https://mochajs.org/api/mocha#run -- */ -- run(fn?: (failures: number) => void): Mocha.Runner; -- -- /** -- * Loads ESM (and CJS) test files asynchronously. -- * -- * @see https://mochajs.org/api/mocha#loadFilesAsync -- */ -- loadFilesAsync(): Promise; -- -- /** -- * Load registered files. -- * -- * @see https://mochajs.org/api/mocha#loadFiles -- */ -- protected loadFiles(fn?: () => void): void; -- -- /** -- * Unloads `files` from Node's `require` cache. -- * -- * This allows required files to be "freshly" reloaded, providing the ability -- * to reuse a Mocha instance programmatically. -- * Note: does not clear ESM module files from the cache -- */ -- unloadFiles(): this; -- -- /** -- * Toggles parallel mode. -- * -- * Must be run before calling `run`. Changes the `Runner` class to -- * use; also enables lazy file loading if not already done so. -- * -- * @see https://mochajs.org/api/mocha#parallelMode -- */ -- parallelMode(enabled?: boolean): this; -- -- /** -- * Assigns hooks to the root suite. -- * -- * @see https://mochajs.org/api/mocha#rootHooks -- */ -- rootHooks(hooks: Mocha.RootHookObject): this; -- -- /** -- * Configures one or more global setup fixtures. -- * If given no parameters, unsets any previously-set fixtures. -- * -- * @see https://mochajs.org/api/mocha#globalSetup -- */ -- globalSetup: Mocha.HookFunction; -- -- /** -- * Configures one or more global teardown fixtures. -- * If given no parameters, unsets any previously-set fixtures. -- * -- * @see https://mochajs.org/api/mocha#globalTeardown -- */ -- globalTeardown: Mocha.HookFunction; -- -- /** -- * Returns `true` if one or more global setup fixtures have been supplied -- * -- * @see https://mochajs.org/api/mocha#hasGlobalSetupFixtures -- */ -- hasGlobalSetupFixtures(): boolean; -- -- /** -- * Returns `true` if one or more global teardown fixtures have been supplied -- * -- * @see https://mochajs.org/api/mocha#hasGlobalTeardownFixtures -- */ -- hasGlobalTeardownFixtures(): boolean; -- -- /** -- * Toggle execution of any global setup fixture(s) -- * -- * @see https://mochajs.org/api/mocha#enableGlobalSetup -- */ -- enableGlobalSetup(enabled: boolean): this; -- -- /** -- * Toggle execution of any global teardown fixture(s) -- * -- * @see https://mochajs.org/api/mocha#enableGlobalTeardown -- */ -- enableGlobalTeardown(enabled: boolean): this; --} -- --declare namespace Mocha { -- namespace utils { -- /** -- * Compute a slug from the given `str`. -- * -- * @see https://mochajs.org/api/module-utils.html#.slug -- */ -- function slug(str: string): string; -- -- /** -- * Strip the function definition from `str`, and re-indent for pre whitespace. -- * -- * @see https://mochajs.org/api/module-utils.html#.clean -- */ -- function clean(str: string): string; -- -- /** -- * Highlight the given string of `js`. -- */ -- function highlight(js: string): string; -- -- /** -- * Takes some variable and asks `Object.prototype.toString()` what it thinks it is. -- */ -- function type(value: any): string; -- -- /** -- * Stringify `value`. Different behavior depending on type of value: -- * -- * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively. -- * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes. -- * - If `value` is an *empty* object, function, or array, returns `'{}'`, `'[Function]'`, or `'[]'` respectively. -- * - If `value` has properties, call canonicalize} on it, then return result of `JSON.stringify()` -- * -- * @see https://mochajs.org/api/module-utils.html#.stringify -- */ -- function stringify(value: any): string; -- -- /** -- * Return a new Thing that has the keys in sorted order. Recursive. -- * -- * If the Thing... -- * - has already been seen, return string `'[Circular]'` -- * - is `undefined`, return string `'[undefined]'` -- * - is `null`, return value `null` -- * - is some other primitive, return the value -- * - is not a primitive or an `Array`, `Object`, or `Function`, return the value of the Thing's `toString()` method -- * - is a non-empty `Array`, `Object`, or `Function`, return the result of calling this function again. -- * - is an empty `Array`, `Object`, or `Function`, returns `'[]'`, `'{}'`, or `'[Function]'` respectively. -- * -- * @see https://mochajs.org/api/module-utils.html#.canonicalize -- */ -- function canonicalize(value: any, stack: any[], typeHint: string): any; -- -- /** -- * Lookup file names at the given `path`. -- * -- * @see https://mochajs.org/api/Mocha.utils.html#.exports.lookupFiles -- */ -- function lookupFiles(filepath: string, extensions?: string[], recursive?: boolean): string[]; -- -- /** -- * Generate an undefined error with a message warning the user. -- * -- * @see https://mochajs.org/api/module-utils.html#.undefinedError -- */ -- function undefinedError(): Error; -- -- /** -- * Generate an undefined error if `err` is not defined. -- * -- * @see https://mochajs.org/api/module-utils.html#.getError -- */ -- function getError(err: Error | undefined): Error; -- -- /** -- * When invoking this function you get a filter function that get the Error.stack as an -- * input, and return a prettify output. (i.e: strip Mocha and internal node functions from -- * stack trace). -- * -- * @see https://mochajs.org/api/module-utils.html#.stackTraceFilter -- */ -- function stackTraceFilter(): (stack: string) => string; -- } -- -- namespace interfaces { -- function bdd(suite: Suite): void; -- function tdd(suite: Suite): void; -- function qunit(suite: Suite): void; -- function exports(suite: Suite): void; -- } -- -- // #region Test interface augmentations -- -- interface HookFunction { -- /** -- * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the -- * function is used as the name of the hook. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (fn: Func): void; -- -- /** -- * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the -- * function is used as the name of the hook. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (fn: AsyncFunc): void; -- -- /** -- * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (name: string, fn?: Func): void; -- -- /** -- * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (name: string, fn?: AsyncFunc): void; -- } -- -- interface SuiteFunction { -- /** -- * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing -- * nested suites. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string, fn: (this: Suite) => void): Suite; -- -- /** -- * [qunit] Describe a "suite" with the given `title`. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string): Suite; -- -- /** -- * [bdd, tdd, qunit] Indicates this suite should be executed exclusively. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- only: ExclusiveSuiteFunction; -- -- /** -- * [bdd, tdd] Indicates this suite should not be executed. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- skip: PendingSuiteFunction; -- } -- -- interface ExclusiveSuiteFunction { -- /** -- * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing -- * nested suites. Indicates this suite should be executed exclusively. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string, fn: (this: Suite) => void): Suite; -- -- /** -- * [qunit] Describe a "suite" with the given `title`. Indicates this suite should be executed -- * exclusively. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string): Suite; -- } -- -- /** -- * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing -- * nested suites. Indicates this suite should not be executed. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @returns [bdd] `Suite` -- * @returns [tdd] `void` -- */ -- interface PendingSuiteFunction { -- (title: string, fn: (this: Suite) => void): Suite | void; -- } -- -- interface TestFunction { -- /** -- * Describe a specification or test-case with the given callback `fn` acting as a thunk. -- * The name of the function is used as the name of the test. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (fn: Func): Test; -- -- /** -- * Describe a specification or test-case with the given callback `fn` acting as a thunk. -- * The name of the function is used as the name of the test. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (fn: AsyncFunc): Test; -- -- /** -- * Describe a specification or test-case with the given `title` and callback `fn` acting -- * as a thunk. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string, fn?: Func): Test; -- -- /** -- * Describe a specification or test-case with the given `title` and callback `fn` acting -- * as a thunk. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string, fn?: AsyncFunc): Test; -- -- /** -- * Indicates this test should be executed exclusively. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- only: ExclusiveTestFunction; -- -- /** -- * Indicates this test should not be executed. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- skip: PendingTestFunction; -- -- /** -- * Number of attempts to retry. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- retries(n: number): void; -- } -- -- interface ExclusiveTestFunction { -- /** -- * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` -- * acting as a thunk. The name of the function is used as the name of the test. Indicates -- * this test should be executed exclusively. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (fn: Func): Test; -- -- /** -- * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` -- * acting as a thunk. The name of the function is used as the name of the test. Indicates -- * this test should be executed exclusively. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (fn: AsyncFunc): Test; -- -- /** -- * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and -- * callback `fn` acting as a thunk. Indicates this test should be executed exclusively. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string, fn?: Func): Test; -- -- /** -- * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and -- * callback `fn` acting as a thunk. Indicates this test should be executed exclusively. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string, fn?: AsyncFunc): Test; -- } -- -- interface PendingTestFunction { -- /** -- * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` -- * acting as a thunk. The name of the function is used as the name of the test. Indicates -- * this test should not be executed. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (fn: Func): Test; -- -- /** -- * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` -- * acting as a thunk. The name of the function is used as the name of the test. Indicates -- * this test should not be executed. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (fn: AsyncFunc): Test; -- -- /** -- * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and -- * callback `fn` acting as a thunk. Indicates this test should not be executed. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string, fn?: Func): Test; -- -- /** -- * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and -- * callback `fn` acting as a thunk. Indicates this test should not be executed. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- (title: string, fn?: AsyncFunc): Test; -- } -- -- /** -- * Execute after each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#afterEach -- */ -- let afterEach: HookFunction; -- -- /** -- * Execute after running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#after -- */ -- let after: HookFunction; -- -- /** -- * Execute before each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#beforeEach -- */ -- let beforeEach: HookFunction; -- -- /** -- * Execute before running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#before -- */ -- let before: HookFunction; -- -- /** -- * Describe a "suite" containing nested suites and tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- let describe: SuiteFunction; -- -- /** -- * Describes a test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- let it: TestFunction; -- -- /** -- * Describes a pending test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- let xit: PendingTestFunction; -- -- /** -- * Execute before each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#beforeEach -- */ -- let setup: HookFunction; -- -- /** -- * Execute before running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#before -- */ -- let suiteSetup: HookFunction; -- -- /** -- * Execute after running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#after -- */ -- let suiteTeardown: HookFunction; -- -- /** -- * Describe a "suite" containing nested suites and tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- let suite: SuiteFunction; -- -- /** -- * Execute after each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#afterEach -- */ -- let teardown: HookFunction; -- -- /** -- * Describes a test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- let test: TestFunction; -- -- /** -- * Triggers root suite execution. -- * -- * - _Only available if flag --delay is passed into Mocha._ -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#runWithSuite -- */ -- function run(): void; -- -- // #endregion Test interface augmentations -- -- namespace reporters { -- /** -- * Initialize a new `Base` reporter. -- * -- * All other reporters generally inherit from this reporter, providing stats such as test duration, -- * number of tests passed / failed, etc. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Base.html -- */ -- class Base { -- constructor(runner: Runner, options?: MochaOptions); -- -- /** -- * Test run statistics -- */ -- stats: Stats; -- -- /** -- * Test failures -- */ -- failures: Test[]; -- -- /** -- * The configured runner -- */ -- runner: Runner; -- -- /** -- * Output common epilogue used by many of the bundled reporters. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Base.html#.Base#epilogue -- */ -- epilogue(): void; -- -- done?(failures: number, fn?: (failures: number) => void): void; -- } -- -- namespace Base { -- /** -- * Enables coloring by default -- * -- * @see https://mochajs.org/api/module-base#.useColors -- */ -- let useColors: boolean; -- -- /** -- * Inline diffs instead of +/- -- * -- * @see https://mochajs.org/api/module-base#.inlineDiffs -- */ -- let inlineDiffs: boolean; -- -- /** -- * Default color map -- * -- * @see https://mochajs.org/api/module-base#.colors -- */ -- const colors: ColorMap; -- -- /** -- * Default color map -- * -- * @see https://mochajs.org/api/module-base#.colors -- */ -- interface ColorMap { -- // added by Base -- pass: number; -- fail: number; -- "bright pass": number; -- "bright fail": number; -- "bright yellow": number; -- pending: number; -- suite: number; -- "error title": number; -- "error message": number; -- "error stack": number; -- checkmark: number; -- fast: number; -- medium: number; -- slow: number; -- green: number; -- light: number; -- "diff gutter": number; -- "diff added": number; -- "diff removed": number; -- -- // added by Progress -- progress: number; -- -- // added by Landing -- plane: number; -- "plane crash": number; -- runway: number; -- -- [key: string]: number; -- } -- -- /** -- * Default symbol map -- * -- * @see https://mochajs.org/api/module-base#.symbols -- */ -- const symbols: SymbolMap; -- -- /** -- * Default symbol map -- * -- * @see https://mochajs.org/api/module-base#.symbols -- */ -- interface SymbolMap { -- ok: string; -- err: string; -- dot: string; -- comma: string; -- bang: string; -- [key: string]: string; -- } -- -- /** -- * Color `str` with the given `type` (from `colors`) -- * -- * @see https://mochajs.org/api/module-base#.color -- */ -- function color(type: string, str: string): string; -- -- /** -- * Expose terminal window size -- * -- * @see https://mochajs.org/api/module-base#.window -- */ -- const window: { -- width: number; -- }; -- -- /** -- * ANSI TTY control sequences common among reporters. -- * -- * @see https://mochajs.org/api/module-base#.cursor -- */ -- namespace cursor { -- /** -- * Hides the cursor -- */ -- function hide(): void; -- -- /** -- * Shows the cursor -- */ -- function show(): void; -- -- /** -- * Deletes the current line -- */ -- function deleteLine(): void; -- -- /** -- * Moves to the beginning of the line -- */ -- function beginningOfLine(): void; -- -- /** -- * Clears the line and moves to the beginning of the line. -- */ -- function CR(): void; -- } -- -- /** -- * Returns a diff between two strings with colored ANSI output. -- * -- * @see https://mochajs.org/api/module-base#.generateDiff -- */ -- function generateDiff(actual: string, expected: string): string; -- -- /** -- * Output the given `failures` as a list. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Base.html#.exports.list1 -- */ -- function list(failures: Test[]): void; -- } -- -- /** -- * Initialize a new `Dot` matrix test reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Dot.html -- */ -- class Dot extends Base { -- } -- -- /** -- * Initialize a new `Doc` reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Doc.html -- */ -- class Doc extends Base { -- } -- -- /** -- * Initialize a new `TAP` test reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.TAP.html -- */ -- class TAP extends Base { -- } -- -- /** -- * Initialize a new `JSON` reporter -- * -- * @see https://mochajs.org/api/Mocha.reporters.JSON.html -- */ -- class JSON extends Base { -- } -- -- /** -- * Initialize a new `HTML` reporter. -- * -- * - _This reporter cannot be used on the console._ -- * -- * @see https://mochajs.org/api/Mocha.reporters.HTML.html -- */ -- class HTML extends Base { -- /** -- * Provide suite URL. -- * -- * @see https://mochajs.org/api/Mocha.reporters.HTML.html#suiteURL -- */ -- suiteURL(suite: Suite): string; -- -- /** -- * Provide test URL. -- * -- * @see https://mochajs.org/api/Mocha.reporters.HTML.html#testURL -- */ -- testURL(test: Test): string; -- -- /** -- * Adds code toggle functionality for the provided test's list element. -- * -- * @see https://mochajs.org/api/Mocha.reporters.HTML.html#addCodeToggle -- */ -- addCodeToggle(el: HTMLLIElement, contents: string): void; -- } -- -- /** -- * Initialize a new `List` test reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.List.html -- */ -- class List extends Base { -- } -- -- /** -- * Initialize a new `Min` minimal test reporter (best used with --watch). -- * -- * @see https://mochajs.org/api/Mocha.reporters.Min.html -- */ -- class Min extends Base { -- } -- -- /** -- * Initialize a new `Spec` test reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Spec.html -- */ -- class Spec extends Base { -- } -- -- /** -- * Initialize a new `NyanCat` test reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Nyan.html -- */ -- class Nyan extends Base { -- private colorIndex; -- private numberOfLines; -- private rainbowColors; -- private scoreboardWidth; -- private tick; -- private trajectories; -- private trajectoryWidthMax; -- private draw; -- private drawScoreboard; -- private appendRainbow; -- private drawRainbow; -- private drawNyanCat; -- private face; -- private cursorUp; -- private cursorDown; -- private generateColors; -- private rainbowify; -- } -- -- /** -- * Initialize a new `XUnit` test reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.XUnit.html -- */ -- class XUnit extends Base { -- constructor(runner: Runner, options?: XUnit.MochaOptions); -- -- /** -- * Override done to close the stream (if it's a file). -- * -- * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#done -- */ -- done(failures: number, fn: (failures: number) => void): void; -- -- /** -- * Write out the given line. -- * -- * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#write -- */ -- write(line: string): void; -- -- /** -- * Output tag for the given `test.` -- * -- * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#test -- */ -- test(test: Test): void; -- } -- -- namespace XUnit { -- interface MochaOptions extends Mocha.MochaOptions { -- reporterOptions?: ReporterOptions; -- } -- -- interface ReporterOptions { -- output?: string; -- suiteName?: string; -- } -- } -- -- /** -- * Initialize a new `Markdown` test reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Markdown.html -- */ -- class Markdown extends Base { -- } -- -- /** -- * Initialize a new `Progress` bar test reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Progress.html -- */ -- class Progress extends Base { -- constructor(runner: Runner, options?: Progress.MochaOptions); -- } -- -- namespace Progress { -- interface MochaOptions extends Mocha.MochaOptions { -- reporterOptions?: ReporterOptions; -- } -- -- interface ReporterOptions { -- open?: string; -- complete?: string; -- incomplete?: string; -- close?: string; -- verbose?: boolean; -- } -- } -- -- /** -- * Initialize a new `Landing` reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.Landing.html -- */ -- class Landing extends Base { -- } -- -- /** -- * Initialize a new `JSONStream` test reporter. -- * -- * @see https://mochajs.org/api/Mocha.reporters.JSONStream.html -- */ -- class JSONStream extends Base { -- } -- -- // value-only aliases -- const base: typeof Base; -- const dot: typeof Dot; -- const doc: typeof Doc; -- const tap: typeof TAP; -- const json: typeof JSON; -- const html: typeof HTML; -- const list: typeof List; -- const spec: typeof Spec; -- const nyan: typeof Nyan; -- const xunit: typeof XUnit; -- const markdown: typeof Markdown; -- const progress: typeof Progress; -- const landing: typeof Landing; -- // NOTE: not possible to type this correctly: -- // const "json-stream": typeof JSONStream; -- } -- -- /** -- * Initialize a new `Runnable` with the given `title` and callback `fn`. -- * -- * @see https://mochajs.org/api/Runnable.html -- */ -- class Runnable { -- private _slow; -- private _retries; -- private _currentRetry; -- private _timeout; -- private _timeoutError; -- -- constructor(title: string, fn?: Func | AsyncFunc); -- -- title: string; -- fn: Func | AsyncFunc | undefined; -- body: string; -- async: boolean; -- sync: boolean; -- timedOut: boolean; -- pending: boolean; -- duration?: number; -- parent?: Suite; -- state?: "failed" | "passed"; -- timer?: any; -- ctx?: Context; -- callback?: Done; -- allowUncaught?: boolean; -- file?: string; -- -- /** -- * Get test timeout. -- * -- * @see https://mochajs.org/api/Runnable.html#timeout -- */ -- timeout(): number; -- -- /** -- * Set test timeout. -- * -- * @see https://mochajs.org/api/Runnable.html#timeout -- */ -- timeout(ms: string | number): this; -- -- /** -- * Get test slowness threshold. -- * -- * @see https://mochajs.org/api/Runnable.html#slow -- */ -- slow(): number; -- -- /** -- * Set test slowness threshold. -- * -- * @see https://mochajs.org/api/Runnable.html#slow -- */ -- slow(ms: string | number): this; -- -- /** -- * Halt and mark as pending. -- */ -- skip(): never; -- -- /** -- * Check if this runnable or its parent suite is marked as pending. -- * -- * @see https://mochajs.org/api/Runnable.html#isPending -- */ -- isPending(): boolean; -- -- /** -- * Return `true` if this Runnable has failed. -- */ -- isFailed(): boolean; -- -- /** -- * Return `true` if this Runnable has passed. -- */ -- isPassed(): boolean; -- -- /** -- * Set or get number of retries. -- * -- * @see https://mochajs.org/api/Runnable.html#retries -- */ -- retries(): number; -- -- /** -- * Set or get number of retries. -- * -- * @see https://mochajs.org/api/Runnable.html#retries -- */ -- retries(n: number): void; -- -- /** -- * Set or get current retry -- * -- * @see https://mochajs.org/api/Runnable.html#currentRetry -- */ -- protected currentRetry(): number; -- -- /** -- * Set or get current retry -- * -- * @see https://mochajs.org/api/Runnable.html#currentRetry -- */ -- protected currentRetry(n: number): void; -- -- /** -- * Return the full title generated by recursively concatenating the parent's full title. -- */ -- fullTitle(): string; -- -- /** -- * Return the title path generated by concatenating the parent's title path with the title. -- */ -- titlePath(): string[]; -- -- /** -- * Clear the timeout. -- * -- * @see https://mochajs.org/api/Runnable.html#clearTimeout -- */ -- clearTimeout(): void; -- -- /** -- * Inspect the runnable void of private properties. -- * -- * @see https://mochajs.org/api/Runnable.html#inspect -- */ -- inspect(): string; -- -- /** -- * Reset the timeout. -- * -- * @see https://mochajs.org/api/Runnable.html#resetTimeout -- */ -- resetTimeout(): void; -- -- /** -- * Get a list of whitelisted globals for this test run. -- * -- * @see https://mochajs.org/api/Runnable.html#globals -- */ -- globals(): string[]; -- -- /** -- * Set a list of whitelisted globals for this test run. -- * -- * @see https://mochajs.org/api/Runnable.html#globals -- */ -- globals(globals: ReadonlyArray): void; -- -- /** -- * Run the test and invoke `fn(err)`. -- * -- * @see https://mochajs.org/api/Runnable.html#run -- */ -- run(fn: Done): void; -- } -- -- // #region Runnable "error" event -- interface Runnable extends NodeJS.EventEmitter { -- on(event: "error", listener: (error: any) => void): this; -- once(event: "error", listener: (error: any) => void): this; -- addListener(event: "error", listener: (error: any) => void): this; -- removeListener(event: "error", listener: (error: any) => void): this; -- prependListener(event: "error", listener: (error: any) => void): this; -- prependOnceListener(event: "error", listener: (error: any) => void): this; -- emit(name: "error", error: any): boolean; -- } -- // #endregion Runnable "error" event -- // #region Runnable untyped events -- interface Runnable extends NodeJS.EventEmitter { -- on(event: string, listener: (...args: any[]) => void): this; -- once(event: string, listener: (...args: any[]) => void): this; -- addListener(event: string, listener: (...args: any[]) => void): this; -- removeListener(event: string, listener: (...args: any[]) => void): this; -- prependListener(event: string, listener: (...args: any[]) => void): this; -- prependOnceListener(event: string, listener: (...args: any[]) => void): this; -- emit(name: string, ...args: any[]): boolean; -- } -- // #endregion Runnable untyped events -- -- /** -- * Test context -- * -- * @see https://mochajs.org/api/module-Context.html#~Context -- */ -- class Context { -- private _runnable; -- -- test?: Runnable; -- currentTest?: Test; -- -- /** -- * Get the context `Runnable`. -- */ -- runnable(): Runnable; -- -- /** -- * Set the context `Runnable`. -- */ -- runnable(runnable: Runnable): this; -- -- /** -- * Get test timeout. -- */ -- timeout(): number; -- -- /** -- * Set test timeout. -- */ -- timeout(ms: string | number): this; -- -- /** -- * Get test slowness threshold. -- */ -- slow(): number; -- -- /** -- * Set test slowness threshold. -- */ -- slow(ms: string | number): this; -- -- /** -- * Mark a test as skipped. -- */ -- skip(): never; -- -- /** -- * Get the number of allowed retries on failed tests. -- */ -- retries(): number; -- -- /** -- * Set the number of allowed retries on failed tests. -- */ -- retries(n: number): this; -- -- [key: string]: any; -- } -- -- interface RunnerConstants { -- readonly EVENT_HOOK_BEGIN: 'hook'; -- readonly EVENT_HOOK_END: 'hook end'; -- readonly EVENT_RUN_BEGIN: 'start'; -- readonly EVENT_DELAY_BEGIN: 'waiting'; -- readonly EVENT_DELAY_END: 'ready'; -- readonly EVENT_RUN_END: 'end'; -- readonly EVENT_SUITE_BEGIN: 'suite'; -- readonly EVENT_SUITE_END: 'suite end'; -- readonly EVENT_TEST_BEGIN: 'test'; -- readonly EVENT_TEST_END: 'test end'; -- readonly EVENT_TEST_FAIL: 'fail'; -- readonly EVENT_TEST_PASS: 'pass'; -- readonly EVENT_TEST_PENDING: 'pending'; -- readonly EVENT_TEST_RETRY: 'retry'; -- readonly STATE_IDLE: 'idle'; -- readonly STATE_RUNNING: 'running'; -- readonly STATE_STOPPED: 'stopped'; -- } -- -- /** -- * Initialize a `Runner` for the given `suite`. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html -- */ -- class Runner { -- private _globals; -- private _abort; -- private _delay; -- private _defaultGrep; -- private next; -- private hookErr; -- private prevGlobalsLength; -- private nextSuite; -- -- static readonly constants: RunnerConstants; -- -- constructor(suite: Suite, delay: boolean); -- -- suite: Suite; -- started: boolean; -- total: number; -- failures: number; -- asyncOnly?: boolean; -- allowUncaught?: boolean; -- fullStackTrace?: boolean; -- forbidOnly?: boolean; -- forbidPending?: boolean; -- checkLeaks?: boolean; -- test?: Test; -- currentRunnable?: Runnable; -- stats?: Stats; // added by reporters -- -- /** -- * Removes all event handlers set during a run on this instance. -- * Remark: this does *not* clean/dispose the tests or suites themselves. -- * -- * @see https://mochajs.org/api/runner#dispose -- */ -- dispose(): void; -- -- /** -- * Run tests with full titles matching `re`. Updates runner.total -- * with number of tests matched. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grep -- */ -- grep(re: RegExp, invert: boolean): this; -- -- /** -- * Returns the number of tests matching the grep search for the -- * given suite. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grepTotal -- */ -- grepTotal(suite: Suite): number; -- -- /** -- * Gets the allowed globals. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals -- */ -- globals(): string[]; -- -- /** -- * Allow the given `arr` of globals. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals -- */ -- globals(arr: ReadonlyArray): this; -- -- /** -- * Run the root suite and invoke `fn(failures)` on completion. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#run -- */ -- run(fn?: (failures: number) => void): this; -- -- /** -- * Cleanly abort execution. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#abort -- */ -- abort(): this; -- -- /** -- * Handle uncaught exceptions. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#uncaught -- */ -- uncaught(err: any): void; -- -- /** -- * Wrapper for setImmediate, process.nextTick, or browser polyfill. -- */ -- protected static immediately(callback: Function): void; -- -- /** -- * Return a list of global properties. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#globalProps -- */ -- protected globalProps(): string[]; -- -- /** -- * Check for global variable leaks. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#checkGlobals -- */ -- protected checkGlobals(test: Test): void; -- -- /** -- * Fail the given `test`. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#fail -- */ -- protected fail(test: Test, err: any): void; -- -- /** -- * Fail the given `hook` with `err`. -- * -- * Hook failures work in the following pattern: -- * - If bail, then exit -- * - Failed `before` hook skips all tests in a suite and subsuites, -- * but jumps to corresponding `after` hook -- * - Failed `before each` hook skips remaining tests in a -- * suite and jumps to corresponding `after each` hook, -- * which is run only once -- * - Failed `after` hook does not alter -- * execution order -- * - Failed `after each` hook skips remaining tests in a -- * suite and subsuites, but executes other `after each` -- * hooks -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#failHook -- */ -- protected failHook(hook: Hook, err: any): void; -- -- /** -- * Run hook `name` callbacks and then invoke `fn()`. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#hook -- */ -- protected hook(name: string, fn: () => void): void; -- -- /** -- * Run hook `name` for the given array of `suites` -- * in order, and callback `fn(err, errSuite)`. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#hooks -- */ -- protected hooks(name: string, suites: Suite[], fn: (err?: any, errSuite?: Suite) => void): void; -- -- /** -- * Run hooks from the top level down. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#hookUp -- */ -- protected hookUp(name: string, fn: (err?: any, errSuite?: Suite) => void): void; -- -- /** -- * Run hooks from the bottom up. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#hookDown -- */ -- protected hookDown(name: string, fn: (err?: any, errSuite?: Suite) => void): void; -- -- /** -- * Return an array of parent Suites from closest to furthest. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#parents -- */ -- protected parents(): Suite[]; -- -- /** -- * Run the current test and callback `fn(err)`. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#runTest -- */ -- protected runTest(fn: Done): any; -- -- /** -- * Run tests in the given `suite` and invoke the callback `fn()` when complete. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#runTests -- */ -- protected runTests(suite: Suite, fn: (errSuite?: Suite) => void): void; -- -- /** -- * Run the given `suite` and invoke the callback `fn()` when complete. -- * -- * @see https://mochajs.org/api/Mocha.Runner.html#runSuite -- */ -- protected runSuite(suite: Suite, fn: (errSuite?: Suite) => void): void; -- } -- -- // #region Runner "waiting" event -- interface Runner { -- on(event: "waiting", listener: (rootSuite: Suite) => void): this; -- once(event: "waiting", listener: (rootSuite: Suite) => void): this; -- addListener(event: "waiting", listener: (rootSuite: Suite) => void): this; -- removeListener(event: "waiting", listener: (rootSuite: Suite) => void): this; -- prependListener(event: "waiting", listener: (rootSuite: Suite) => void): this; -- prependOnceListener(event: "waiting", listener: (rootSuite: Suite) => void): this; -- emit(name: "waiting", rootSuite: Suite): boolean; -- } -- // #endregion Runner "waiting" event -- // #region Runner "start" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "start", listener: () => void): this; -- once(event: "start", listener: () => void): this; -- addListener(event: "start", listener: () => void): this; -- removeListener(event: "start", listener: () => void): this; -- prependListener(event: "start", listener: () => void): this; -- prependOnceListener(event: "start", listener: () => void): this; -- emit(name: "start"): boolean; -- } -- // #endregion Runner "start" event -- // #region Runner "end" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "end", listener: () => void): this; -- once(event: "end", listener: () => void): this; -- addListener(event: "end", listener: () => void): this; -- removeListener(event: "end", listener: () => void): this; -- prependListener(event: "end", listener: () => void): this; -- prependOnceListener(event: "end", listener: () => void): this; -- emit(name: "end"): boolean; -- } -- // #endregion Runner "end" event -- // #region Runner "suite" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "suite", listener: (suite: Suite) => void): this; -- once(event: "suite", listener: (suite: Suite) => void): this; -- addListener(event: "suite", listener: (suite: Suite) => void): this; -- removeListener(event: "suite", listener: (suite: Suite) => void): this; -- prependListener(event: "suite", listener: (suite: Suite) => void): this; -- prependOnceListener(event: "suite", listener: (suite: Suite) => void): this; -- emit(name: "suite", suite: Suite): boolean; -- } -- // #endregion Runner "suite" event -- // #region Runner "suite end" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "suite end", listener: (suite: Suite) => void): this; -- once(event: "suite end", listener: (suite: Suite) => void): this; -- addListener(event: "suite end", listener: (suite: Suite) => void): this; -- removeListener(event: "suite end", listener: (suite: Suite) => void): this; -- prependListener(event: "suite end", listener: (suite: Suite) => void): this; -- prependOnceListener(event: "suite end", listener: (suite: Suite) => void): this; -- emit(name: "suite end", suite: Suite): boolean; -- } -- // #endregion Runner "suite end" event -- // #region Runner "test" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "test", listener: (test: Test) => void): this; -- once(event: "test", listener: (test: Test) => void): this; -- addListener(event: "test", listener: (test: Test) => void): this; -- removeListener(event: "test", listener: (test: Test) => void): this; -- prependListener(event: "test", listener: (test: Test) => void): this; -- prependOnceListener(event: "test", listener: (test: Test) => void): this; -- emit(name: "test", test: Test): boolean; -- } -- // #endregion Runner "test" event -- // #region Runner "test end" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "test end", listener: (test: Test) => void): this; -- once(event: "test end", listener: (test: Test) => void): this; -- addListener(event: "test end", listener: (test: Test) => void): this; -- removeListener(event: "test end", listener: (test: Test) => void): this; -- prependListener(event: "test end", listener: (test: Test) => void): this; -- prependOnceListener(event: "test end", listener: (test: Test) => void): this; -- emit(name: "test end", test: Test): boolean; -- } -- // #endregion Runner "test end" event -- // #region Runner "hook" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "hook", listener: (hook: Hook) => void): this; -- once(event: "hook", listener: (hook: Hook) => void): this; -- addListener(event: "hook", listener: (hook: Hook) => void): this; -- removeListener(event: "hook", listener: (hook: Hook) => void): this; -- prependListener(event: "hook", listener: (hook: Hook) => void): this; -- prependOnceListener(event: "hook", listener: (hook: Hook) => void): this; -- emit(name: "hook", hook: Hook): boolean; -- } -- // #endregion Runner "hook" event -- // #region Runner "hook end" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "hook end", listener: (hook: Hook) => void): this; -- once(event: "hook end", listener: (hook: Hook) => void): this; -- addListener(event: "hook end", listener: (hook: Hook) => void): this; -- removeListener(event: "hook end", listener: (hook: Hook) => void): this; -- prependListener(event: "hook end", listener: (hook: Hook) => void): this; -- prependOnceListener(event: "hook end", listener: (hook: Hook) => void): this; -- emit(name: "hook end", hook: Hook): boolean; -- } -- // #endregion Runner "hook end" event -- // #region Runner "pass" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "pass", listener: (test: Test) => void): this; -- once(event: "pass", listener: (test: Test) => void): this; -- addListener(event: "pass", listener: (test: Test) => void): this; -- removeListener(event: "pass", listener: (test: Test) => void): this; -- prependListener(event: "pass", listener: (test: Test) => void): this; -- prependOnceListener(event: "pass", listener: (test: Test) => void): this; -- emit(name: "pass", test: Test): boolean; -- } -- // #endregion Runner "pass" event -- // #region Runner "fail" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "fail", listener: (test: Test, err: any) => void): this; -- once(event: "fail", listener: (test: Test, err: any) => void): this; -- addListener(event: "fail", listener: (test: Test, err: any) => void): this; -- removeListener(event: "fail", listener: (test: Test, err: any) => void): this; -- prependListener(event: "fail", listener: (test: Test, err: any) => void): this; -- prependOnceListener(event: "fail", listener: (test: Test, err: any) => void): this; -- emit(name: "fail", test: Test, err: any): boolean; -- } -- // #endregion Runner "fail" event -- // #region Runner "pending" event -- interface Runner extends NodeJS.EventEmitter { -- on(event: "pending", listener: (test: Test) => void): this; -- once(event: "pending", listener: (test: Test) => void): this; -- addListener(event: "pending", listener: (test: Test) => void): this; -- removeListener(event: "pending", listener: (test: Test) => void): this; -- prependListener(event: "pending", listener: (test: Test) => void): this; -- prependOnceListener(event: "pending", listener: (test: Test) => void): this; -- emit(name: "pending", test: Test): boolean; -- } -- // #endregion Runner "pending" event -- // #region Runner untyped events -- interface Runner extends NodeJS.EventEmitter { -- on(event: string, listener: (...args: any[]) => void): this; -- once(event: string, listener: (...args: any[]) => void): this; -- addListener(event: string, listener: (...args: any[]) => void): this; -- removeListener(event: string, listener: (...args: any[]) => void): this; -- prependListener(event: string, listener: (...args: any[]) => void): this; -- prependOnceListener(event: string, listener: (...args: any[]) => void): this; -- emit(name: string, ...args: any[]): boolean; -- } -- // #endregion Runner untyped events -- -- interface SuiteConstants { -- readonly EVENT_FILE_POST_REQUIRE: 'post-require'; -- readonly EVENT_FILE_PRE_REQUIRE: 'pre-require'; -- readonly EVENT_FILE_REQUIRE: 'require'; -- readonly EVENT_ROOT_SUITE_RUN: 'run'; -- -- readonly HOOK_TYPE_AFTER_ALL: 'afterAll'; -- readonly HOOK_TYPE_AFTER_EACH: 'afterEach'; -- readonly HOOK_TYPE_BEFORE_ALL: 'beforeAll'; -- readonly HOOK_TYPE_BEFORE_EACH: 'beforeEach'; -- -- readonly EVENT_SUITE_ADD_HOOK_AFTER_ALL: 'afterAll'; -- readonly EVENT_SUITE_ADD_HOOK_AFTER_EACH: 'afterEach'; -- readonly EVENT_SUITE_ADD_HOOK_BEFORE_ALL: 'beforeAll'; -- readonly EVENT_SUITE_ADD_HOOK_BEFORE_EACH: 'beforeEach'; -- readonly EVENT_SUITE_ADD_SUITE: 'suite'; -- readonly EVENT_SUITE_ADD_TEST: 'test'; -- } -- -- /** -- * Initialize a new `Suite` with the given `title` and `ctx`. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html -- */ -- class Suite { -- private _beforeEach; -- private _beforeAll; -- private _afterEach; -- private _afterAll; -- private _timeout; -- private _slow; -- private _bail; -- private _retries; -- private _onlyTests; -- private _onlySuites; -- -- static readonly constants: SuiteConstants; -- -- constructor(title: string, parentContext?: Context); -- -- ctx: Context; -- suites: Suite[]; -- tests: Test[]; -- pending: boolean; -- file?: string; -- root: boolean; -- delayed: boolean; -- parent: Suite | undefined; -- title: string; -- -- /** -- * Create a new `Suite` with the given `title` and parent `Suite`. When a suite -- * with the same title is already present, that suite is returned to provide -- * nicer reporter and more flexible meta-testing. -- * -- * @see https://mochajs.org/api/mocha#.exports.create -- */ -- static create(parent: Suite, title: string): Suite; -- -- /** -- * Return a clone of this `Suite`. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#clone -- */ -- clone(): Suite; -- -- /** -- * Get timeout `ms`. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#timeout -- */ -- timeout(): number; -- -- /** -- * Set timeout `ms` or short-hand such as "2s". -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#timeout -- */ -- timeout(ms: string | number): this; -- -- /** -- * Get number of times to retry a failed test. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#retries -- */ -- retries(): number; -- -- /** -- * Set number of times to retry a failed test. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#retries -- */ -- retries(n: string | number): this; -- -- /** -- * Get slow `ms`. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#slow -- */ -- slow(): number; -- -- /** -- * Set slow `ms` or short-hand such as "2s". -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#slow -- */ -- slow(ms: string | number): this; -- -- /** -- * Get whether to bail after first error. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#bail -- */ -- bail(): boolean; -- -- /** -- * Set whether to bail after first error. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#bail -- */ -- bail(bail: boolean): this; -- -- /** -- * Check if this suite or its parent suite is marked as pending. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#isPending -- */ -- isPending(): boolean; -- -- /** -- * Run `fn(test[, done])` before running tests. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll -- */ -- beforeAll(fn?: Func): this; -- -- /** -- * Run `fn(test[, done])` before running tests. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll -- */ -- beforeAll(fn?: AsyncFunc): this; -- -- /** -- * Run `fn(test[, done])` before running tests. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll -- */ -- beforeAll(title: string, fn?: Func): this; -- -- /** -- * Run `fn(test[, done])` before running tests. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll -- */ -- beforeAll(title: string, fn?: AsyncFunc): this; -- -- /** -- * Run `fn(test[, done])` after running tests. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#afterAll -- */ -- afterAll(fn?: Func): this; -- -- /** -- * Run `fn(test[, done])` after running tests. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#afterAll -- */ -- afterAll(fn?: AsyncFunc): this; -- -- /** -- * Run `fn(test[, done])` after running tests. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#afterAll -- */ -- afterAll(title: string, fn?: Func): this; -- -- /** -- * Run `fn(test[, done])` after running tests. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#afterAll -- */ -- afterAll(title: string, fn?: AsyncFunc): this; -- -- /** -- * Run `fn(test[, done])` before each test case. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach -- */ -- beforeEach(fn?: Func): this; -- -- /** -- * Run `fn(test[, done])` before each test case. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach -- */ -- beforeEach(fn?: AsyncFunc): this; -- -- /** -- * Run `fn(test[, done])` before each test case. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach -- */ -- beforeEach(title: string, fn?: Func): this; -- -- /** -- * Run `fn(test[, done])` before each test case. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach -- */ -- beforeEach(title: string, fn?: AsyncFunc): this; -- -- /** -- * Run `fn(test[, done])` after each test case. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#afterEach -- */ -- afterEach(fn?: Func): this; -- -- /** -- * Run `fn(test[, done])` after each test case. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#afterEach -- */ -- afterEach(fn?: AsyncFunc): this; -- -- /** -- * Run `fn(test[, done])` after each test case. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#afterEach -- */ -- afterEach(title: string, fn?: Func): this; -- -- /** -- * Run `fn(test[, done])` after each test case. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#afterEach -- */ -- afterEach(title: string, fn?: AsyncFunc): this; -- -- /** -- * Add a test `suite`. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#addSuite -- */ -- addSuite(suite: Suite): this; -- -- /** -- * Add a `test` to this suite. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#addTest -- */ -- addTest(test: Test): this; -- -- /** -- * Cleans all references from this suite and all child suites. -- * -- * https://mochajs.org/api/suite#dispose -- */ -- dispose(): void; -- -- /** -- * Return the full title generated by recursively concatenating the parent's -- * full title. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#fullTitle -- */ -- fullTitle(): string; -- -- /** -- * Return the title path generated by recursively concatenating the parent's -- * title path. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#titlePath -- */ -- titlePath(): string[]; -- -- /** -- * Return the total number of tests. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#total -- */ -- total(): number; -- -- /** -- * Iterates through each suite recursively to find all tests. Applies a -- * function in the format `fn(test)`. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#eachTest -- */ -- eachTest(fn: (test: Test) => void): this; -- -- /** -- * This will run the root suite if we happen to be running in delayed mode. -- * -- * @see https://mochajs.org/api/Mocha.Suite.html#run -- */ -- run(): void; -- -- /** -- * Generic hook-creator. -- */ -- protected _createHook(title: string, fn?: Func | AsyncFunc): Hook; -- } -- -- // #region Suite "beforeAll" event -- interface Suite extends NodeJS.EventEmitter { -- on(event: "beforeAll", listener: (hook: Hook) => void): this; -- once(event: "beforeAll", listener: (hook: Hook) => void): this; -- addListener(event: "beforeAll", listener: (hook: Hook) => void): this; -- removeListener(event: "beforeAll", listener: (hook: Hook) => void): this; -- prependListener(event: "beforeAll", listener: (hook: Hook) => void): this; -- prependOnceListener(event: "beforeAll", listener: (hook: Hook) => void): this; -- emit(name: "beforeAll", hook: Hook): boolean; -- } -- // #endregion Suite "beforeAll" event -- // #region Suite "afterAll" event -- interface Suite extends NodeJS.EventEmitter { -- on(event: "afterAll", listener: (hook: Hook) => void): this; -- once(event: "afterAll", listener: (hook: Hook) => void): this; -- addListener(event: "afterAll", listener: (hook: Hook) => void): this; -- removeListener(event: "afterAll", listener: (hook: Hook) => void): this; -- prependListener(event: "afterAll", listener: (hook: Hook) => void): this; -- prependOnceListener(event: "afterAll", listener: (hook: Hook) => void): this; -- emit(name: "afterAll", hook: Hook): boolean; -- } -- // #endregion Suite "afterAll" event -- // #region Suite "beforeEach" event -- interface Suite extends NodeJS.EventEmitter { -- on(event: "beforeEach", listener: (hook: Hook) => void): this; -- once(event: "beforeEach", listener: (hook: Hook) => void): this; -- addListener(event: "beforeEach", listener: (hook: Hook) => void): this; -- removeListener(event: "beforeEach", listener: (hook: Hook) => void): this; -- prependListener(event: "beforeEach", listener: (hook: Hook) => void): this; -- prependOnceListener(event: "beforeEach", listener: (hook: Hook) => void): this; -- emit(name: "beforeEach", hook: Hook): boolean; -- } -- // #endregion Suite "beforeEach" event -- // #region Suite "afterEach" event -- interface Suite extends NodeJS.EventEmitter { -- on(event: "afterEach", listener: (hook: Hook) => void): this; -- once(event: "afterEach", listener: (hook: Hook) => void): this; -- addListener(event: "afterEach", listener: (hook: Hook) => void): this; -- removeListener(event: "afterEach", listener: (hook: Hook) => void): this; -- prependListener(event: "afterEach", listener: (hook: Hook) => void): this; -- prependOnceListener(event: "afterEach", listener: (hook: Hook) => void): this; -- emit(name: "afterEach", hook: Hook): boolean; -- } -- // #endregion Suite "afterEach" event -- // #region Suite "suite" event -- interface Suite extends NodeJS.EventEmitter { -- on(event: "suite", listener: (suite: Suite) => void): this; -- once(event: "suite", listener: (suite: Suite) => void): this; -- addListener(event: "suite", listener: (suite: Suite) => void): this; -- removeListener(event: "suite", listener: (suite: Suite) => void): this; -- prependListener(event: "suite", listener: (suite: Suite) => void): this; -- prependOnceListener(event: "suite", listener: (suite: Suite) => void): this; -- emit(name: "suite", suite: Suite): boolean; -- } -- // #endregion Suite "suite" event -- // #region Suite "test" event -- interface Suite { -- on(event: "test", listener: (test: Test) => void): this; -- once(event: "test", listener: (test: Test) => void): this; -- addListener(event: "test", listener: (test: Test) => void): this; -- removeListener(event: "test", listener: (test: Test) => void): this; -- prependListener(event: "test", listener: (test: Test) => void): this; -- prependOnceListener(event: "test", listener: (test: Test) => void): this; -- emit(name: "test", test: Test): boolean; -- } -- // #endregion Suite "test" event -- // #region Suite "run" event -- interface Suite extends NodeJS.EventEmitter { -- on(event: "run", listener: () => void): this; -- once(event: "run", listener: () => void): this; -- addListener(event: "run", listener: () => void): this; -- removeListener(event: "run", listener: () => void): this; -- prependListener(event: "run", listener: () => void): this; -- prependOnceListener(event: "run", listener: () => void): this; -- emit(name: "run"): boolean; -- } -- // #endregion Suite "run" event -- // #region Suite "pre-require" event -- interface Suite extends NodeJS.EventEmitter { -- on(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- once(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- addListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- removeListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- prependListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- prependOnceListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- emit(name: "pre-require", context: MochaGlobals, file: string, mocha: Mocha): boolean; -- } -- // #endregion Suite "pre-require" event -- // #region Suite "require" event -- interface Suite extends NodeJS.EventEmitter { -- on(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -- once(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -- addListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -- removeListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -- prependListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -- prependOnceListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -- emit(name: "require", module: any, file: string, mocha: Mocha): boolean; -- } -- // #endregion Suite "require" event -- // #region Suite "post-require" event -- interface Suite extends NodeJS.EventEmitter { -- on(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- once(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- addListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- removeListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- prependListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- prependOnceListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -- emit(name: "post-require", context: MochaGlobals, file: string, mocha: Mocha): boolean; -- } -- // #endregion Suite "post-require" event -- // #region Suite untyped events -- interface Suite extends NodeJS.EventEmitter { -- on(event: string, listener: (...args: any[]) => void): this; -- once(event: string, listener: (...args: any[]) => void): this; -- addListener(event: string, listener: (...args: any[]) => void): this; -- removeListener(event: string, listener: (...args: any[]) => void): this; -- prependListener(event: string, listener: (...args: any[]) => void): this; -- prependOnceListener(event: string, listener: (...args: any[]) => void): this; -- emit(name: string, ...args: any[]): boolean; -- } -- // #endregion Runner untyped events -- -- /** -- * Initialize a new `Hook` with the given `title` and callback `fn` -- * -- * @see https://mochajs.org/api/Hook.html -- */ -- class Hook extends Runnable { -- private _error; -- -- type: "hook"; -- originalTitle?: string; // added by Runner -- -- /** -- * Get the test `err`. -- * -- * @see https://mochajs.org/api/Hook.html#error -- */ -- error(): any; -- -- /** -- * Set the test `err`. -- * -- * @see https://mochajs.org/api/Hook.html#error -- */ -- error(err: any): void; -- } -- -- /** -- * An alternative way to define root hooks that works with parallel runs. -- * -- * Root hooks work with any interface, but the property names do not change. -- * In other words, if you are using the tdd interface, suiteSetup maps to beforeAll, and setup maps to beforeEach. -- * -- * As with other hooks, `this` refers to to the current context object. -- * -- * @see https://mochajs.org/#root-hook-plugins -- */ -- interface RootHookObject { -- /** -- * In serial mode, run after all tests end, once only. -- * In parallel mode, run after all tests end, for each file. -- */ -- afterAll?: Func | AsyncFunc | Func[] | AsyncFunc[]; -- /** -- * In serial mode (Mocha's default), before all tests begin, once only. -- * In parallel mode, run before all tests begin, for each file. -- */ -- beforeAll?: Func | AsyncFunc | Func[] | AsyncFunc[]; -- /** -- * In both modes, run after every test. -- */ -- afterEach?: Func | AsyncFunc | Func[] | AsyncFunc[]; -- /** -- * In both modes, run before each test. -- */ -- beforeEach?: Func | AsyncFunc | Func[] | AsyncFunc[]; -- } -- -- /** -- * Initialize a new `Test` with the given `title` and callback `fn`. -- * -- * @see https://mochajs.org/api/Test.html -- */ -- class Test extends Runnable { -- type: "test"; -- speed?: "slow" | "medium" | "fast"; // added by reporters -- err?: Error; // added by reporters -- clone(): Test; -- } -- -- /** -- * Test statistics -- */ -- interface Stats { -- suites: number; -- tests: number; -- passes: number; -- pending: number; -- failures: number; -- start?: Date; -- end?: Date; -- duration?: number; -- } -- -- type TestInterface = (suite: Suite) => void; -- -- interface ReporterConstructor { -- new (runner: Runner, options: MochaOptions): reporters.Base; -- } -- -- type Done = (err?: any) => void; -- -- /** -- * Callback function used for tests and hooks. -- */ -- type Func = (this: Context, done: Done) => void; -- -- /** -- * Async callback function used for tests and hooks. -- */ -- type AsyncFunc = (this: Context) => PromiseLike; -- -- /** -- * Options to pass to Mocha. -- */ -- interface MochaOptions { -- /** Test interfaces ("bdd", "tdd", "exports", etc.). */ -- ui?: Interface; -- -- /** -- * Reporter constructor, built-in reporter name, or reporter module path. Defaults to -- * `"spec"`. -- */ -- reporter?: string | ReporterConstructor; -- -- /** Options to pass to the reporter. */ -- reporterOptions?: any; -- -- /** Array of accepted globals. */ -- globals?: string[]; -- -- /** timeout in milliseconds or time string like '1s'. */ -- timeout?: number | string; -- -- /** number of times to retry failed tests. */ -- retries?: number; -- -- /** bail on the first test failure. */ -- bail?: boolean; -- -- /** milliseconds to wait before considering a test slow. */ -- slow?: number; -- -- /** check for global variable leaks. */ -- checkLeaks?: boolean; -- -- /** display the full stack trace on failure. */ -- fullStackTrace?: boolean; -- -- /** string or regexp to filter tests with. */ -- grep?: string | RegExp; -- -- /** Enable growl support. */ -- growl?: boolean; -- -- /** Color TTY output from reporter */ -- color?: boolean; -- -- /** Use inline diffs rather than +/-. */ -- inlineDiffs?: boolean; -- -- /** Do not show diffs at all. */ -- hideDiff?: boolean; -- -- /** Run job in parallel */ -- parallel?: boolean; -- -- /** Max number of worker processes for parallel runs */ -- jobs?: number; -- -- /** Assigns hooks to the root suite */ -- rootHooks?: RootHookObject; -- -- asyncOnly?: boolean; -- delay?: boolean; -- forbidOnly?: boolean; -- forbidPending?: boolean; -- noHighlighting?: boolean; -- allowUncaught?: boolean; -- fullTrace?: boolean; -- } -- -- interface MochaInstanceOptions extends MochaOptions { -- files?: string[]; -- } -- -- /** -- * Variables added to the global scope by Mocha when run in the CLI. -- */ -- interface MochaGlobals { -- /** -- * Execute before running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#before -- */ -- before: HookFunction; -- -- /** -- * Execute after running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#after -- */ -- after: HookFunction; -- -- /** -- * Execute before each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#beforeEach -- */ -- beforeEach: HookFunction; -- -- /** -- * Execute after each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#afterEach -- */ -- afterEach: HookFunction; -- -- /** -- * Describe a "suite" containing nested suites and tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- describe: SuiteFunction; -- -- /** -- * Describe a "suite" containing nested suites and tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- context: SuiteFunction; -- -- /** -- * Pending suite. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- xdescribe: PendingSuiteFunction; -- -- /** -- * Pending suite. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- xcontext: PendingSuiteFunction; -- -- /** -- * Describes a test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- it: TestFunction; -- -- /** -- * Describes a test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- specify: TestFunction; -- -- /** -- * Describes a pending test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- xit: PendingTestFunction; -- -- /** -- * Describes a pending test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- xspecify: PendingTestFunction; -- -- /** -- * Execute before running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#before -- */ -- suiteSetup: HookFunction; -- -- /** -- * Execute after running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#after -- */ -- suiteTeardown: HookFunction; -- -- /** -- * Execute before each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#beforeEach -- */ -- setup: HookFunction; -- -- /** -- * Execute after each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#afterEach -- */ -- teardown: HookFunction; -- -- /** -- * Describe a "suite" containing nested suites and tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- suite: SuiteFunction; -- -- /** -- * Describes a test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ -- test: TestFunction; -- -- run: typeof run; -- } -- -- /** -- * Third-party declarations that want to add new entries to the `Reporter` union can -- * contribute names here. -- */ -- interface ReporterContributions { -- Base: never; -- base: never; -- Dot: never; -- dot: never; -- TAP: never; -- tap: never; -- JSON: never; -- json: never; -- HTML: never; -- html: never; -- List: never; -- list: never; -- Min: never; -- min: never; -- Spec: never; -- spec: never; -- Nyan: never; -- nyan: never; -- XUnit: never; -- xunit: never; -- Markdown: never; -- markdown: never; -- Progress: never; -- progress: never; -- Landing: never; -- landing: never; -- JSONStream: never; -- "json-stream": never; -- } -- -- type Reporter = keyof ReporterContributions; -- -- /** -- * Third-party declarations that want to add new entries to the `Interface` union can -- * contribute names here. -- */ -- interface InterfaceContributions { -- bdd: never; -- tdd: never; -- qunit: never; -- exports: never; -- } -- -- type Interface = keyof InterfaceContributions; --} -- --// #region Test interface augmentations -- --/** -- * Triggers root suite execution. -- * -- * - _Only available if flag --delay is passed into Mocha._ -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#runWithSuite -- */ --declare function run(): void; -- --/** -- * Execute before running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#before -- */ --declare var before: Mocha.HookFunction; -- --/** -- * Execute before running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#before -- */ --declare var suiteSetup: Mocha.HookFunction; -- --/** -- * Execute after running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#after -- */ --declare var after: Mocha.HookFunction; -- --/** -- * Execute after running tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#after -- */ --declare var suiteTeardown: Mocha.HookFunction; -- --/** -- * Execute before each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#beforeEach -- */ --declare var beforeEach: Mocha.HookFunction; -- --/** -- * Execute before each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#beforeEach -- */ --declare var setup: Mocha.HookFunction; -- --/** -- * Execute after each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#afterEach -- */ --declare var afterEach: Mocha.HookFunction; -- --/** -- * Execute after each test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- * -- * @see https://mochajs.org/api/global.html#afterEach -- */ --declare var teardown: Mocha.HookFunction; -- --/** -- * Describe a "suite" containing nested suites and tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var describe: Mocha.SuiteFunction; -- --/** -- * Describe a "suite" containing nested suites and tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var context: Mocha.SuiteFunction; -- --/** -- * Describe a "suite" containing nested suites and tests. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var suite: Mocha.SuiteFunction; -- --/** -- * Pending suite. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var xdescribe: Mocha.PendingSuiteFunction; -- --/** -- * Pending suite. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var xcontext: Mocha.PendingSuiteFunction; -- --/** -- * Describes a test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var it: Mocha.TestFunction; -- --/** -- * Describes a test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var specify: Mocha.TestFunction; -- --/** -- * Describes a test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var test: Mocha.TestFunction; -- --/** -- * Describes a pending test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var xit: Mocha.PendingTestFunction; -- --/** -- * Describes a pending test case. -- * -- * - _Only available when invoked via the mocha CLI._ -- */ --declare var xspecify: Mocha.PendingTestFunction; -- --// #endregion Test interface augmentations -- --// #region Reporter augmentations -- --// Forward declaration for `HTMLLIElement` from lib.dom.d.ts. --// Required by Mocha.reporters.HTML. --// NOTE: Mocha *must not* have a direct dependency on DOM types. --// tslint:disable-next-line no-empty-interface --interface HTMLLIElement { } -- --// Augments the DOM `Window` object when lib.dom.d.ts is loaded. --// tslint:disable-next-line no-empty-interface --interface Window extends Mocha.MochaGlobals { } -- --declare namespace NodeJS { -- // Forward declaration for `NodeJS.EventEmitter` from node.d.ts. -- // Required by Mocha.Runnable, Mocha.Runner, and Mocha.Suite. -- // NOTE: Mocha *must not* have a direct dependency on @types/node. -- // tslint:disable-next-line no-empty-interface -- interface EventEmitter { } -- -- // Augments NodeJS's `global` object when node.d.ts is loaded -- // tslint:disable-next-line no-empty-interface -- interface Global extends Mocha.MochaGlobals { } --} -- --// #endregion Reporter augmentations -- --// #region Browser augmentations -- --/** -- * Mocha global. -- * -- * - _Only supported in the browser._ -- */ --declare const mocha: BrowserMocha; -- --interface BrowserMocha extends Mocha { -- /** -- * Function to allow assertion libraries to throw errors directly into mocha. -- * This is useful when running tests in a browser because window.onerror will -- * only receive the 'message' attribute of the Error. -- * -- * - _Only supported in the browser._ -- */ -- throwError(err: any): never; -- -- /** -- * Setup mocha with the given settings options. -- * -- * - _Only supported in the browser._ -- */ -- setup(opts?: Mocha.Interface | Mocha.MochaOptions): this; --} -- --// #endregion Browser augmentations -- --declare module "mocha" { -- export = Mocha; --} -- --declare module "mocha/lib/stats-collector" { -- export = createStatsCollector; -- -- /** -- * Provides stats such as test duration, number of tests passed / failed etc., by listening for events emitted by `runner`. -- */ -- function createStatsCollector(runner: Mocha.Runner): void; -- } -- --declare module "mocha/lib/interfaces/common" { -- export = common; -- -- function common(suites: Mocha.Suite[], context: Mocha.MochaGlobals, mocha: Mocha): common.CommonFunctions; -- -- namespace common { -- interface CommonFunctions { -- /** -- * This is only present if flag --delay is passed into Mocha. It triggers -- * root suite execution. -- */ -- runWithSuite(suite: Mocha.Suite): () => void; -- -- /** -- * Execute before running tests. -- */ -- before(fn?: Mocha.Func | Mocha.AsyncFunc): void; -- -- /** -- * Execute before running tests. -- */ -- before(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; -- -- /** -- * Execute after running tests. -- */ -- after(fn?: Mocha.Func | Mocha.AsyncFunc): void; -- -- /** -- * Execute after running tests. -- */ -- after(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; -- -- /** -- * Execute before each test case. -- */ -- beforeEach(fn?: Mocha.Func | Mocha.AsyncFunc): void; -- -- /** -- * Execute before each test case. -- */ -- beforeEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; -- -- /** -- * Execute after each test case. -- */ -- afterEach(fn?: Mocha.Func | Mocha.AsyncFunc): void; -- -- /** -- * Execute after each test case. -- */ -- afterEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; -- -- suite: SuiteFunctions; -- test: TestFunctions; -- } -- -- interface CreateOptions { -- /** Title of suite */ -- title: string; -- -- /** Suite function */ -- fn?: (this: Mocha.Suite) => void; -- -- /** Is suite pending? */ -- pending?: boolean; -- -- /** Filepath where this Suite resides */ -- file?: string; -- -- /** Is suite exclusive? */ -- isOnly?: boolean; -- } -- -- interface SuiteFunctions { -- /** -- * Create an exclusive Suite; convenience function -- */ -- only(opts: CreateOptions): Mocha.Suite; -- -- /** -- * Create a Suite, but skip it; convenience function -- */ -- skip(opts: CreateOptions): Mocha.Suite; -- -- /** -- * Creates a suite. -- */ -- create(opts: CreateOptions): Mocha.Suite; -- } -- -- interface TestFunctions { -- /** -- * Exclusive test-case. -- */ -- only(mocha: Mocha, test: Mocha.Test): Mocha.Test; -- -- /** -- * Pending test case. -- */ -- skip(title: string): void; -- -- /** -- * Number of retry attempts -- */ -- retries(n: number): void; -- } -- } --} -+// // Type definitions for mocha 8.2 -+// // Project: https://mochajs.org -+// // Definitions by: Kazi Manzur Rashid -+// // otiai10 -+// // Vadim Macagon -+// // Andrew Bradley -+// // Dmitrii Sorin -+// // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -+// // TypeScript Version: 2.1 -+ -+// /** -+// * Mocha API -+// * -+// * @see https://mochajs.org/api/mocha -+// */ -+// declare class Mocha { -+// private _growl; -+// private _reporter; -+// private _ui; -+ -+// constructor(options?: Mocha.MochaOptions); -+ -+// suite: Mocha.Suite; -+// files: string[]; -+// options: Mocha.MochaInstanceOptions; -+ -+// /** -+// * Add test `file`. -+// * -+// * @see https://mochajs.org/api/mocha#addFile -+// */ -+// addFile(file: string): this; -+ -+// /** -+// * Enable or disable bailing on the first failure. -+// * -+// * @see https://mochajs.org/api/mocha#bail -+// */ -+// bail(bail?: boolean): this; -+ -+// /** -+// * Manually dispose this mocha instance. Mark this instance as `disposed` and unable to run more tests. -+// * It also removes function references to tests functions and hooks, so variables trapped in closures can be cleaned by the garbage collector. -+// * -+// * @see https://mochajs.org/api/mocha#dispose -+// */ -+// dispose(): void; -+ -+// /** -+// * Set reporter to one of the built-in reporters. -+// * -+// * @see https://mochajs.org/api/mocha#reporter -+// */ -+// reporter(reporter: Mocha.Reporter, reporterOptions?: any): this; -+ -+// /** -+// * Set reporter to the provided constructor, one of the built-in reporters, or loads a reporter -+// * from a module path. Defaults to `"spec"`. -+// * -+// * @see https://mochajs.org/api/mocha#reporter -+// */ -+// reporter(reporter?: string | Mocha.ReporterConstructor, reporterOptions?: any): this; -+ -+// /** -+// * Set test UI to one of the built-in test interfaces. -+// * -+// * @see https://mochajs.org/api/mocha#ui -+// */ -+// ui(name: Mocha.Interface): this; -+ -+// /** -+// * Set test UI to one of the built-in test interfaces or loads a test interface from a module -+// * path. Defaults to `"bdd"`. -+// * -+// * @see https://mochajs.org/api/mocha#ui -+// */ -+// ui(name?: string): this; -+ -+// /** -+// * Escape string and add it to grep as a RegExp. -+// * -+// * @see https://mochajs.org/api/mocha#fgrep -+// */ -+// fgrep(str: string): this; -+ -+// /** -+// * Add regexp to grep, if `re` is a string it is escaped. -+// * -+// * @see https://mochajs.org/api/mocha#grep -+// */ -+// grep(re: string | RegExp): this; -+ -+// /** -+// * Invert `.grep()` matches. -+// * -+// * @see https://mochajs.org/api/mocha#invert -+// */ -+// invert(): this; -+ -+// /** -+// * Enable global leak checking. -+// * -+// * @see https://mochajs.org/api/mocha#checkLeaks -+// */ -+// checkLeaks(): this; -+ -+// /** -+// * Display long stack-trace on failing -+// * -+// * @see https://mochajs.org/api/mocha#fullTrace -+// */ -+// fullTrace(): this; -+ -+// /** -+// * Enable growl support. -+// * -+// * @see https://mochajs.org/api/mocha#growl -+// */ -+// growl(): this; -+ -+// /** -+// * Ignore `globals` array or string. -+// * -+// * @see https://mochajs.org/api/mocha#globals -+// */ -+// globals(globals: string | ReadonlyArray): this; -+ -+// /** -+// * Set the timeout in milliseconds. -+// * -+// * @see https://mochajs.org/api/mocha#timeout -+// */ -+// timeout(timeout: string | number): this; -+ -+// /** -+// * Set the number of times to retry failed tests. -+// * -+// * @see https://mochajs.org/api/mocha#retries -+// */ -+// retries(n: number): this; -+ -+// /** -+// * Set slowness threshold in milliseconds. -+// * -+// * @see https://mochajs.org/api/mocha#slow -+// */ -+// slow(slow: string | number): this; -+ -+// /** -+// * Makes all tests async (accepting a callback) -+// * -+// * @see https://mochajs.org/api/mocha#asyncOnly. -+// */ -+// asyncOnly(): this; -+ -+// /** -+// * Disable syntax highlighting (in browser). -+// * -+// * @see https://mochajs.org/api/mocha#noHighlighting -+// */ -+// noHighlighting(): this; -+ -+// /** -+// * Enable uncaught errors to propagate (in browser). -+// * -+// * @see https://mochajs.org/api/mocha#allowUncaught -+// */ -+// allowUncaught(): boolean; -+ -+// /** -+// * Delay root suite execution. -+// * -+// * @see https://mochajs.org/api/mocha#delay -+// */ -+// delay(): boolean; -+ -+// /** -+// * Tests marked only fail the suite -+// * -+// * @see https://mochajs.org/api/mocha#forbidOnly -+// */ -+// forbidOnly(): boolean; -+ -+// /** -+// * Pending tests and tests marked skip fail the suite -+// * -+// * @see https://mochajs.org/api/mocha#forbidPending -+// */ -+// forbidPending(): boolean; -+ -+// /** -+// * Run tests and invoke `fn()` when complete. -+// * -+// * Note that `run` relies on Node's `require` to execute -+// * the test interface functions and will be subject to the -+// * cache - if the files are already in the `require` cache, -+// * they will effectively be skipped. Therefore, to run tests -+// * multiple times or to run tests in files that are already -+// * in the `require` cache, make sure to clear them from the -+// * cache first in whichever manner best suits your needs. -+// * -+// * @see https://mochajs.org/api/mocha#run -+// */ -+// run(fn?: (failures: number) => void): Mocha.Runner; -+ -+// /** -+// * Loads ESM (and CJS) test files asynchronously. -+// * -+// * @see https://mochajs.org/api/mocha#loadFilesAsync -+// */ -+// loadFilesAsync(): Promise; -+ -+// /** -+// * Load registered files. -+// * -+// * @see https://mochajs.org/api/mocha#loadFiles -+// */ -+// protected loadFiles(fn?: () => void): void; -+ -+// /** -+// * Unloads `files` from Node's `require` cache. -+// * -+// * This allows required files to be "freshly" reloaded, providing the ability -+// * to reuse a Mocha instance programmatically. -+// * Note: does not clear ESM module files from the cache -+// */ -+// unloadFiles(): this; -+ -+// /** -+// * Toggles parallel mode. -+// * -+// * Must be run before calling `run`. Changes the `Runner` class to -+// * use; also enables lazy file loading if not already done so. -+// * -+// * @see https://mochajs.org/api/mocha#parallelMode -+// */ -+// parallelMode(enabled?: boolean): this; -+ -+// /** -+// * Assigns hooks to the root suite. -+// * -+// * @see https://mochajs.org/api/mocha#rootHooks -+// */ -+// rootHooks(hooks: Mocha.RootHookObject): this; -+ -+// /** -+// * Configures one or more global setup fixtures. -+// * If given no parameters, unsets any previously-set fixtures. -+// * -+// * @see https://mochajs.org/api/mocha#globalSetup -+// */ -+// globalSetup: Mocha.HookFunction; -+ -+// /** -+// * Configures one or more global teardown fixtures. -+// * If given no parameters, unsets any previously-set fixtures. -+// * -+// * @see https://mochajs.org/api/mocha#globalTeardown -+// */ -+// globalTeardown: Mocha.HookFunction; -+ -+// /** -+// * Returns `true` if one or more global setup fixtures have been supplied -+// * -+// * @see https://mochajs.org/api/mocha#hasGlobalSetupFixtures -+// */ -+// hasGlobalSetupFixtures(): boolean; -+ -+// /** -+// * Returns `true` if one or more global teardown fixtures have been supplied -+// * -+// * @see https://mochajs.org/api/mocha#hasGlobalTeardownFixtures -+// */ -+// hasGlobalTeardownFixtures(): boolean; -+ -+// /** -+// * Toggle execution of any global setup fixture(s) -+// * -+// * @see https://mochajs.org/api/mocha#enableGlobalSetup -+// */ -+// enableGlobalSetup(enabled: boolean): this; -+ -+// /** -+// * Toggle execution of any global teardown fixture(s) -+// * -+// * @see https://mochajs.org/api/mocha#enableGlobalTeardown -+// */ -+// enableGlobalTeardown(enabled: boolean): this; -+// } -+ -+// declare namespace Mocha { -+// namespace utils { -+// /** -+// * Compute a slug from the given `str`. -+// * -+// * @see https://mochajs.org/api/module-utils.html#.slug -+// */ -+// function slug(str: string): string; -+ -+// /** -+// * Strip the function definition from `str`, and re-indent for pre whitespace. -+// * -+// * @see https://mochajs.org/api/module-utils.html#.clean -+// */ -+// function clean(str: string): string; -+ -+// /** -+// * Highlight the given string of `js`. -+// */ -+// function highlight(js: string): string; -+ -+// /** -+// * Takes some variable and asks `Object.prototype.toString()` what it thinks it is. -+// */ -+// function type(value: any): string; -+ -+// /** -+// * Stringify `value`. Different behavior depending on type of value: -+// * -+// * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively. -+// * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes. -+// * - If `value` is an *empty* object, function, or array, returns `'{}'`, `'[Function]'`, or `'[]'` respectively. -+// * - If `value` has properties, call canonicalize} on it, then return result of `JSON.stringify()` -+// * -+// * @see https://mochajs.org/api/module-utils.html#.stringify -+// */ -+// function stringify(value: any): string; -+ -+// /** -+// * Return a new Thing that has the keys in sorted order. Recursive. -+// * -+// * If the Thing... -+// * - has already been seen, return string `'[Circular]'` -+// * - is `undefined`, return string `'[undefined]'` -+// * - is `null`, return value `null` -+// * - is some other primitive, return the value -+// * - is not a primitive or an `Array`, `Object`, or `Function`, return the value of the Thing's `toString()` method -+// * - is a non-empty `Array`, `Object`, or `Function`, return the result of calling this function again. -+// * - is an empty `Array`, `Object`, or `Function`, returns `'[]'`, `'{}'`, or `'[Function]'` respectively. -+// * -+// * @see https://mochajs.org/api/module-utils.html#.canonicalize -+// */ -+// function canonicalize(value: any, stack: any[], typeHint: string): any; -+ -+// /** -+// * Lookup file names at the given `path`. -+// * -+// * @see https://mochajs.org/api/Mocha.utils.html#.exports.lookupFiles -+// */ -+// function lookupFiles(filepath: string, extensions?: string[], recursive?: boolean): string[]; -+ -+// /** -+// * Generate an undefined error with a message warning the user. -+// * -+// * @see https://mochajs.org/api/module-utils.html#.undefinedError -+// */ -+// function undefinedError(): Error; -+ -+// /** -+// * Generate an undefined error if `err` is not defined. -+// * -+// * @see https://mochajs.org/api/module-utils.html#.getError -+// */ -+// function getError(err: Error | undefined): Error; -+ -+// /** -+// * When invoking this function you get a filter function that get the Error.stack as an -+// * input, and return a prettify output. (i.e: strip Mocha and internal node functions from -+// * stack trace). -+// * -+// * @see https://mochajs.org/api/module-utils.html#.stackTraceFilter -+// */ -+// function stackTraceFilter(): (stack: string) => string; -+// } -+ -+// namespace interfaces { -+// function bdd(suite: Suite): void; -+// function tdd(suite: Suite): void; -+// function qunit(suite: Suite): void; -+// function exports(suite: Suite): void; -+// } -+ -+// // #region Test interface augmentations -+ -+// interface HookFunction { -+// /** -+// * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the -+// * function is used as the name of the hook. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (fn: Func): void; -+ -+// /** -+// * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the -+// * function is used as the name of the hook. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (fn: AsyncFunc): void; -+ -+// /** -+// * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (name: string, fn?: Func): void; -+ -+// /** -+// * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (name: string, fn?: AsyncFunc): void; -+// } -+ -+// interface SuiteFunction { -+// /** -+// * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing -+// * nested suites. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (title: string, fn: (this: Suite) => void): Suite; -+ -+// /** -+// * [qunit] Describe a "suite" with the given `title`. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (title: string): Suite; -+ -+// /** -+// * [bdd, tdd, qunit] Indicates this suite should be executed exclusively. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// only: ExclusiveSuiteFunction; -+ -+// /** -+// * [bdd, tdd] Indicates this suite should not be executed. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// skip: PendingSuiteFunction; -+// } -+ -+// interface ExclusiveSuiteFunction { -+// /** -+// * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing -+// * nested suites. Indicates this suite should be executed exclusively. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (title: string, fn: (this: Suite) => void): Suite; -+ -+// /** -+// * [qunit] Describe a "suite" with the given `title`. Indicates this suite should be executed -+// * exclusively. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (title: string): Suite; -+// } -+ -+// /** -+// * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing -+// * nested suites. Indicates this suite should not be executed. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @returns [bdd] `Suite` -+// * @returns [tdd] `void` -+// */ -+// interface PendingSuiteFunction { -+// (title: string, fn: (this: Suite) => void): Suite | void; -+// } -+ -+// interface TestFunction { -+// /** -+// * Describe a specification or test-case with the given callback `fn` acting as a thunk. -+// * The name of the function is used as the name of the test. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (fn: Func): Test; -+ -+// /** -+// * Describe a specification or test-case with the given callback `fn` acting as a thunk. -+// * The name of the function is used as the name of the test. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (fn: AsyncFunc): Test; -+ -+// /** -+// * Describe a specification or test-case with the given `title` and callback `fn` acting -+// * as a thunk. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (title: string, fn?: Func): Test; -+ -+// /** -+// * Describe a specification or test-case with the given `title` and callback `fn` acting -+// * as a thunk. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (title: string, fn?: AsyncFunc): Test; -+ -+// /** -+// * Indicates this test should be executed exclusively. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// only: ExclusiveTestFunction; -+ -+// /** -+// * Indicates this test should not be executed. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// skip: PendingTestFunction; -+ -+// /** -+// * Number of attempts to retry. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// retries(n: number): void; -+// } -+ -+// interface ExclusiveTestFunction { -+// /** -+// * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` -+// * acting as a thunk. The name of the function is used as the name of the test. Indicates -+// * this test should be executed exclusively. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (fn: Func): Test; -+ -+// /** -+// * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` -+// * acting as a thunk. The name of the function is used as the name of the test. Indicates -+// * this test should be executed exclusively. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (fn: AsyncFunc): Test; -+ -+// /** -+// * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and -+// * callback `fn` acting as a thunk. Indicates this test should be executed exclusively. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (title: string, fn?: Func): Test; -+ -+// /** -+// * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and -+// * callback `fn` acting as a thunk. Indicates this test should be executed exclusively. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (title: string, fn?: AsyncFunc): Test; -+// } -+ -+// interface PendingTestFunction { -+// /** -+// * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` -+// * acting as a thunk. The name of the function is used as the name of the test. Indicates -+// * this test should not be executed. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (fn: Func): Test; -+ -+// /** -+// * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn` -+// * acting as a thunk. The name of the function is used as the name of the test. Indicates -+// * this test should not be executed. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (fn: AsyncFunc): Test; -+ -+// /** -+// * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and -+// * callback `fn` acting as a thunk. Indicates this test should not be executed. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (title: string, fn?: Func): Test; -+ -+// /** -+// * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and -+// * callback `fn` acting as a thunk. Indicates this test should not be executed. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// (title: string, fn?: AsyncFunc): Test; -+// } -+ -+// /** -+// * Execute after each test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#afterEach -+// */ -+// let afterEach: HookFunction; -+ -+// /** -+// * Execute after running tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#after -+// */ -+// let after: HookFunction; -+ -+// /** -+// * Execute before each test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#beforeEach -+// */ -+// let beforeEach: HookFunction; -+ -+// /** -+// * Execute before running tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#before -+// */ -+// let before: HookFunction; -+ -+// /** -+// * Describe a "suite" containing nested suites and tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// let describe: SuiteFunction; -+ -+// /** -+// * Describes a test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// let it: TestFunction; -+ -+// /** -+// * Describes a pending test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// let xit: PendingTestFunction; -+ -+// /** -+// * Execute before each test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#beforeEach -+// */ -+// let setup: HookFunction; -+ -+// /** -+// * Execute before running tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#before -+// */ -+// let suiteSetup: HookFunction; -+ -+// /** -+// * Execute after running tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#after -+// */ -+// let suiteTeardown: HookFunction; -+ -+// /** -+// * Describe a "suite" containing nested suites and tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// let suite: SuiteFunction; -+ -+// /** -+// * Execute after each test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#afterEach -+// */ -+// let teardown: HookFunction; -+ -+// /** -+// * Describes a test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// let test: TestFunction; -+ -+// /** -+// * Triggers root suite execution. -+// * -+// * - _Only available if flag --delay is passed into Mocha._ -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#runWithSuite -+// */ -+// function run(): void; -+ -+// // #endregion Test interface augmentations -+ -+// namespace reporters { -+// /** -+// * Initialize a new `Base` reporter. -+// * -+// * All other reporters generally inherit from this reporter, providing stats such as test duration, -+// * number of tests passed / failed, etc. -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.Base.html -+// */ -+// class Base { -+// constructor(runner: Runner, options?: MochaOptions); -+ -+// /** -+// * Test run statistics -+// */ -+// stats: Stats; -+ -+// /** -+// * Test failures -+// */ -+// failures: Test[]; -+ -+// /** -+// * The configured runner -+// */ -+// runner: Runner; -+ -+// /** -+// * Output common epilogue used by many of the bundled reporters. -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.Base.html#.Base#epilogue -+// */ -+// epilogue(): void; -+ -+// done?(failures: number, fn?: (failures: number) => void): void; -+// } -+ -+// namespace Base { -+// /** -+// * Enables coloring by default -+// * -+// * @see https://mochajs.org/api/module-base#.useColors -+// */ -+// let useColors: boolean; -+ -+// /** -+// * Inline diffs instead of +/- -+// * -+// * @see https://mochajs.org/api/module-base#.inlineDiffs -+// */ -+// let inlineDiffs: boolean; -+ -+// /** -+// * Default color map -+// * -+// * @see https://mochajs.org/api/module-base#.colors -+// */ -+// const colors: ColorMap; -+ -+// /** -+// * Default color map -+// * -+// * @see https://mochajs.org/api/module-base#.colors -+// */ -+// interface ColorMap { -+// // added by Base -+// pass: number; -+// fail: number; -+// "bright pass": number; -+// "bright fail": number; -+// "bright yellow": number; -+// pending: number; -+// suite: number; -+// "error title": number; -+// "error message": number; -+// "error stack": number; -+// checkmark: number; -+// fast: number; -+// medium: number; -+// slow: number; -+// green: number; -+// light: number; -+// "diff gutter": number; -+// "diff added": number; -+// "diff removed": number; -+ -+// // added by Progress -+// progress: number; -+ -+// // added by Landing -+// plane: number; -+// "plane crash": number; -+// runway: number; -+ -+// [key: string]: number; -+// } -+ -+// /** -+// * Default symbol map -+// * -+// * @see https://mochajs.org/api/module-base#.symbols -+// */ -+// const symbols: SymbolMap; -+ -+// /** -+// * Default symbol map -+// * -+// * @see https://mochajs.org/api/module-base#.symbols -+// */ -+// interface SymbolMap { -+// ok: string; -+// err: string; -+// dot: string; -+// comma: string; -+// bang: string; -+// [key: string]: string; -+// } -+ -+// /** -+// * Color `str` with the given `type` (from `colors`) -+// * -+// * @see https://mochajs.org/api/module-base#.color -+// */ -+// function color(type: string, str: string): string; -+ -+// /** -+// * Expose terminal window size -+// * -+// * @see https://mochajs.org/api/module-base#.window -+// */ -+// const window: { -+// width: number; -+// }; -+ -+// /** -+// * ANSI TTY control sequences common among reporters. -+// * -+// * @see https://mochajs.org/api/module-base#.cursor -+// */ -+// namespace cursor { -+// /** -+// * Hides the cursor -+// */ -+// function hide(): void; -+ -+// /** -+// * Shows the cursor -+// */ -+// function show(): void; -+ -+// /** -+// * Deletes the current line -+// */ -+// function deleteLine(): void; -+ -+// /** -+// * Moves to the beginning of the line -+// */ -+// function beginningOfLine(): void; -+ -+// /** -+// * Clears the line and moves to the beginning of the line. -+// */ -+// function CR(): void; -+// } -+ -+// /** -+// * Returns a diff between two strings with colored ANSI output. -+// * -+// * @see https://mochajs.org/api/module-base#.generateDiff -+// */ -+// function generateDiff(actual: string, expected: string): string; -+ -+// /** -+// * Output the given `failures` as a list. -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.Base.html#.exports.list1 -+// */ -+// function list(failures: Test[]): void; -+// } -+ -+// /** -+// * Initialize a new `Dot` matrix test reporter. -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.Dot.html -+// */ -+// class Dot extends Base { -+// } -+ -+// /** -+// * Initialize a new `Doc` reporter. -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.Doc.html -+// */ -+// class Doc extends Base { -+// } -+ -+// /** -+// * Initialize a new `TAP` test reporter. -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.TAP.html -+// */ -+// class TAP extends Base { -+// } -+ -+// /** -+// * Initialize a new `JSON` reporter -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.JSON.html -+// */ -+// class JSON extends Base { -+// } -+ -+// /** -+// * Initialize a new `HTML` reporter. -+// * -+// * - _This reporter cannot be used on the console._ -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.HTML.html -+// */ -+// class HTML extends Base { -+// /** -+// * Provide suite URL. -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.HTML.html#suiteURL -+// */ -+// suiteURL(suite: Suite): string; -+ -+// /** -+// * Provide test URL. -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.HTML.html#testURL -+// */ -+// testURL(test: Test): string; -+ -+// /** -+// * Adds code toggle functionality for the provided test's list element. -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.HTML.html#addCodeToggle -+// */ -+// addCodeToggle(el: HTMLLIElement, contents: string): void; -+// } -+ -+// /** -+// * Initialize a new `List` test reporter. -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.List.html -+// */ -+// class List extends Base { -+// } -+ -+// /** -+// * Initialize a new `Min` minimal test reporter (best used with --watch). -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.Min.html -+// */ -+// class Min extends Base { -+// } -+ -+// /** -+// * Initialize a new `Spec` test reporter. -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.Spec.html -+// */ -+// class Spec extends Base { -+// } -+ -+// /** -+// * Initialize a new `NyanCat` test reporter. -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.Nyan.html -+// */ -+// class Nyan extends Base { -+// private colorIndex; -+// private numberOfLines; -+// private rainbowColors; -+// private scoreboardWidth; -+// private tick; -+// private trajectories; -+// private trajectoryWidthMax; -+// private draw; -+// private drawScoreboard; -+// private appendRainbow; -+// private drawRainbow; -+// private drawNyanCat; -+// private face; -+// private cursorUp; -+// private cursorDown; -+// private generateColors; -+// private rainbowify; -+// } -+ -+// /** -+// * Initialize a new `XUnit` test reporter. -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.XUnit.html -+// */ -+// class XUnit extends Base { -+// constructor(runner: Runner, options?: XUnit.MochaOptions); -+ -+// /** -+// * Override done to close the stream (if it's a file). -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#done -+// */ -+// done(failures: number, fn: (failures: number) => void): void; -+ -+// /** -+// * Write out the given line. -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#write -+// */ -+// write(line: string): void; -+ -+// /** -+// * Output tag for the given `test.` -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#test -+// */ -+// test(test: Test): void; -+// } -+ -+// namespace XUnit { -+// interface MochaOptions extends Mocha.MochaOptions { -+// reporterOptions?: ReporterOptions; -+// } -+ -+// interface ReporterOptions { -+// output?: string; -+// suiteName?: string; -+// } -+// } -+ -+// /** -+// * Initialize a new `Markdown` test reporter. -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.Markdown.html -+// */ -+// class Markdown extends Base { -+// } -+ -+// /** -+// * Initialize a new `Progress` bar test reporter. -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.Progress.html -+// */ -+// class Progress extends Base { -+// constructor(runner: Runner, options?: Progress.MochaOptions); -+// } -+ -+// namespace Progress { -+// interface MochaOptions extends Mocha.MochaOptions { -+// reporterOptions?: ReporterOptions; -+// } -+ -+// interface ReporterOptions { -+// open?: string; -+// complete?: string; -+// incomplete?: string; -+// close?: string; -+// verbose?: boolean; -+// } -+// } -+ -+// /** -+// * Initialize a new `Landing` reporter. -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.Landing.html -+// */ -+// class Landing extends Base { -+// } -+ -+// /** -+// * Initialize a new `JSONStream` test reporter. -+// * -+// * @see https://mochajs.org/api/Mocha.reporters.JSONStream.html -+// */ -+// class JSONStream extends Base { -+// } -+ -+// // value-only aliases -+// const base: typeof Base; -+// const dot: typeof Dot; -+// const doc: typeof Doc; -+// const tap: typeof TAP; -+// const json: typeof JSON; -+// const html: typeof HTML; -+// const list: typeof List; -+// const spec: typeof Spec; -+// const nyan: typeof Nyan; -+// const xunit: typeof XUnit; -+// const markdown: typeof Markdown; -+// const progress: typeof Progress; -+// const landing: typeof Landing; -+// // NOTE: not possible to type this correctly: -+// // const "json-stream": typeof JSONStream; -+// } -+ -+// /** -+// * Initialize a new `Runnable` with the given `title` and callback `fn`. -+// * -+// * @see https://mochajs.org/api/Runnable.html -+// */ -+// class Runnable { -+// private _slow; -+// private _retries; -+// private _currentRetry; -+// private _timeout; -+// private _timeoutError; -+ -+// constructor(title: string, fn?: Func | AsyncFunc); -+ -+// title: string; -+// fn: Func | AsyncFunc | undefined; -+// body: string; -+// async: boolean; -+// sync: boolean; -+// timedOut: boolean; -+// pending: boolean; -+// duration?: number; -+// parent?: Suite; -+// state?: "failed" | "passed"; -+// timer?: any; -+// ctx?: Context; -+// callback?: Done; -+// allowUncaught?: boolean; -+// file?: string; -+ -+// /** -+// * Get test timeout. -+// * -+// * @see https://mochajs.org/api/Runnable.html#timeout -+// */ -+// timeout(): number; -+ -+// /** -+// * Set test timeout. -+// * -+// * @see https://mochajs.org/api/Runnable.html#timeout -+// */ -+// timeout(ms: string | number): this; -+ -+// /** -+// * Get test slowness threshold. -+// * -+// * @see https://mochajs.org/api/Runnable.html#slow -+// */ -+// slow(): number; -+ -+// /** -+// * Set test slowness threshold. -+// * -+// * @see https://mochajs.org/api/Runnable.html#slow -+// */ -+// slow(ms: string | number): this; -+ -+// /** -+// * Halt and mark as pending. -+// */ -+// skip(): never; -+ -+// /** -+// * Check if this runnable or its parent suite is marked as pending. -+// * -+// * @see https://mochajs.org/api/Runnable.html#isPending -+// */ -+// isPending(): boolean; -+ -+// /** -+// * Return `true` if this Runnable has failed. -+// */ -+// isFailed(): boolean; -+ -+// /** -+// * Return `true` if this Runnable has passed. -+// */ -+// isPassed(): boolean; -+ -+// /** -+// * Set or get number of retries. -+// * -+// * @see https://mochajs.org/api/Runnable.html#retries -+// */ -+// retries(): number; -+ -+// /** -+// * Set or get number of retries. -+// * -+// * @see https://mochajs.org/api/Runnable.html#retries -+// */ -+// retries(n: number): void; -+ -+// /** -+// * Set or get current retry -+// * -+// * @see https://mochajs.org/api/Runnable.html#currentRetry -+// */ -+// protected currentRetry(): number; -+ -+// /** -+// * Set or get current retry -+// * -+// * @see https://mochajs.org/api/Runnable.html#currentRetry -+// */ -+// protected currentRetry(n: number): void; -+ -+// /** -+// * Return the full title generated by recursively concatenating the parent's full title. -+// */ -+// fullTitle(): string; -+ -+// /** -+// * Return the title path generated by concatenating the parent's title path with the title. -+// */ -+// titlePath(): string[]; -+ -+// /** -+// * Clear the timeout. -+// * -+// * @see https://mochajs.org/api/Runnable.html#clearTimeout -+// */ -+// clearTimeout(): void; -+ -+// /** -+// * Inspect the runnable void of private properties. -+// * -+// * @see https://mochajs.org/api/Runnable.html#inspect -+// */ -+// inspect(): string; -+ -+// /** -+// * Reset the timeout. -+// * -+// * @see https://mochajs.org/api/Runnable.html#resetTimeout -+// */ -+// resetTimeout(): void; -+ -+// /** -+// * Get a list of whitelisted globals for this test run. -+// * -+// * @see https://mochajs.org/api/Runnable.html#globals -+// */ -+// globals(): string[]; -+ -+// /** -+// * Set a list of whitelisted globals for this test run. -+// * -+// * @see https://mochajs.org/api/Runnable.html#globals -+// */ -+// globals(globals: ReadonlyArray): void; -+ -+// /** -+// * Run the test and invoke `fn(err)`. -+// * -+// * @see https://mochajs.org/api/Runnable.html#run -+// */ -+// run(fn: Done): void; -+// } -+ -+// // #region Runnable "error" event -+// interface Runnable extends NodeJS.EventEmitter { -+// on(event: "error", listener: (error: any) => void): this; -+// once(event: "error", listener: (error: any) => void): this; -+// addListener(event: "error", listener: (error: any) => void): this; -+// removeListener(event: "error", listener: (error: any) => void): this; -+// prependListener(event: "error", listener: (error: any) => void): this; -+// prependOnceListener(event: "error", listener: (error: any) => void): this; -+// emit(name: "error", error: any): boolean; -+// } -+// // #endregion Runnable "error" event -+// // #region Runnable untyped events -+// interface Runnable extends NodeJS.EventEmitter { -+// on(event: string, listener: (...args: any[]) => void): this; -+// once(event: string, listener: (...args: any[]) => void): this; -+// addListener(event: string, listener: (...args: any[]) => void): this; -+// removeListener(event: string, listener: (...args: any[]) => void): this; -+// prependListener(event: string, listener: (...args: any[]) => void): this; -+// prependOnceListener(event: string, listener: (...args: any[]) => void): this; -+// emit(name: string, ...args: any[]): boolean; -+// } -+// // #endregion Runnable untyped events -+ -+// /** -+// * Test context -+// * -+// * @see https://mochajs.org/api/module-Context.html#~Context -+// */ -+// class Context { -+// private _runnable; -+ -+// test?: Runnable; -+// currentTest?: Test; -+ -+// /** -+// * Get the context `Runnable`. -+// */ -+// runnable(): Runnable; -+ -+// /** -+// * Set the context `Runnable`. -+// */ -+// runnable(runnable: Runnable): this; -+ -+// /** -+// * Get test timeout. -+// */ -+// timeout(): number; -+ -+// /** -+// * Set test timeout. -+// */ -+// timeout(ms: string | number): this; -+ -+// /** -+// * Get test slowness threshold. -+// */ -+// slow(): number; -+ -+// /** -+// * Set test slowness threshold. -+// */ -+// slow(ms: string | number): this; -+ -+// /** -+// * Mark a test as skipped. -+// */ -+// skip(): never; -+ -+// /** -+// * Get the number of allowed retries on failed tests. -+// */ -+// retries(): number; -+ -+// /** -+// * Set the number of allowed retries on failed tests. -+// */ -+// retries(n: number): this; -+ -+// [key: string]: any; -+// } -+ -+// interface RunnerConstants { -+// readonly EVENT_HOOK_BEGIN: 'hook'; -+// readonly EVENT_HOOK_END: 'hook end'; -+// readonly EVENT_RUN_BEGIN: 'start'; -+// readonly EVENT_DELAY_BEGIN: 'waiting'; -+// readonly EVENT_DELAY_END: 'ready'; -+// readonly EVENT_RUN_END: 'end'; -+// readonly EVENT_SUITE_BEGIN: 'suite'; -+// readonly EVENT_SUITE_END: 'suite end'; -+// readonly EVENT_TEST_BEGIN: 'test'; -+// readonly EVENT_TEST_END: 'test end'; -+// readonly EVENT_TEST_FAIL: 'fail'; -+// readonly EVENT_TEST_PASS: 'pass'; -+// readonly EVENT_TEST_PENDING: 'pending'; -+// readonly EVENT_TEST_RETRY: 'retry'; -+// readonly STATE_IDLE: 'idle'; -+// readonly STATE_RUNNING: 'running'; -+// readonly STATE_STOPPED: 'stopped'; -+// } -+ -+// /** -+// * Initialize a `Runner` for the given `suite`. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html -+// */ -+// class Runner { -+// private _globals; -+// private _abort; -+// private _delay; -+// private _defaultGrep; -+// private next; -+// private hookErr; -+// private prevGlobalsLength; -+// private nextSuite; -+ -+// static readonly constants: RunnerConstants; -+ -+// constructor(suite: Suite, delay: boolean); -+ -+// suite: Suite; -+// started: boolean; -+// total: number; -+// failures: number; -+// asyncOnly?: boolean; -+// allowUncaught?: boolean; -+// fullStackTrace?: boolean; -+// forbidOnly?: boolean; -+// forbidPending?: boolean; -+// checkLeaks?: boolean; -+// test?: Test; -+// currentRunnable?: Runnable; -+// stats?: Stats; // added by reporters -+ -+// /** -+// * Removes all event handlers set during a run on this instance. -+// * Remark: this does *not* clean/dispose the tests or suites themselves. -+// * -+// * @see https://mochajs.org/api/runner#dispose -+// */ -+// dispose(): void; -+ -+// /** -+// * Run tests with full titles matching `re`. Updates runner.total -+// * with number of tests matched. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grep -+// */ -+// grep(re: RegExp, invert: boolean): this; -+ -+// /** -+// * Returns the number of tests matching the grep search for the -+// * given suite. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grepTotal -+// */ -+// grepTotal(suite: Suite): number; -+ -+// /** -+// * Gets the allowed globals. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals -+// */ -+// globals(): string[]; -+ -+// /** -+// * Allow the given `arr` of globals. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals -+// */ -+// globals(arr: ReadonlyArray): this; -+ -+// /** -+// * Run the root suite and invoke `fn(failures)` on completion. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#run -+// */ -+// run(fn?: (failures: number) => void): this; -+ -+// /** -+// * Cleanly abort execution. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#abort -+// */ -+// abort(): this; -+ -+// /** -+// * Handle uncaught exceptions. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#uncaught -+// */ -+// uncaught(err: any): void; -+ -+// /** -+// * Wrapper for setImmediate, process.nextTick, or browser polyfill. -+// */ -+// protected static immediately(callback: Function): void; -+ -+// /** -+// * Return a list of global properties. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#globalProps -+// */ -+// protected globalProps(): string[]; -+ -+// /** -+// * Check for global variable leaks. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#checkGlobals -+// */ -+// protected checkGlobals(test: Test): void; -+ -+// /** -+// * Fail the given `test`. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#fail -+// */ -+// protected fail(test: Test, err: any): void; -+ -+// /** -+// * Fail the given `hook` with `err`. -+// * -+// * Hook failures work in the following pattern: -+// * - If bail, then exit -+// * - Failed `before` hook skips all tests in a suite and subsuites, -+// * but jumps to corresponding `after` hook -+// * - Failed `before each` hook skips remaining tests in a -+// * suite and jumps to corresponding `after each` hook, -+// * which is run only once -+// * - Failed `after` hook does not alter -+// * execution order -+// * - Failed `after each` hook skips remaining tests in a -+// * suite and subsuites, but executes other `after each` -+// * hooks -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#failHook -+// */ -+// protected failHook(hook: Hook, err: any): void; -+ -+// /** -+// * Run hook `name` callbacks and then invoke `fn()`. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#hook -+// */ -+// protected hook(name: string, fn: () => void): void; -+ -+// /** -+// * Run hook `name` for the given array of `suites` -+// * in order, and callback `fn(err, errSuite)`. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#hooks -+// */ -+// protected hooks(name: string, suites: Suite[], fn: (err?: any, errSuite?: Suite) => void): void; -+ -+// /** -+// * Run hooks from the top level down. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#hookUp -+// */ -+// protected hookUp(name: string, fn: (err?: any, errSuite?: Suite) => void): void; -+ -+// /** -+// * Run hooks from the bottom up. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#hookDown -+// */ -+// protected hookDown(name: string, fn: (err?: any, errSuite?: Suite) => void): void; -+ -+// /** -+// * Return an array of parent Suites from closest to furthest. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#parents -+// */ -+// protected parents(): Suite[]; -+ -+// /** -+// * Run the current test and callback `fn(err)`. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#runTest -+// */ -+// protected runTest(fn: Done): any; -+ -+// /** -+// * Run tests in the given `suite` and invoke the callback `fn()` when complete. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#runTests -+// */ -+// protected runTests(suite: Suite, fn: (errSuite?: Suite) => void): void; -+ -+// /** -+// * Run the given `suite` and invoke the callback `fn()` when complete. -+// * -+// * @see https://mochajs.org/api/Mocha.Runner.html#runSuite -+// */ -+// protected runSuite(suite: Suite, fn: (errSuite?: Suite) => void): void; -+// } -+ -+// // #region Runner "waiting" event -+// interface Runner { -+// on(event: "waiting", listener: (rootSuite: Suite) => void): this; -+// once(event: "waiting", listener: (rootSuite: Suite) => void): this; -+// addListener(event: "waiting", listener: (rootSuite: Suite) => void): this; -+// removeListener(event: "waiting", listener: (rootSuite: Suite) => void): this; -+// prependListener(event: "waiting", listener: (rootSuite: Suite) => void): this; -+// prependOnceListener(event: "waiting", listener: (rootSuite: Suite) => void): this; -+// emit(name: "waiting", rootSuite: Suite): boolean; -+// } -+// // #endregion Runner "waiting" event -+// // #region Runner "start" event -+// interface Runner extends NodeJS.EventEmitter { -+// on(event: "start", listener: () => void): this; -+// once(event: "start", listener: () => void): this; -+// addListener(event: "start", listener: () => void): this; -+// removeListener(event: "start", listener: () => void): this; -+// prependListener(event: "start", listener: () => void): this; -+// prependOnceListener(event: "start", listener: () => void): this; -+// emit(name: "start"): boolean; -+// } -+// // #endregion Runner "start" event -+// // #region Runner "end" event -+// interface Runner extends NodeJS.EventEmitter { -+// on(event: "end", listener: () => void): this; -+// once(event: "end", listener: () => void): this; -+// addListener(event: "end", listener: () => void): this; -+// removeListener(event: "end", listener: () => void): this; -+// prependListener(event: "end", listener: () => void): this; -+// prependOnceListener(event: "end", listener: () => void): this; -+// emit(name: "end"): boolean; -+// } -+// // #endregion Runner "end" event -+// // #region Runner "suite" event -+// interface Runner extends NodeJS.EventEmitter { -+// on(event: "suite", listener: (suite: Suite) => void): this; -+// once(event: "suite", listener: (suite: Suite) => void): this; -+// addListener(event: "suite", listener: (suite: Suite) => void): this; -+// removeListener(event: "suite", listener: (suite: Suite) => void): this; -+// prependListener(event: "suite", listener: (suite: Suite) => void): this; -+// prependOnceListener(event: "suite", listener: (suite: Suite) => void): this; -+// emit(name: "suite", suite: Suite): boolean; -+// } -+// // #endregion Runner "suite" event -+// // #region Runner "suite end" event -+// interface Runner extends NodeJS.EventEmitter { -+// on(event: "suite end", listener: (suite: Suite) => void): this; -+// once(event: "suite end", listener: (suite: Suite) => void): this; -+// addListener(event: "suite end", listener: (suite: Suite) => void): this; -+// removeListener(event: "suite end", listener: (suite: Suite) => void): this; -+// prependListener(event: "suite end", listener: (suite: Suite) => void): this; -+// prependOnceListener(event: "suite end", listener: (suite: Suite) => void): this; -+// emit(name: "suite end", suite: Suite): boolean; -+// } -+// // #endregion Runner "suite end" event -+// // #region Runner "test" event -+// interface Runner extends NodeJS.EventEmitter { -+// on(event: "test", listener: (test: Test) => void): this; -+// once(event: "test", listener: (test: Test) => void): this; -+// addListener(event: "test", listener: (test: Test) => void): this; -+// removeListener(event: "test", listener: (test: Test) => void): this; -+// prependListener(event: "test", listener: (test: Test) => void): this; -+// prependOnceListener(event: "test", listener: (test: Test) => void): this; -+// emit(name: "test", test: Test): boolean; -+// } -+// // #endregion Runner "test" event -+// // #region Runner "test end" event -+// interface Runner extends NodeJS.EventEmitter { -+// on(event: "test end", listener: (test: Test) => void): this; -+// once(event: "test end", listener: (test: Test) => void): this; -+// addListener(event: "test end", listener: (test: Test) => void): this; -+// removeListener(event: "test end", listener: (test: Test) => void): this; -+// prependListener(event: "test end", listener: (test: Test) => void): this; -+// prependOnceListener(event: "test end", listener: (test: Test) => void): this; -+// emit(name: "test end", test: Test): boolean; -+// } -+// // #endregion Runner "test end" event -+// // #region Runner "hook" event -+// interface Runner extends NodeJS.EventEmitter { -+// on(event: "hook", listener: (hook: Hook) => void): this; -+// once(event: "hook", listener: (hook: Hook) => void): this; -+// addListener(event: "hook", listener: (hook: Hook) => void): this; -+// removeListener(event: "hook", listener: (hook: Hook) => void): this; -+// prependListener(event: "hook", listener: (hook: Hook) => void): this; -+// prependOnceListener(event: "hook", listener: (hook: Hook) => void): this; -+// emit(name: "hook", hook: Hook): boolean; -+// } -+// // #endregion Runner "hook" event -+// // #region Runner "hook end" event -+// interface Runner extends NodeJS.EventEmitter { -+// on(event: "hook end", listener: (hook: Hook) => void): this; -+// once(event: "hook end", listener: (hook: Hook) => void): this; -+// addListener(event: "hook end", listener: (hook: Hook) => void): this; -+// removeListener(event: "hook end", listener: (hook: Hook) => void): this; -+// prependListener(event: "hook end", listener: (hook: Hook) => void): this; -+// prependOnceListener(event: "hook end", listener: (hook: Hook) => void): this; -+// emit(name: "hook end", hook: Hook): boolean; -+// } -+// // #endregion Runner "hook end" event -+// // #region Runner "pass" event -+// interface Runner extends NodeJS.EventEmitter { -+// on(event: "pass", listener: (test: Test) => void): this; -+// once(event: "pass", listener: (test: Test) => void): this; -+// addListener(event: "pass", listener: (test: Test) => void): this; -+// removeListener(event: "pass", listener: (test: Test) => void): this; -+// prependListener(event: "pass", listener: (test: Test) => void): this; -+// prependOnceListener(event: "pass", listener: (test: Test) => void): this; -+// emit(name: "pass", test: Test): boolean; -+// } -+// // #endregion Runner "pass" event -+// // #region Runner "fail" event -+// interface Runner extends NodeJS.EventEmitter { -+// on(event: "fail", listener: (test: Test, err: any) => void): this; -+// once(event: "fail", listener: (test: Test, err: any) => void): this; -+// addListener(event: "fail", listener: (test: Test, err: any) => void): this; -+// removeListener(event: "fail", listener: (test: Test, err: any) => void): this; -+// prependListener(event: "fail", listener: (test: Test, err: any) => void): this; -+// prependOnceListener(event: "fail", listener: (test: Test, err: any) => void): this; -+// emit(name: "fail", test: Test, err: any): boolean; -+// } -+// // #endregion Runner "fail" event -+// // #region Runner "pending" event -+// interface Runner extends NodeJS.EventEmitter { -+// on(event: "pending", listener: (test: Test) => void): this; -+// once(event: "pending", listener: (test: Test) => void): this; -+// addListener(event: "pending", listener: (test: Test) => void): this; -+// removeListener(event: "pending", listener: (test: Test) => void): this; -+// prependListener(event: "pending", listener: (test: Test) => void): this; -+// prependOnceListener(event: "pending", listener: (test: Test) => void): this; -+// emit(name: "pending", test: Test): boolean; -+// } -+// // #endregion Runner "pending" event -+// // #region Runner untyped events -+// interface Runner extends NodeJS.EventEmitter { -+// on(event: string, listener: (...args: any[]) => void): this; -+// once(event: string, listener: (...args: any[]) => void): this; -+// addListener(event: string, listener: (...args: any[]) => void): this; -+// removeListener(event: string, listener: (...args: any[]) => void): this; -+// prependListener(event: string, listener: (...args: any[]) => void): this; -+// prependOnceListener(event: string, listener: (...args: any[]) => void): this; -+// emit(name: string, ...args: any[]): boolean; -+// } -+// // #endregion Runner untyped events -+ -+// interface SuiteConstants { -+// readonly EVENT_FILE_POST_REQUIRE: 'post-require'; -+// readonly EVENT_FILE_PRE_REQUIRE: 'pre-require'; -+// readonly EVENT_FILE_REQUIRE: 'require'; -+// readonly EVENT_ROOT_SUITE_RUN: 'run'; -+ -+// readonly HOOK_TYPE_AFTER_ALL: 'afterAll'; -+// readonly HOOK_TYPE_AFTER_EACH: 'afterEach'; -+// readonly HOOK_TYPE_BEFORE_ALL: 'beforeAll'; -+// readonly HOOK_TYPE_BEFORE_EACH: 'beforeEach'; -+ -+// readonly EVENT_SUITE_ADD_HOOK_AFTER_ALL: 'afterAll'; -+// readonly EVENT_SUITE_ADD_HOOK_AFTER_EACH: 'afterEach'; -+// readonly EVENT_SUITE_ADD_HOOK_BEFORE_ALL: 'beforeAll'; -+// readonly EVENT_SUITE_ADD_HOOK_BEFORE_EACH: 'beforeEach'; -+// readonly EVENT_SUITE_ADD_SUITE: 'suite'; -+// readonly EVENT_SUITE_ADD_TEST: 'test'; -+// } -+ -+// /** -+// * Initialize a new `Suite` with the given `title` and `ctx`. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html -+// */ -+// class Suite { -+// private _beforeEach; -+// private _beforeAll; -+// private _afterEach; -+// private _afterAll; -+// private _timeout; -+// private _slow; -+// private _bail; -+// private _retries; -+// private _onlyTests; -+// private _onlySuites; -+ -+// static readonly constants: SuiteConstants; -+ -+// constructor(title: string, parentContext?: Context); -+ -+// ctx: Context; -+// suites: Suite[]; -+// tests: Test[]; -+// pending: boolean; -+// file?: string; -+// root: boolean; -+// delayed: boolean; -+// parent: Suite | undefined; -+// title: string; -+ -+// /** -+// * Create a new `Suite` with the given `title` and parent `Suite`. When a suite -+// * with the same title is already present, that suite is returned to provide -+// * nicer reporter and more flexible meta-testing. -+// * -+// * @see https://mochajs.org/api/mocha#.exports.create -+// */ -+// static create(parent: Suite, title: string): Suite; -+ -+// /** -+// * Return a clone of this `Suite`. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#clone -+// */ -+// clone(): Suite; -+ -+// /** -+// * Get timeout `ms`. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#timeout -+// */ -+// timeout(): number; -+ -+// /** -+// * Set timeout `ms` or short-hand such as "2s". -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#timeout -+// */ -+// timeout(ms: string | number): this; -+ -+// /** -+// * Get number of times to retry a failed test. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#retries -+// */ -+// retries(): number; -+ -+// /** -+// * Set number of times to retry a failed test. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#retries -+// */ -+// retries(n: string | number): this; -+ -+// /** -+// * Get slow `ms`. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#slow -+// */ -+// slow(): number; -+ -+// /** -+// * Set slow `ms` or short-hand such as "2s". -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#slow -+// */ -+// slow(ms: string | number): this; -+ -+// /** -+// * Get whether to bail after first error. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#bail -+// */ -+// bail(): boolean; -+ -+// /** -+// * Set whether to bail after first error. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#bail -+// */ -+// bail(bail: boolean): this; -+ -+// /** -+// * Check if this suite or its parent suite is marked as pending. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#isPending -+// */ -+// isPending(): boolean; -+ -+// /** -+// * Run `fn(test[, done])` before running tests. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll -+// */ -+// beforeAll(fn?: Func): this; -+ -+// /** -+// * Run `fn(test[, done])` before running tests. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll -+// */ -+// beforeAll(fn?: AsyncFunc): this; -+ -+// /** -+// * Run `fn(test[, done])` before running tests. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll -+// */ -+// beforeAll(title: string, fn?: Func): this; -+ -+// /** -+// * Run `fn(test[, done])` before running tests. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll -+// */ -+// beforeAll(title: string, fn?: AsyncFunc): this; -+ -+// /** -+// * Run `fn(test[, done])` after running tests. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#afterAll -+// */ -+// afterAll(fn?: Func): this; -+ -+// /** -+// * Run `fn(test[, done])` after running tests. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#afterAll -+// */ -+// afterAll(fn?: AsyncFunc): this; -+ -+// /** -+// * Run `fn(test[, done])` after running tests. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#afterAll -+// */ -+// afterAll(title: string, fn?: Func): this; -+ -+// /** -+// * Run `fn(test[, done])` after running tests. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#afterAll -+// */ -+// afterAll(title: string, fn?: AsyncFunc): this; -+ -+// /** -+// * Run `fn(test[, done])` before each test case. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach -+// */ -+// beforeEach(fn?: Func): this; -+ -+// /** -+// * Run `fn(test[, done])` before each test case. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach -+// */ -+// beforeEach(fn?: AsyncFunc): this; -+ -+// /** -+// * Run `fn(test[, done])` before each test case. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach -+// */ -+// beforeEach(title: string, fn?: Func): this; -+ -+// /** -+// * Run `fn(test[, done])` before each test case. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach -+// */ -+// beforeEach(title: string, fn?: AsyncFunc): this; -+ -+// /** -+// * Run `fn(test[, done])` after each test case. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#afterEach -+// */ -+// afterEach(fn?: Func): this; -+ -+// /** -+// * Run `fn(test[, done])` after each test case. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#afterEach -+// */ -+// afterEach(fn?: AsyncFunc): this; -+ -+// /** -+// * Run `fn(test[, done])` after each test case. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#afterEach -+// */ -+// afterEach(title: string, fn?: Func): this; -+ -+// /** -+// * Run `fn(test[, done])` after each test case. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#afterEach -+// */ -+// afterEach(title: string, fn?: AsyncFunc): this; -+ -+// /** -+// * Add a test `suite`. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#addSuite -+// */ -+// addSuite(suite: Suite): this; -+ -+// /** -+// * Add a `test` to this suite. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#addTest -+// */ -+// addTest(test: Test): this; -+ -+// /** -+// * Cleans all references from this suite and all child suites. -+// * -+// * https://mochajs.org/api/suite#dispose -+// */ -+// dispose(): void; -+ -+// /** -+// * Return the full title generated by recursively concatenating the parent's -+// * full title. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#fullTitle -+// */ -+// fullTitle(): string; -+ -+// /** -+// * Return the title path generated by recursively concatenating the parent's -+// * title path. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#titlePath -+// */ -+// titlePath(): string[]; -+ -+// /** -+// * Return the total number of tests. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#total -+// */ -+// total(): number; -+ -+// /** -+// * Iterates through each suite recursively to find all tests. Applies a -+// * function in the format `fn(test)`. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#eachTest -+// */ -+// eachTest(fn: (test: Test) => void): this; -+ -+// /** -+// * This will run the root suite if we happen to be running in delayed mode. -+// * -+// * @see https://mochajs.org/api/Mocha.Suite.html#run -+// */ -+// run(): void; -+ -+// /** -+// * Generic hook-creator. -+// */ -+// protected _createHook(title: string, fn?: Func | AsyncFunc): Hook; -+// } -+ -+// // #region Suite "beforeAll" event -+// interface Suite extends NodeJS.EventEmitter { -+// on(event: "beforeAll", listener: (hook: Hook) => void): this; -+// once(event: "beforeAll", listener: (hook: Hook) => void): this; -+// addListener(event: "beforeAll", listener: (hook: Hook) => void): this; -+// removeListener(event: "beforeAll", listener: (hook: Hook) => void): this; -+// prependListener(event: "beforeAll", listener: (hook: Hook) => void): this; -+// prependOnceListener(event: "beforeAll", listener: (hook: Hook) => void): this; -+// emit(name: "beforeAll", hook: Hook): boolean; -+// } -+// // #endregion Suite "beforeAll" event -+// // #region Suite "afterAll" event -+// interface Suite extends NodeJS.EventEmitter { -+// on(event: "afterAll", listener: (hook: Hook) => void): this; -+// once(event: "afterAll", listener: (hook: Hook) => void): this; -+// addListener(event: "afterAll", listener: (hook: Hook) => void): this; -+// removeListener(event: "afterAll", listener: (hook: Hook) => void): this; -+// prependListener(event: "afterAll", listener: (hook: Hook) => void): this; -+// prependOnceListener(event: "afterAll", listener: (hook: Hook) => void): this; -+// emit(name: "afterAll", hook: Hook): boolean; -+// } -+// // #endregion Suite "afterAll" event -+// // #region Suite "beforeEach" event -+// interface Suite extends NodeJS.EventEmitter { -+// on(event: "beforeEach", listener: (hook: Hook) => void): this; -+// once(event: "beforeEach", listener: (hook: Hook) => void): this; -+// addListener(event: "beforeEach", listener: (hook: Hook) => void): this; -+// removeListener(event: "beforeEach", listener: (hook: Hook) => void): this; -+// prependListener(event: "beforeEach", listener: (hook: Hook) => void): this; -+// prependOnceListener(event: "beforeEach", listener: (hook: Hook) => void): this; -+// emit(name: "beforeEach", hook: Hook): boolean; -+// } -+// // #endregion Suite "beforeEach" event -+// // #region Suite "afterEach" event -+// interface Suite extends NodeJS.EventEmitter { -+// on(event: "afterEach", listener: (hook: Hook) => void): this; -+// once(event: "afterEach", listener: (hook: Hook) => void): this; -+// addListener(event: "afterEach", listener: (hook: Hook) => void): this; -+// removeListener(event: "afterEach", listener: (hook: Hook) => void): this; -+// prependListener(event: "afterEach", listener: (hook: Hook) => void): this; -+// prependOnceListener(event: "afterEach", listener: (hook: Hook) => void): this; -+// emit(name: "afterEach", hook: Hook): boolean; -+// } -+// // #endregion Suite "afterEach" event -+// // #region Suite "suite" event -+// interface Suite extends NodeJS.EventEmitter { -+// on(event: "suite", listener: (suite: Suite) => void): this; -+// once(event: "suite", listener: (suite: Suite) => void): this; -+// addListener(event: "suite", listener: (suite: Suite) => void): this; -+// removeListener(event: "suite", listener: (suite: Suite) => void): this; -+// prependListener(event: "suite", listener: (suite: Suite) => void): this; -+// prependOnceListener(event: "suite", listener: (suite: Suite) => void): this; -+// emit(name: "suite", suite: Suite): boolean; -+// } -+// // #endregion Suite "suite" event -+// // #region Suite "test" event -+// interface Suite { -+// on(event: "test", listener: (test: Test) => void): this; -+// once(event: "test", listener: (test: Test) => void): this; -+// addListener(event: "test", listener: (test: Test) => void): this; -+// removeListener(event: "test", listener: (test: Test) => void): this; -+// prependListener(event: "test", listener: (test: Test) => void): this; -+// prependOnceListener(event: "test", listener: (test: Test) => void): this; -+// emit(name: "test", test: Test): boolean; -+// } -+// // #endregion Suite "test" event -+// // #region Suite "run" event -+// interface Suite extends NodeJS.EventEmitter { -+// on(event: "run", listener: () => void): this; -+// once(event: "run", listener: () => void): this; -+// addListener(event: "run", listener: () => void): this; -+// removeListener(event: "run", listener: () => void): this; -+// prependListener(event: "run", listener: () => void): this; -+// prependOnceListener(event: "run", listener: () => void): this; -+// emit(name: "run"): boolean; -+// } -+// // #endregion Suite "run" event -+// // #region Suite "pre-require" event -+// interface Suite extends NodeJS.EventEmitter { -+// on(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+// once(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+// addListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+// removeListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+// prependListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+// prependOnceListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+// emit(name: "pre-require", context: MochaGlobals, file: string, mocha: Mocha): boolean; -+// } -+// // #endregion Suite "pre-require" event -+// // #region Suite "require" event -+// interface Suite extends NodeJS.EventEmitter { -+// on(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -+// once(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -+// addListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -+// removeListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -+// prependListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -+// prependOnceListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this; -+// emit(name: "require", module: any, file: string, mocha: Mocha): boolean; -+// } -+// // #endregion Suite "require" event -+// // #region Suite "post-require" event -+// interface Suite extends NodeJS.EventEmitter { -+// on(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+// once(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+// addListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+// removeListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+// prependListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+// prependOnceListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this; -+// emit(name: "post-require", context: MochaGlobals, file: string, mocha: Mocha): boolean; -+// } -+// // #endregion Suite "post-require" event -+// // #region Suite untyped events -+// interface Suite extends NodeJS.EventEmitter { -+// on(event: string, listener: (...args: any[]) => void): this; -+// once(event: string, listener: (...args: any[]) => void): this; -+// addListener(event: string, listener: (...args: any[]) => void): this; -+// removeListener(event: string, listener: (...args: any[]) => void): this; -+// prependListener(event: string, listener: (...args: any[]) => void): this; -+// prependOnceListener(event: string, listener: (...args: any[]) => void): this; -+// emit(name: string, ...args: any[]): boolean; -+// } -+// // #endregion Runner untyped events -+ -+// /** -+// * Initialize a new `Hook` with the given `title` and callback `fn` -+// * -+// * @see https://mochajs.org/api/Hook.html -+// */ -+// class Hook extends Runnable { -+// private _error; -+ -+// type: "hook"; -+// originalTitle?: string; // added by Runner -+ -+// /** -+// * Get the test `err`. -+// * -+// * @see https://mochajs.org/api/Hook.html#error -+// */ -+// error(): any; -+ -+// /** -+// * Set the test `err`. -+// * -+// * @see https://mochajs.org/api/Hook.html#error -+// */ -+// error(err: any): void; -+// } -+ -+// /** -+// * An alternative way to define root hooks that works with parallel runs. -+// * -+// * Root hooks work with any interface, but the property names do not change. -+// * In other words, if you are using the tdd interface, suiteSetup maps to beforeAll, and setup maps to beforeEach. -+// * -+// * As with other hooks, `this` refers to to the current context object. -+// * -+// * @see https://mochajs.org/#root-hook-plugins -+// */ -+// interface RootHookObject { -+// /** -+// * In serial mode, run after all tests end, once only. -+// * In parallel mode, run after all tests end, for each file. -+// */ -+// afterAll?: Func | AsyncFunc | Func[] | AsyncFunc[]; -+// /** -+// * In serial mode (Mocha's default), before all tests begin, once only. -+// * In parallel mode, run before all tests begin, for each file. -+// */ -+// beforeAll?: Func | AsyncFunc | Func[] | AsyncFunc[]; -+// /** -+// * In both modes, run after every test. -+// */ -+// afterEach?: Func | AsyncFunc | Func[] | AsyncFunc[]; -+// /** -+// * In both modes, run before each test. -+// */ -+// beforeEach?: Func | AsyncFunc | Func[] | AsyncFunc[]; -+// } -+ -+// /** -+// * Initialize a new `Test` with the given `title` and callback `fn`. -+// * -+// * @see https://mochajs.org/api/Test.html -+// */ -+// class Test extends Runnable { -+// type: "test"; -+// speed?: "slow" | "medium" | "fast"; // added by reporters -+// err?: Error; // added by reporters -+// clone(): Test; -+// } -+ -+// /** -+// * Test statistics -+// */ -+// interface Stats { -+// suites: number; -+// tests: number; -+// passes: number; -+// pending: number; -+// failures: number; -+// start?: Date; -+// end?: Date; -+// duration?: number; -+// } -+ -+// type TestInterface = (suite: Suite) => void; -+ -+// interface ReporterConstructor { -+// new (runner: Runner, options: MochaOptions): reporters.Base; -+// } -+ -+// type Done = (err?: any) => void; -+ -+// /** -+// * Callback function used for tests and hooks. -+// */ -+// type Func = (this: Context, done: Done) => void; -+ -+// /** -+// * Async callback function used for tests and hooks. -+// */ -+// type AsyncFunc = (this: Context) => PromiseLike; -+ -+// /** -+// * Options to pass to Mocha. -+// */ -+// interface MochaOptions { -+// /** Test interfaces ("bdd", "tdd", "exports", etc.). */ -+// ui?: Interface; -+ -+// /** -+// * Reporter constructor, built-in reporter name, or reporter module path. Defaults to -+// * `"spec"`. -+// */ -+// reporter?: string | ReporterConstructor; -+ -+// /** Options to pass to the reporter. */ -+// reporterOptions?: any; -+ -+// /** Array of accepted globals. */ -+// globals?: string[]; -+ -+// /** timeout in milliseconds or time string like '1s'. */ -+// timeout?: number | string; -+ -+// /** number of times to retry failed tests. */ -+// retries?: number; -+ -+// /** bail on the first test failure. */ -+// bail?: boolean; -+ -+// /** milliseconds to wait before considering a test slow. */ -+// slow?: number; -+ -+// /** check for global variable leaks. */ -+// checkLeaks?: boolean; -+ -+// /** display the full stack trace on failure. */ -+// fullStackTrace?: boolean; -+ -+// /** string or regexp to filter tests with. */ -+// grep?: string | RegExp; -+ -+// /** Enable growl support. */ -+// growl?: boolean; -+ -+// /** Color TTY output from reporter */ -+// color?: boolean; -+ -+// /** Use inline diffs rather than +/-. */ -+// inlineDiffs?: boolean; -+ -+// /** Do not show diffs at all. */ -+// hideDiff?: boolean; -+ -+// /** Run job in parallel */ -+// parallel?: boolean; -+ -+// /** Max number of worker processes for parallel runs */ -+// jobs?: number; -+ -+// /** Assigns hooks to the root suite */ -+// rootHooks?: RootHookObject; -+ -+// asyncOnly?: boolean; -+// delay?: boolean; -+// forbidOnly?: boolean; -+// forbidPending?: boolean; -+// noHighlighting?: boolean; -+// allowUncaught?: boolean; -+// fullTrace?: boolean; -+// } -+ -+// interface MochaInstanceOptions extends MochaOptions { -+// files?: string[]; -+// } -+ -+// /** -+// * Variables added to the global scope by Mocha when run in the CLI. -+// */ -+// interface MochaGlobals { -+// /** -+// * Execute before running tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#before -+// */ -+// before: HookFunction; -+ -+// /** -+// * Execute after running tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#after -+// */ -+// after: HookFunction; -+ -+// /** -+// * Execute before each test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#beforeEach -+// */ -+// beforeEach: HookFunction; -+ -+// /** -+// * Execute after each test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#afterEach -+// */ -+// afterEach: HookFunction; -+ -+// /** -+// * Describe a "suite" containing nested suites and tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// describe: SuiteFunction; -+ -+// /** -+// * Describe a "suite" containing nested suites and tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// context: SuiteFunction; -+ -+// /** -+// * Pending suite. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// xdescribe: PendingSuiteFunction; -+ -+// /** -+// * Pending suite. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// xcontext: PendingSuiteFunction; -+ -+// /** -+// * Describes a test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// it: TestFunction; -+ -+// /** -+// * Describes a test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// specify: TestFunction; -+ -+// /** -+// * Describes a pending test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// xit: PendingTestFunction; -+ -+// /** -+// * Describes a pending test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// xspecify: PendingTestFunction; -+ -+// /** -+// * Execute before running tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#before -+// */ -+// suiteSetup: HookFunction; -+ -+// /** -+// * Execute after running tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#after -+// */ -+// suiteTeardown: HookFunction; -+ -+// /** -+// * Execute before each test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#beforeEach -+// */ -+// setup: HookFunction; -+ -+// /** -+// * Execute after each test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#afterEach -+// */ -+// teardown: HookFunction; -+ -+// /** -+// * Describe a "suite" containing nested suites and tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// suite: SuiteFunction; -+ -+// /** -+// * Describes a test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// test: TestFunction; -+ -+// run: typeof run; -+// } -+ -+// /** -+// * Third-party declarations that want to add new entries to the `Reporter` union can -+// * contribute names here. -+// */ -+// interface ReporterContributions { -+// Base: never; -+// base: never; -+// Dot: never; -+// dot: never; -+// TAP: never; -+// tap: never; -+// JSON: never; -+// json: never; -+// HTML: never; -+// html: never; -+// List: never; -+// list: never; -+// Min: never; -+// min: never; -+// Spec: never; -+// spec: never; -+// Nyan: never; -+// nyan: never; -+// XUnit: never; -+// xunit: never; -+// Markdown: never; -+// markdown: never; -+// Progress: never; -+// progress: never; -+// Landing: never; -+// landing: never; -+// JSONStream: never; -+// "json-stream": never; -+// } -+ -+// type Reporter = keyof ReporterContributions; -+ -+// /** -+// * Third-party declarations that want to add new entries to the `Interface` union can -+// * contribute names here. -+// */ -+// interface InterfaceContributions { -+// bdd: never; -+// tdd: never; -+// qunit: never; -+// exports: never; -+// } -+ -+// type Interface = keyof InterfaceContributions; -+// } -+ -+// // #region Test interface augmentations -+ -+// /** -+// * Triggers root suite execution. -+// * -+// * - _Only available if flag --delay is passed into Mocha._ -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#runWithSuite -+// */ -+// declare function run(): void; -+ -+// /** -+// * Execute before running tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#before -+// */ -+// declare var before: Mocha.HookFunction; -+ -+// /** -+// * Execute before running tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#before -+// */ -+// declare var suiteSetup: Mocha.HookFunction; -+ -+// /** -+// * Execute after running tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#after -+// */ -+// declare var after: Mocha.HookFunction; -+ -+// /** -+// * Execute after running tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#after -+// */ -+// declare var suiteTeardown: Mocha.HookFunction; -+ -+// /** -+// * Execute before each test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#beforeEach -+// */ -+// declare var beforeEach: Mocha.HookFunction; -+ -+// /** -+// * Execute before each test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#beforeEach -+// */ -+// declare var setup: Mocha.HookFunction; -+ -+// /** -+// * Execute after each test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#afterEach -+// */ -+// declare var afterEach: Mocha.HookFunction; -+ -+// /** -+// * Execute after each test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// * -+// * @see https://mochajs.org/api/global.html#afterEach -+// */ -+// declare var teardown: Mocha.HookFunction; -+ -+// /** -+// * Describe a "suite" containing nested suites and tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// declare var describe: Mocha.SuiteFunction; -+ -+// /** -+// * Describe a "suite" containing nested suites and tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// declare var context: Mocha.SuiteFunction; -+ -+// /** -+// * Describe a "suite" containing nested suites and tests. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// declare var suite: Mocha.SuiteFunction; -+ -+// /** -+// * Pending suite. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// declare var xdescribe: Mocha.PendingSuiteFunction; -+ -+// /** -+// * Pending suite. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// declare var xcontext: Mocha.PendingSuiteFunction; -+ -+// /** -+// * Describes a test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// declare var it: Mocha.TestFunction; -+ -+// /** -+// * Describes a test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// declare var specify: Mocha.TestFunction; -+ -+// /** -+// * Describes a test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// declare var test: Mocha.TestFunction; -+ -+// /** -+// * Describes a pending test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// declare var xit: Mocha.PendingTestFunction; -+ -+// /** -+// * Describes a pending test case. -+// * -+// * - _Only available when invoked via the mocha CLI._ -+// */ -+// declare var xspecify: Mocha.PendingTestFunction; -+ -+// // #endregion Test interface augmentations -+ -+// // #region Reporter augmentations -+ -+// // Forward declaration for `HTMLLIElement` from lib.dom.d.ts. -+// // Required by Mocha.reporters.HTML. -+// // NOTE: Mocha *must not* have a direct dependency on DOM types. -+// // tslint:disable-next-line no-empty-interface -+// interface HTMLLIElement { } -+ -+// // Augments the DOM `Window` object when lib.dom.d.ts is loaded. -+// // tslint:disable-next-line no-empty-interface -+// interface Window extends Mocha.MochaGlobals { } -+ -+// declare namespace NodeJS { -+// // Forward declaration for `NodeJS.EventEmitter` from node.d.ts. -+// // Required by Mocha.Runnable, Mocha.Runner, and Mocha.Suite. -+// // NOTE: Mocha *must not* have a direct dependency on @types/node. -+// // tslint:disable-next-line no-empty-interface -+// interface EventEmitter { } -+ -+// // Augments NodeJS's `global` object when node.d.ts is loaded -+// // tslint:disable-next-line no-empty-interface -+// interface Global extends Mocha.MochaGlobals { } -+// } -+ -+// // #endregion Reporter augmentations -+ -+// // #region Browser augmentations -+ -+// /** -+// * Mocha global. -+// * -+// * - _Only supported in the browser._ -+// */ -+// declare const mocha: BrowserMocha; -+ -+// interface BrowserMocha extends Mocha { -+// /** -+// * Function to allow assertion libraries to throw errors directly into mocha. -+// * This is useful when running tests in a browser because window.onerror will -+// * only receive the 'message' attribute of the Error. -+// * -+// * - _Only supported in the browser._ -+// */ -+// throwError(err: any): never; -+ -+// /** -+// * Setup mocha with the given settings options. -+// * -+// * - _Only supported in the browser._ -+// */ -+// setup(opts?: Mocha.Interface | Mocha.MochaOptions): this; -+// } -+ -+// // #endregion Browser augmentations -+ -+// declare module "mocha" { -+// export = Mocha; -+// } -+ -+// declare module "mocha/lib/stats-collector" { -+// export = createStatsCollector; -+ -+// /** -+// * Provides stats such as test duration, number of tests passed / failed etc., by listening for events emitted by `runner`. -+// */ -+// function createStatsCollector(runner: Mocha.Runner): void; -+// } -+ -+// declare module "mocha/lib/interfaces/common" { -+// export = common; -+ -+// function common(suites: Mocha.Suite[], context: Mocha.MochaGlobals, mocha: Mocha): common.CommonFunctions; -+ -+// namespace common { -+// interface CommonFunctions { -+// /** -+// * This is only present if flag --delay is passed into Mocha. It triggers -+// * root suite execution. -+// */ -+// runWithSuite(suite: Mocha.Suite): () => void; -+ -+// /** -+// * Execute before running tests. -+// */ -+// before(fn?: Mocha.Func | Mocha.AsyncFunc): void; -+ -+// /** -+// * Execute before running tests. -+// */ -+// before(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; -+ -+// /** -+// * Execute after running tests. -+// */ -+// after(fn?: Mocha.Func | Mocha.AsyncFunc): void; -+ -+// /** -+// * Execute after running tests. -+// */ -+// after(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; -+ -+// /** -+// * Execute before each test case. -+// */ -+// beforeEach(fn?: Mocha.Func | Mocha.AsyncFunc): void; -+ -+// /** -+// * Execute before each test case. -+// */ -+// beforeEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; -+ -+// /** -+// * Execute after each test case. -+// */ -+// afterEach(fn?: Mocha.Func | Mocha.AsyncFunc): void; -+ -+// /** -+// * Execute after each test case. -+// */ -+// afterEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void; -+ -+// suite: SuiteFunctions; -+// test: TestFunctions; -+// } -+ -+// interface CreateOptions { -+// /** Title of suite */ -+// title: string; -+ -+// /** Suite function */ -+// fn?: (this: Mocha.Suite) => void; -+ -+// /** Is suite pending? */ -+// pending?: boolean; -+ -+// /** Filepath where this Suite resides */ -+// file?: string; -+ -+// /** Is suite exclusive? */ -+// isOnly?: boolean; -+// } -+ -+// interface SuiteFunctions { -+// /** -+// * Create an exclusive Suite; convenience function -+// */ -+// only(opts: CreateOptions): Mocha.Suite; -+ -+// /** -+// * Create a Suite, but skip it; convenience function -+// */ -+// skip(opts: CreateOptions): Mocha.Suite; -+ -+// /** -+// * Creates a suite. -+// */ -+// create(opts: CreateOptions): Mocha.Suite; -+// } -+ -+// interface TestFunctions { -+// /** -+// * Exclusive test-case. -+// */ -+// only(mocha: Mocha, test: Mocha.Test): Mocha.Test; -+ -+// /** -+// * Pending test case. -+// */ -+// skip(title: string): void; -+ -+// /** -+// * Number of retry attempts -+// */ -+// retries(n: number): void; -+// } -+// } -+// } diff --git a/yarn.lock b/yarn.lock index 767069405070..f4290d8747ef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9889,9 +9889,9 @@ integrity sha512-fZQQafSREFyuZcdWFAExYjBiCL7AUCdgsk80iO0q4yihYYdcIiH28CcuPTGFgLOCC8RlW49GSQxdHwZP+I7CNg== "@types/mocha@^8.0.3": - version "8.2.2" - resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.2.2.tgz#91daa226eb8c2ff261e6a8cbf8c7304641e095e0" - integrity sha512-Lwh0lzzqT5Pqh6z61P3c3P5nm6fzQK/MMHl9UKeneAeInVflBSz1O2EkX6gM6xfJd7FBXBY5purtLx7fUiZ7Hw== + version "8.0.3" + resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.0.3.tgz#51b21b6acb6d1b923bbdc7725c38f9f455166402" + integrity sha512-vyxR57nv8NfcU0GZu8EUXZLTbCMupIUwy95LJ6lllN+JRPG25CwMHoB1q5xKh8YKhQnHYRAn4yW2yuHbf/5xgg== "@types/mock-fs@4.10.0": version "4.10.0" From 6efd656f73ec8a67120f124a4089d3527ba2dfa3 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 20:26:05 -0600 Subject: [PATCH 67/96] remove duplicated files --- .../config/__snapshots__/index_spec.ts.js | 153 ------- .../__snapshots__/validation_spec.ts.js | 226 ---------- packages/config/test/unit/index_spec.ts | 174 -------- packages/config/test/unit/validation_spec.ts | 391 ------------------ 4 files changed, 944 deletions(-) delete mode 100644 packages/config/__snapshots__/index_spec.ts.js delete mode 100644 packages/config/__snapshots__/validation_spec.ts.js delete mode 100644 packages/config/test/unit/index_spec.ts delete mode 100644 packages/config/test/unit/validation_spec.ts diff --git a/packages/config/__snapshots__/index_spec.ts.js b/packages/config/__snapshots__/index_spec.ts.js deleted file mode 100644 index 950e55900213..000000000000 --- a/packages/config/__snapshots__/index_spec.ts.js +++ /dev/null @@ -1,153 +0,0 @@ -exports['src/index .getBreakingKeys returns list of breaking config keys 1'] = [ - "integrationFolder", - "componentFolder", - "testFiles", - "blacklistHosts", - "experimentalComponentTesting", - "experimentalGetCookiesSameSite", - "experimentalNetworkStubbing", - "experimentalRunEvents", - "experimentalShadowDomSupport", - "firefoxGcInterval", - "nodeVersion", - "nodeVersion" -] - -exports['src/index .getDefaultValues returns list of public config keys 1'] = { - "animationDistanceThreshold": 5, - "baseUrl": null, - "blockHosts": null, - "chromeWebSecurity": true, - "clientCertificates": [], - "component": { - "specPattern": "**/*.cy.{js,jsx,ts,tsx}" - }, - "defaultCommandTimeout": 4000, - "downloadsFolder": "cypress/downloads", - "e2e": { - "specPattern": "cypress/e2e/**/*.cy.{js,jsx,ts,tsx}" - }, - "env": {}, - "execTimeout": 60000, - "exit": true, - "experimentalFetchPolyfill": false, - "experimentalInteractiveRunEvents": false, - "experimentalSessionSupport": false, - "experimentalSourceRewriting": false, - "fileServerFolder": "", - "fixturesFolder": "cypress/fixtures", - "excludeSpecPattern": "*.hot-update.js", - "includeShadowDom": false, - "keystrokeDelay": 0, - "modifyObstructiveCode": true, - "numTestsKeptInMemory": 50, - "pageLoadTimeout": 60000, - "pluginsFile": "cypress/plugins", - "port": null, - "projectId": null, - "redirectionLimit": 20, - "reporter": "spec", - "reporterOptions": null, - "requestTimeout": 5000, - "resolvedNodePath": null, - "resolvedNodeVersion": null, - "responseTimeout": 30000, - "retries": { - "runMode": 0, - "openMode": 0 - }, - "screenshotOnRunFailure": true, - "screenshotsFolder": "cypress/screenshots", - "slowTestThreshold": 10000, - "scrollBehavior": "top", - "supportFile": "cypress/support/e2e.{js,jsx,ts,tsx}", - "supportFolder": false, - "taskTimeout": 60000, - "trashAssetsBeforeRuns": true, - "userAgent": null, - "video": true, - "videoCompression": 32, - "videosFolder": "cypress/videos", - "videoUploadOnPasses": true, - "viewportHeight": 660, - "viewportWidth": 1000, - "waitForAnimations": true, - "watchForFileChanges": true, - "autoOpen": false, - "browsers": [], - "clientRoute": "/__/", - "configFile": "cypress.config.js", - "devServerPublicPathRoute": "/__cypress/src", - "hosts": null, - "isInteractive": true, - "isTextTerminal": false, - "morgan": true, - "namespace": "__cypress", - "reporterRoute": "/__cypress/reporter", - "socketId": null, - "socketIoCookie": "__socket.io", - "socketIoRoute": "/__socket.io", - "xhrRoute": "/xhrs/" -} - -exports['src/index .getPublicConfigKeys returns list of public config keys 1'] = [ - "animationDistanceThreshold", - "arch", - "baseUrl", - "blockHosts", - "chromeWebSecurity", - "clientCertificates", - "component", - "defaultCommandTimeout", - "downloadsFolder", - "e2e", - "env", - "execTimeout", - "exit", - "experimentalFetchPolyfill", - "experimentalInteractiveRunEvents", - "experimentalSessionSupport", - "experimentalSourceRewriting", - "fileServerFolder", - "fixturesFolder", - "excludeSpecPattern", - "includeShadowDom", - "keystrokeDelay", - "modifyObstructiveCode", - "nodeVersion", - "numTestsKeptInMemory", - "platform", - "pageLoadTimeout", - "pluginsFile", - "port", - "projectId", - "redirectionLimit", - "reporter", - "reporterOptions", - "requestTimeout", - "resolvedNodePath", - "resolvedNodeVersion", - "responseTimeout", - "retries", - "screenshotOnRunFailure", - "screenshotsFolder", - "slowTestThreshold", - "scrollBehavior", - "supportFile", - "supportFolder", - "taskTimeout", - "trashAssetsBeforeRuns", - "userAgent", - "video", - "videoCompression", - "videosFolder", - "videoUploadOnPasses", - "viewportHeight", - "viewportWidth", - "waitForAnimations", - "watchForFileChanges", - "browsers", - "hosts", - "isInteractive", - "modifyObstructiveCode" -] diff --git a/packages/config/__snapshots__/validation_spec.ts.js b/packages/config/__snapshots__/validation_spec.ts.js deleted file mode 100644 index 1b3d0e62bfce..000000000000 --- a/packages/config/__snapshots__/validation_spec.ts.js +++ /dev/null @@ -1,226 +0,0 @@ -exports['src/validation .isValidClientCertificatesSet returns error message for certs not passed as an array array 1'] = { - "key": "mockConfigKey", - "value": "1", - "type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls" -} - -exports['src/validation .isValidClientCertificatesSet returns error message for certs object without url 1'] = { - "key": "clientCertificates[0].url", - "type": "a URL matcher" -} - -exports['missing https protocol'] = { - "key": "clientCertificates[0].url", - "value": "http://url.com", - "type": "an https protocol" -} - -exports['invalid url'] = { - "key": "clientCertificates[0].url", - "value": "not *", - "type": "a valid URL" -} - -exports['src/validation .isValidBrowser passes valid browsers and forms error messages for invalid ones isValidBrowser 1'] = { - "name": "isValidBrowser", - "behavior": [ - { - "given": { - "name": "Chrome", - "displayName": "Chrome Browser", - "family": "chromium", - "path": "/path/to/chrome", - "version": "1.2.3", - "majorVersion": 1 - }, - "expect": true - }, - { - "given": { - "name": "FF", - "displayName": "Firefox", - "family": "firefox", - "path": "/path/to/firefox", - "version": "1.2.3", - "majorVersion": "1" - }, - "expect": true - }, - { - "given": { - "name": "Electron", - "displayName": "Electron", - "family": "chromium", - "path": "", - "version": "99.101.3", - "majorVersion": 99 - }, - "expect": true - }, - { - "given": { - "name": "No display name", - "family": "chromium" - }, - "expect": { - "key": "displayName", - "value": { - "name": "No display name", - "family": "chromium" - }, - "type": "a non-empty string" - } - }, - { - "given": { - "name": "bad family", - "displayName": "Bad family browser", - "family": "unknown family" - }, - "expect": { - "key": "family", - "value": { - "name": "bad family", - "displayName": "Bad family browser", - "family": "unknown family" - }, - "type": "either chromium or firefox" - } - } - ] -} - -exports['undefined browsers'] = ` -Missing browsers list -` - -exports['empty list of browsers'] = ` -Expected at least one browser -` - -exports['browsers list with a string'] = { - "key": "name", - "value": "foo", - "type": "a non-empty string", - "list": "browsers" -} - -exports['invalid retry value'] = { - "key": "mockConfigKey", - "value": "1", - "type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls" -} - -exports['invalid retry object'] = { - "key": "mockConfigKey", - "value": { - "fakeMode": 1 - }, - "type": "a positive number or null or an object with keys \"openMode\" and \"runMode\" with values of numbers or nulls" -} - -exports['src/validation .isPlainObject returns error message when value is a not an object 1'] = { - "key": "mockConfigKey", - "value": 1, - "type": "a plain object" -} - -exports['src/validation .isNumber returns error message when value is a not a number 1'] = { - "key": "mockConfigKey", - "value": "string", - "type": "a number" -} - -exports['src/validation .isNumberOrFalse returns error message when value is a not number or false 1'] = { - "key": "mockConfigKey", - "value": null, - "type": "a number or false" -} - -exports['not qualified url'] = { - "key": "mockConfigKey", - "value": "url.com", - "type": "a fully qualified URL (starting with `http://` or `https://`)" -} - -exports['empty string'] = { - "key": "mockConfigKey", - "value": "", - "type": "a fully qualified URL (starting with `http://` or `https://`)" -} - -exports['src/validation .isBoolean returns error message when value is a not a string 1'] = { - "key": "mockConfigKey", - "value": 1, - "type": "a string" -} - -exports['src/validation .isString returns error message when value is a not a string 1'] = { - "key": "mockConfigKey", - "value": 1, - "type": "a string" -} - -exports['src/validation .isArray returns error message when value is a non-array 1'] = { - "key": "mockConfigKey", - "value": 1, - "type": "an array" -} - -exports['src/validation .isStringOrFalse returns error message when value is neither string nor false 1'] = { - "key": "mockConfigKey", - "value": null, - "type": "a string or false" -} - -exports['not string or array'] = { - "key": "mockConfigKey", - "value": null, - "type": "a string or an array of strings" -} - -exports['array of non-strings'] = { - "key": "mockConfigKey", - "value": [ - 1, - 2, - 3 - ], - "type": "a string or an array of strings" -} - -exports['not one of the strings error message'] = { - "key": "test", - "value": "nope", - "type": "one of these values: \"foo\", \"bar\"" -} - -exports['number instead of string'] = { - "key": "test", - "value": 42, - "type": "one of these values: \"foo\", \"bar\"" -} - -exports['null instead of string'] = { - "key": "test", - "value": null, - "type": "one of these values: \"foo\", \"bar\"" -} - -exports['not one of the numbers error message'] = { - "key": "test", - "value": 4, - "type": "one of these values: 1, 2, 3" -} - -exports['string instead of a number'] = { - "key": "test", - "value": "foo", - "type": "one of these values: 1, 2, 3" -} - -exports['null instead of a number'] = { - "key": "test", - "value": null, - "type": "one of these values: 1, 2, 3" -} diff --git a/packages/config/test/unit/index_spec.ts b/packages/config/test/unit/index_spec.ts deleted file mode 100644 index b9edcf34896d..000000000000 --- a/packages/config/test/unit/index_spec.ts +++ /dev/null @@ -1,174 +0,0 @@ -import chai from 'chai' -import snapshot from 'snap-shot-it' -import sinon from 'sinon' -import sinonChai from 'sinon-chai' - -import * as configUtil from '../../src/index' - -chai.use(sinonChai) -const { expect } = chai - -describe('src/index', () => { - describe('.allowed', () => { - it('returns filter config only containing allowed keys', () => { - const keys = configUtil.allowed({ - 'baseUrl': 'https://url.com', - 'blacklistHosts': 'breaking option', - 'devServerPublicPathRoute': 'internal key', - 'random': 'not a config option', - }) - - expect(keys).to.deep.eq({ - 'baseUrl': 'https://url.com', - 'blacklistHosts': 'breaking option', - }) - }) - }) - - describe('.getBreakingKeys', () => { - it('returns list of breaking config keys', () => { - const breakingKeys = configUtil.getBreakingKeys() - - expect(breakingKeys).to.include('blacklistHosts') - snapshot(breakingKeys) - }) - }) - - describe('.getDefaultValues', () => { - it('returns list of public config keys', () => { - const defaultValues = configUtil.getDefaultValues() - - expect(defaultValues).to.deep.include({ - defaultCommandTimeout: 4000, - scrollBehavior: 'top', - watchForFileChanges: true, - }) - - expect(defaultValues.env).to.deep.eq({}) - - // remove these since they are different depending on your machine - ;['platform', 'arch', 'version'].forEach((x) => { - expect(defaultValues[x]).to.exist - delete defaultValues[x] - }) - - snapshot(defaultValues) - }) - }) - - describe('.getPublicConfigKeys', () => { - it('returns list of public config keys', () => { - const publicConfigKeys = configUtil.getPublicConfigKeys() - - expect(publicConfigKeys).to.include('blockHosts') - expect(publicConfigKeys).to.not.include('devServerPublicPathRoute') - snapshot(publicConfigKeys) - }) - }) - - describe('.matchesConfigKey', () => { - it('returns normalized key when config key has a default value', () => { - let normalizedKey = configUtil.matchesConfigKey('EXEC_TIMEOUT') - - expect(normalizedKey).to.eq('execTimeout') - - normalizedKey = configUtil.matchesConfigKey('Base-url') - expect(normalizedKey).to.eq('baseUrl') - }) - - it('returns nothing when config key does not has a default value', () => { - let normalizedKey = configUtil.matchesConfigKey('random') - - expect(normalizedKey).to.be.undefined - }) - }) - - describe('.validate', () => { - it('validates config', () => { - const errorFn = sinon.spy() - - configUtil.validate({ - 'baseUrl': 'https://', - }, errorFn) - - expect(errorFn).to.have.callCount(0) - }) - - it('calls error callback if config is invalid', () => { - const errorFn = sinon.spy() - - configUtil.validate({ - 'baseUrl': ' ', - }, errorFn) - - expect(errorFn).to.have.been.calledWithMatch({ key: 'baseUrl' }) - expect(errorFn).to.have.been.calledWithMatch({ type: 'a fully qualified URL (starting with `http://` or `https://`)' }) - }) - }) - - describe('.validateNoBreakingConfig', () => { - it('calls warning callback if config contains breaking option that warns', () => { - const warningFn = sinon.spy() - const errorFn = sinon.spy() - - configUtil.validateNoBreakingConfig({ - 'experimentalNetworkStubbing': 'should break', - configFile: 'config.js', - }, warningFn, errorFn) - - expect(warningFn).to.have.been.calledOnceWith('EXPERIMENTAL_NETWORK_STUBBING_REMOVED', { - name: 'experimentalNetworkStubbing', - newName: undefined, - value: undefined, - configFile: 'config.js', - }) - - expect(errorFn).to.have.callCount(0) - }) - - it('calls error callback if config contains breaking option that should throw an error', () => { - const warningFn = sinon.spy() - const errorFn = sinon.spy() - - configUtil.validateNoBreakingConfig({ - 'blacklistHosts': 'should break', - configFile: 'config.js', - }, warningFn, errorFn) - - expect(warningFn).to.have.been.callCount(0) - expect(errorFn).to.have.been.calledOnceWith('RENAMED_CONFIG_OPTION', { - name: 'blacklistHosts', - newName: 'blockHosts', - value: undefined, - configFile: 'config.js', - }) - }) - }) - - describe('.validateNoReadOnlyConfig', () => { - it('returns an error if validation fails', () => { - const errorFn = sinon.spy() - - configUtil.validateNoReadOnlyConfig({ chromeWebSecurity: false }, errorFn) - - expect(errorFn).to.have.callCount(1) - expect(errorFn).to.have.been.calledWithMatch(/chromeWebSecurity/) - }) - - it('does not return an error if validation succeeds', () => { - const errorFn = sinon.spy() - - configUtil.validateNoReadOnlyConfig({ requestTimeout: 1000 }, errorFn) - - expect(errorFn).to.have.callCount(0) - }) - - it('does not return an error if configuration is a non-Cypress config option', () => { - const errorFn = sinon.spy() - - configUtil.validateNoReadOnlyConfig({ foo: 'bar' }, errorFn) - - expect(errorFn).to.have.callCount(0) - }) - }) -}) diff --git a/packages/config/test/unit/validation_spec.ts b/packages/config/test/unit/validation_spec.ts deleted file mode 100644 index ff8566e2ddfb..000000000000 --- a/packages/config/test/unit/validation_spec.ts +++ /dev/null @@ -1,391 +0,0 @@ -import snapshot from 'snap-shot-it' -import { expect } from 'chai' - -import * as validation from '../../src/validation' - -describe('src/validation', () => { - const mockKey = 'mockConfigKey' - - describe('.isValidClientCertificatesSet', () => { - it('returns error message for certs not passed as an array array', () => { - const result = validation.isValidRetriesConfig(mockKey, '1') - - expect(result).to.not.be.true - snapshot(result) - }) - - it('returns error message for certs object without url', () => { - const result = validation.isValidClientCertificatesSet(mockKey, [ - { name: 'cert' }, - ]) - - expect(result).to.not.be.true - snapshot(result) - }) - - it('returns error message for certs url not matching *', () => { - let result = validation.isValidClientCertificatesSet(mockKey, [ - { url: 'http://url.com' }, - ]) - - expect(result).to.not.be.true - snapshot('missing https protocol', result) - - result = validation.isValidClientCertificatesSet(mockKey, [ - { url: 'not *' }, - ]) - - expect(result).to.not.be.true - snapshot('invalid url', result) - }) - }) - - describe('.isValidBrowser', () => { - it('passes valid browsers and forms error messages for invalid ones', () => { - const browsers = [ - // valid browser - { - name: 'Chrome', - displayName: 'Chrome Browser', - family: 'chromium', - path: '/path/to/chrome', - version: '1.2.3', - majorVersion: 1, - }, - // another valid browser - { - name: 'FF', - displayName: 'Firefox', - family: 'firefox', - path: '/path/to/firefox', - version: '1.2.3', - majorVersion: '1', - }, - // Electron is a valid browser - { - name: 'Electron', - displayName: 'Electron', - family: 'chromium', - path: '', - version: '99.101.3', - majorVersion: 99, - }, - // invalid browser, missing displayName - { - name: 'No display name', - family: 'chromium', - }, - { - name: 'bad family', - displayName: 'Bad family browser', - family: 'unknown family', - }, - ] - - // data-driven testing - computers snapshot value for each item in the list passed through the function - // https://github.com/bahmutov/snap-shot-it#data-driven-testing - return snapshot.apply(null, [validation.isValidBrowser].concat(browsers as any)) - }) - }) - - describe('.isValidBrowserList', () => { - it('does not allow empty or not browsers', () => { - snapshot('undefined browsers', validation.isValidBrowserList('browsers', undefined)) - snapshot('empty list of browsers', validation.isValidBrowserList('browsers', [])) - - return snapshot('browsers list with a string', validation.isValidBrowserList('browsers', ['foo'])) - }) - }) - - describe('.isValidRetriesConfig', () => { - it('returns true for valid retry value', () => { - let result = validation.isValidRetriesConfig(mockKey, null) - - expect(result).to.be.true - - result = validation.isValidRetriesConfig(mockKey, 2) - expect(result).to.be.true - }) - - it('returns true for valid retry objects', () => { - let result = validation.isValidRetriesConfig(mockKey, { runMode: 1 }) - - expect(result).to.be.true - - result = validation.isValidRetriesConfig(mockKey, { openMode: 1 }) - expect(result).to.be.true - - result = validation.isValidRetriesConfig(mockKey, { - runMode: 3, - openMode: 0, - }) - - expect(result).to.be.true - }) - - it('returns error message for invalid retry config', () => { - let result = validation.isValidRetriesConfig(mockKey, '1') - - expect(result).to.not.be.true - snapshot('invalid retry value', result) - - result = validation.isValidRetriesConfig(mockKey, { fakeMode: 1 }) - expect(result).to.not.be.true - snapshot('invalid retry object', result) - }) - }) - - describe('.isPlainObject', () => { - it('returns true for value=null', () => { - const result = validation.isPlainObject(mockKey, null) - - expect(result).to.be.true - }) - - it('returns true for value=number', () => { - const result = validation.isPlainObject(mockKey, { foo: 'bar' }) - - expect(result).to.be.true - }) - - it('returns error message when value is a not an object', () => { - const result = validation.isPlainObject(mockKey, 1) - - expect(result).to.not.be.true - snapshot(result) - }) - }) - - describe('.isNumber', () => { - it('returns true for value=null', () => { - const result = validation.isNumber(mockKey, null) - - expect(result).to.be.true - }) - - it('returns true for value=number', () => { - const result = validation.isNumber(mockKey, 1) - - expect(result).to.be.true - }) - - it('returns error message when value is a not a number', () => { - const result = validation.isNumber(mockKey, 'string') - - expect(result).to.not.be.true - snapshot(result) - }) - }) - - describe('.isNumberOrFalse', () => { - it('returns true for value=number', () => { - const result = validation.isNumberOrFalse(mockKey, 1) - - expect(result).to.be.true - }) - - it('returns true for value=false', () => { - const result = validation.isNumberOrFalse(mockKey, false) - - expect(result).to.be.true - }) - - it('returns error message when value is a not number or false', () => { - const result = validation.isNumberOrFalse(mockKey, null) - - expect(result).to.not.be.true - snapshot(result) - }) - }) - - describe('.isFullyQualifiedUrl', () => { - it('returns true for value=null', () => { - const result = validation.isFullyQualifiedUrl(mockKey, null) - - expect(result).to.be.true - }) - - it('returns true for value=qualified urls', () => { - let result = validation.isFullyQualifiedUrl(mockKey, 'https://url.com') - - expect(result).to.be.true - result = validation.isFullyQualifiedUrl(mockKey, 'http://url.com') - expect(result).to.be.true - }) - - it('returns error message when value is a not qualified url', () => { - let result = validation.isFullyQualifiedUrl(mockKey, 'url.com') - - expect(result).to.not.be.true - snapshot('not qualified url', result) - - result = validation.isFullyQualifiedUrl(mockKey, '') - expect(result).to.not.be.true - snapshot('empty string', result) - }) - }) - - describe('.isBoolean', () => { - it('returns true for value=null', () => { - const result = validation.isBoolean(mockKey, null) - - expect(result).to.be.true - }) - - it('returns true for value=true', () => { - const result = validation.isBoolean(mockKey, true) - - expect(result).to.be.true - }) - - it('returns true for value=false', () => { - const result = validation.isBoolean(mockKey, false) - - expect(result).to.be.true - }) - - it('returns error message when value is a not a string', () => { - const result = validation.isString(mockKey, 1) - - expect(result).to.not.be.true - snapshot(result) - }) - }) - - describe('.isString', () => { - it('returns true for value=null', () => { - const result = validation.isString(mockKey, null) - - expect(result).to.be.true - }) - - it('returns true for value=array', () => { - const result = validation.isString(mockKey, 'string') - - expect(result).to.be.true - }) - - it('returns error message when value is a not a string', () => { - const result = validation.isString(mockKey, 1) - - expect(result).to.not.be.true - snapshot(result) - }) - }) - - describe('.isArray', () => { - it('returns true for value=null', () => { - const result = validation.isArray(mockKey, null) - - expect(result).to.be.true - }) - - it('returns true for value=array', () => { - const result = validation.isArray(mockKey, [1, 2, 3]) - - expect(result).to.be.true - }) - - it('returns error message when value is a non-array', () => { - const result = validation.isArray(mockKey, 1) - - expect(result).to.not.be.true - snapshot(result) - }) - }) - - describe('.isStringOrFalse', () => { - it('returns true for value=string', () => { - const result = validation.isStringOrFalse(mockKey, 'string') - - expect(result).to.be.true - }) - - it('returns true for value=false', () => { - const result = validation.isStringOrFalse(mockKey, false) - - expect(result).to.be.true - }) - - it('returns error message when value is neither string nor false', () => { - const result = validation.isStringOrFalse(mockKey, null) - - expect(result).to.not.be.true - snapshot(result) - }) - }) - - describe('.isStringOrArrayOfStrings', () => { - it('returns true for value=string', () => { - const result = validation.isStringOrArrayOfStrings(mockKey, 'string') - - expect(result).to.be.true - }) - - it('returns true for value=array of strings', () => { - const result = validation.isStringOrArrayOfStrings(mockKey, ['string', 'other']) - - expect(result).to.be.true - }) - - it('returns error message when value is neither string nor array of string', () => { - let result = validation.isStringOrArrayOfStrings(mockKey, null) - - expect(result).to.not.be.true - snapshot('not string or array', result) - - result = validation.isStringOrArrayOfStrings(mockKey, [1, 2, 3]) - - expect(result).to.not.be.true - snapshot('array of non-strings', result) - }) - }) - - describe('.isOneOf', () => { - it('validates a string', () => { - const validate = validation.isOneOf('foo', 'bar') - - expect(validate).to.be.a('function') - expect(validate('test', 'foo')).to.be.true - expect(validate('test', 'bar')).to.be.true - - // different value - let msg = validate('test', 'nope') - - expect(msg).to.not.be.true - snapshot('not one of the strings error message', msg) - - msg = validate('test', 42) - expect(msg).to.not.be.true - snapshot('number instead of string', msg) - - msg = validate('test', null) - expect(msg).to.not.be.true - - return snapshot('null instead of string', msg) - }) - - it('validates a number', () => { - const validate = validation.isOneOf(1, 2, 3) - - expect(validate).to.be.a('function') - expect(validate('test', 1)).to.be.true - expect(validate('test', 3)).to.be.true - - // different value - let msg = validate('test', 4) - - expect(msg).to.not.be.true - snapshot('not one of the numbers error message', msg) - - msg = validate('test', 'foo') - expect(msg).to.not.be.true - snapshot('string instead of a number', msg) - - msg = validate('test', null) - expect(msg).to.not.be.true - - return snapshot('null instead of a number', msg) - }) - }) -}) From 28062760aa8ba7ea4cf6c15fee8df952eb501e95 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 20:28:44 -0600 Subject: [PATCH 68/96] restore ts --- packages/ts/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ts/tsconfig.json b/packages/ts/tsconfig.json index 3a420e646393..9a1b1089b971 100644 --- a/packages/ts/tsconfig.json +++ b/packages/ts/tsconfig.json @@ -3,7 +3,7 @@ /* Basic Options */ "target": "ES2018", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ - "lib": ["es2018", "ES2020.Promise", "DOM"], /* Specify library files to be included in the compilation: */ + "lib": ["es2018", "ES2020.Promise"], /* Specify library files to be included in the compilation: */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ From 2c7f11b5e9560fde043212d06790d106c3cde789 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Fri, 11 Mar 2022 20:44:57 -0600 Subject: [PATCH 69/96] check root options too --- packages/config/src/options.ts | 22 ++++++++++++++----- .../plugins/child/wrap-non-migrated-config.js | 8 +++++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/packages/config/src/options.ts b/packages/config/src/options.ts index 17abd65d9af9..6016090e8a6c 100644 --- a/packages/config/src/options.ts +++ b/packages/config/src/options.ts @@ -16,7 +16,7 @@ export type BreakingOptionErrorKey = | 'CONFIG_FILE_INVALID_ROOT_CONFIG' | 'CONFIG_FILE_INVALID_ROOT_CONFIG_E2E' | 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT' - | 'TEST_FILES_DEPRECATION' + | 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN' type TestingType = 'e2e' | 'component' @@ -512,6 +512,21 @@ export const options: Array = [ * Values not allowed in 10.X+ in the root, e2e and component config */ export const breakingOptions: Array = [ + { + name: 'integrationFolder', + errorKey: 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN', + isWarning: false, + }, + { + name: 'componentFolder', + errorKey: 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN', + isWarning: false, + }, + { + name: 'testFiles', + errorKey: 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN', + isWarning: false, + }, { name: 'blacklistHosts', errorKey: 'RENAMED_CONFIG_OPTION', @@ -551,11 +566,6 @@ export const breakingOptions: Array = [ errorKey: 'NODE_VERSION_DEPRECATION_BUNDLED', isWarning: true, }, - { - name: 'testFiles', - errorKey: 'TEST_FILES_DEPRECATION', - isWarning: false, - }, ] export const breakingRootOptions: Array = [ diff --git a/packages/server/lib/plugins/child/wrap-non-migrated-config.js b/packages/server/lib/plugins/child/wrap-non-migrated-config.js index f34306b70b35..0ceadf6aae75 100644 --- a/packages/server/lib/plugins/child/wrap-non-migrated-config.js +++ b/packages/server/lib/plugins/child/wrap-non-migrated-config.js @@ -1,7 +1,7 @@ const debugLib = require('debug') const debug = debugLib(`cypress:lifecycle:child:WrapNonMigrated:${process.pid}`) -const { breakingOptions } = require('@packages/config') +const { breakingOptions, breakingRootOptions } = require('@packages/config') /** * Throw the error with the proper codeFrame @@ -13,7 +13,7 @@ function throwInvalidOptionError (errorKey, name) { const errInternal = new Error() Error.captureStackTrace(errInternal, throwInvalidOptionError) - const err = require('@packages/errors').getError(errorKey, { name }, errInternal) + const err = require('@packages/errors').getError(errorKey, { name, setupNodeEvents: true }, errInternal) throw err } @@ -51,4 +51,8 @@ module.exports = function wrapNonMigratedOptions (options) { setInvalidPropSetterWarning(options[testingType], errorKey, name, `${testingType}.${name}`) }) }) + + breakingRootOptions.filter(({ isWarning }) => !isWarning).forEach(({ name, errorKey }) => { + setInvalidPropSetterWarning(options, errorKey, name) + }) } From 0e7632f54a1222def6de4d67d3912be5b7fee873 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 22 Mar 2022 10:48:55 -0500 Subject: [PATCH 70/96] remove mocha changes --- cli/package.json | 2 +- npm/cypress-schematic/package.json | 2 +- npm/webpack-batteries-included-preprocessor/package.json | 2 +- npm/webpack-preprocessor/package.json | 2 +- package.json | 2 +- packages/errors/package.json | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/package.json b/cli/package.json index aa1cd92cb095..e8226e5f6bc6 100644 --- a/cli/package.json +++ b/cli/package.json @@ -73,7 +73,7 @@ "@types/jquery": "3.3.31", "@types/lodash": "4.14.168", "@types/minimatch": "3.0.3", - "@types/mocha": "^8.0.3", + "@types/mocha": "8.0.3", "@types/sinon": "9.0.9", "@types/sinon-chai": "3.2.5", "chai": "3.5.0", diff --git a/npm/cypress-schematic/package.json b/npm/cypress-schematic/package.json index 129bad5cc19c..de5a50461c22 100644 --- a/npm/cypress-schematic/package.json +++ b/npm/cypress-schematic/package.json @@ -29,7 +29,7 @@ "@angular-devkit/schematics-cli": "^12.2.10", "@angular/cli": "^12", "@types/chai-enzyme": "0.6.7", - "@types/mocha": "^8.0.3", + "@types/mocha": "8.0.3", "@types/node": "^12.11.1", "chai": "4.2.0", "cypress": "0.0.0-development", diff --git a/npm/webpack-batteries-included-preprocessor/package.json b/npm/webpack-batteries-included-preprocessor/package.json index 93948ff493f9..1420de1f13c2 100644 --- a/npm/webpack-batteries-included-preprocessor/package.json +++ b/npm/webpack-batteries-included-preprocessor/package.json @@ -27,7 +27,7 @@ "devDependencies": { "@cypress/eslint-plugin-dev": "0.0.0-development", "@cypress/webpack-preprocessor": "0.0.0-development", - "@types/mocha": "^8.0.3", + "@types/mocha": "8.0.3", "@types/webpack": "^4.41.21", "@typescript-eslint/eslint-plugin": "^4.18.0", "@typescript-eslint/parser": "^4.18.0", diff --git a/npm/webpack-preprocessor/package.json b/npm/webpack-preprocessor/package.json index 20c8dfbe992a..5094cca30b70 100644 --- a/npm/webpack-preprocessor/package.json +++ b/npm/webpack-preprocessor/package.json @@ -29,7 +29,7 @@ "@babel/plugin-proposal-nullish-coalescing-operator": "7.8.3", "@babel/preset-env": "^7.0.0", "@fellow/eslint-plugin-coffee": "0.4.13", - "@types/mocha": "^8.0.3", + "@types/mocha": "9.0.0", "@types/webpack": "^4.41.12", "@typescript-eslint/eslint-plugin": "^4.18.0", "@typescript-eslint/parser": "^4.18.0", diff --git a/package.json b/package.json index 6b9bbb1fb16b..5d816d6ef624 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "@types/lodash": "^4.14.168", "@types/markdown-it": "0.0.9", "@types/mini-css-extract-plugin": "1.2.3", - "@types/mocha": "^8.0.3", + "@types/mocha": "8.0.3", "@types/node": "14.14.31", "@types/prismjs": "1.16.0", "@types/react": "16.9.50", diff --git a/packages/errors/package.json b/packages/errors/package.json index 933b93823544..49ed97cf7913 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -25,7 +25,7 @@ "@packages/ts": "0.0.0-development", "@packages/types": "0.0.0-development", "@types/chai": "4.2.15", - "@types/mocha": "^8.0.3", + "@types/mocha": "8.2.2", "@types/node": "14.14.31", "@types/pixelmatch": "^5.2.4", "@types/pngjs": "^6.0.1", From b81f189011d8e64061a8fd6dc82d28f0ce4ebe1b Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 22 Mar 2022 10:49:32 -0500 Subject: [PATCH 71/96] bring back old errors --- packages/config/src/options.ts | 31 ++++++++-------- packages/errors/src/errors.ts | 37 +++++++++++++++++++ .../test/unit/visualSnapshotErrors_spec.ts | 10 +++++ packages/graphql/schemas/schema.graphql | 2 +- yarn.lock | 12 +++++- 5 files changed, 75 insertions(+), 17 deletions(-) diff --git a/packages/config/src/options.ts b/packages/config/src/options.ts index 1d73e18d6913..c9c2f44d6309 100644 --- a/packages/config/src/options.ts +++ b/packages/config/src/options.ts @@ -20,6 +20,7 @@ export type BreakingOptionErrorKey = | 'PLUGINS_FILE_CONFIG_OPTION_REMOVED' | 'RENAMED_CONFIG_OPTION' | 'TEST_FILES_RENAMED' + | 'RENAMED_TO_SPEC_PATTERN' type TestingType = 'e2e' | 'component' @@ -512,21 +513,6 @@ export const options: Array = [ * Values not allowed in 10.X+ in the root, e2e and component config */ export const breakingOptions: Array = [ - { - name: 'integrationFolder', - errorKey: 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN', - isWarning: false, - }, - { - name: 'componentFolder', - errorKey: 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN', - isWarning: false, - }, - { - name: 'testFiles', - errorKey: 'MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN', - isWarning: false, - }, { name: 'blacklistHosts', errorKey: 'RENAMED_CONFIG_OPTION', @@ -582,6 +568,21 @@ export const breakingOptions: Array = [ errorKey: 'TEST_FILES_RENAMED', isWarning: false, }, + { + name: 'ignoreTestFiles', + errorKey: 'IGNORE_TEST_FILES_RENAMED', + isWarning: false, + }, + { + name: 'integrationFolder', + errorKey: 'RENAMED_TO_SPEC_PATTERN', + isWarning: false, + }, + { + name: 'componentFolder', + errorKey: 'RENAMED_TO_SPEC_PATTERN', + isWarning: false, + }, ] export const breakingRootOptions: Array = [ diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index 094104e5af6f..562fe20c281f 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1362,6 +1362,43 @@ export const AllCypressErrors = { ` }, + TEST_FILES_RENAMED: (errShape: BreakingErrResult) => { + const code = errPartial` + { + e2e: { + specPattern: '...', + }, + component: { + specPattern: '...', + }, + }` + + return errTemplate`\ + The ${fmt.highlight(errShape.name)} configuration option is now invalid when set on the config object in ${fmt.cypressVersion(`10.0.0`)}. + + It is now renamed to ${fmt.highlight('specPattern')} and configured separately as a testing type property: ${fmt.highlightSecondary('e2e.specPattern')} and ${fmt.highlightSecondary('component.specPattern')} + ${fmt.code(code)} + + https://on.cypress.io/migration-guide` + }, + + COMPONENT_FOLDER_REMOVED: (errShape: BreakingErrResult) => { + const code = errPartial` + { + component: { + specPattern: '...', + }, + }` + + return errTemplate`\ + The ${fmt.highlight(errShape.name)} configuration option is now invalid when set on the config object in ${fmt.cypressVersion(`10.0.0`)}. + + It is now renamed to ${fmt.highlight('specPattern')} and configured separately as a component testing property: ${fmt.highlightSecondary('component.specPattern')} + ${fmt.code(code)} + + https://on.cypress.io/migration-guide` + }, + RENAMED_TO_SPEC_PATTERN: ({ name, setupNodeEvents = false }: {name: string, setupNodeEvents?: boolean}, err?: Error) => { const stackTrace = err ? fmt.stackTrace(err) : null diff --git a/packages/errors/test/unit/visualSnapshotErrors_spec.ts b/packages/errors/test/unit/visualSnapshotErrors_spec.ts index fe58246c79fc..67660e054595 100644 --- a/packages/errors/test/unit/visualSnapshotErrors_spec.ts +++ b/packages/errors/test/unit/visualSnapshotErrors_spec.ts @@ -1112,6 +1112,16 @@ describe('visual error templates', () => { default: ['custom.config.js', 'custom.json'], } }, + TEST_FILES_RENAMED: () => { + return { + default: [{ name: 'testFiles', configFile: '/path/to/cypress.config.js.ts' }], + } + }, + COMPONENT_FOLDER_REMOVED: () => { + return { + default: [{ name: 'componentFolder', configFile: '/path/to/cypress.config.js.ts' }], + } + }, RENAMED_TO_SPEC_PATTERN: () => { return { default: [{ name: 'integrationFolder' }, makeErr()], diff --git a/packages/graphql/schemas/schema.graphql b/packages/graphql/schemas/schema.graphql index 6250e7cdf0f5..7eef1104aa51 100644 --- a/packages/graphql/schemas/schema.graphql +++ b/packages/graphql/schemas/schema.graphql @@ -557,7 +557,6 @@ enum ErrorTypeEnum { INVOKED_BINARY_OUTSIDE_NPM_MODULE LEGACY_CONFIG_ERROR_DURING_MIGRATION LEGACY_CONFIG_FILE - MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN MIGRATION_ALREADY_OCURRED MULTIPLE_SUPPORT_FILES_FOUND NODE_VERSION_DEPRECATION_BUNDLED @@ -580,6 +579,7 @@ enum ErrorTypeEnum { RECORD_KEY_MISSING RECORD_PARAMS_WITHOUT_RECORDING RENAMED_CONFIG_OPTION + RENAMED_TO_SPEC_PATTERN RENDERER_CRASHED RUN_GROUPING_FEATURE_NOT_AVAILABLE_IN_PLAN SETUP_NODE_EVENTS_DO_NOT_SUPPORT_DEV_SERVER diff --git a/yarn.lock b/yarn.lock index 9775f5c4c159..7a300e7f7d8a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9888,11 +9888,21 @@ resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.1.tgz#283f669ff76d7b8260df8ab7a4262cc83d988256" integrity sha512-fZQQafSREFyuZcdWFAExYjBiCL7AUCdgsk80iO0q4yihYYdcIiH28CcuPTGFgLOCC8RlW49GSQxdHwZP+I7CNg== -"@types/mocha@^8.0.3": +"@types/mocha@8.0.3": version "8.0.3" resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.0.3.tgz#51b21b6acb6d1b923bbdc7725c38f9f455166402" integrity sha512-vyxR57nv8NfcU0GZu8EUXZLTbCMupIUwy95LJ6lllN+JRPG25CwMHoB1q5xKh8YKhQnHYRAn4yW2yuHbf/5xgg== +"@types/mocha@8.2.2", "@types/mocha@^8.0.3": + version "8.2.2" + resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.2.2.tgz#91daa226eb8c2ff261e6a8cbf8c7304641e095e0" + integrity sha512-Lwh0lzzqT5Pqh6z61P3c3P5nm6fzQK/MMHl9UKeneAeInVflBSz1O2EkX6gM6xfJd7FBXBY5purtLx7fUiZ7Hw== + +"@types/mocha@9.0.0": + version "9.0.0" + resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.0.0.tgz#3205bcd15ada9bc681ac20bef64e9e6df88fd297" + integrity sha512-scN0hAWyLVAvLR9AyW7HoFF5sJZglyBsbPuHO4fv7JRvfmPBMfp1ozWqOf/e4wwPNxezBZXRfWzMb6iFLgEVRA== + "@types/mock-fs@4.10.0": version "4.10.0" resolved "https://registry.yarnpkg.com/@types/mock-fs/-/mock-fs-4.10.0.tgz#460061b186993d76856f669d5317cda8a007c24b" From 72381ff6eb1215cd9602816792c5258ef7c4dcc8 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 22 Mar 2022 11:02:56 -0500 Subject: [PATCH 72/96] wat ? --- packages/example/cypress/fixtures/example.json | 0 packages/example/cypress/plugins/index.js | 0 packages/example/cypress/support/commands.js | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 packages/example/cypress/fixtures/example.json mode change 100755 => 100644 packages/example/cypress/plugins/index.js mode change 100755 => 100644 packages/example/cypress/support/commands.js diff --git a/packages/example/cypress/fixtures/example.json b/packages/example/cypress/fixtures/example.json old mode 100755 new mode 100644 diff --git a/packages/example/cypress/plugins/index.js b/packages/example/cypress/plugins/index.js old mode 100755 new mode 100644 diff --git a/packages/example/cypress/support/commands.js b/packages/example/cypress/support/commands.js old mode 100755 new mode 100644 From 406cc4af4a2fbcd59b47de08fa041ede5fdbb867 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 22 Mar 2022 11:05:42 -0500 Subject: [PATCH 73/96] restore error snapshots --- ...> RENAMED_TO_SPEC_PATTERN - componentFolder.html} | 2 +- ...html => RENAMED_TO_SPEC_PATTERN - testFiles.html} | 11 +---------- ... RENAMED_TO_SPEC_PATTERN - testFilesInSetup.html} | 2 +- ...PEC_PATTERN.html => RENAMED_TO_SPEC_PATTERN.html} | 2 +- .../errors/__snapshot-html__/TEST_FILES_RENAMED.html | 12 ------------ 5 files changed, 4 insertions(+), 25 deletions(-) rename packages/errors/__snapshot-html__/{MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - componentFolder.html => RENAMED_TO_SPEC_PATTERN - componentFolder.html} (91%) rename packages/errors/__snapshot-html__/{MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html => RENAMED_TO_SPEC_PATTERN - testFiles.html} (68%) rename packages/errors/__snapshot-html__/{MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFilesInSetup.html => RENAMED_TO_SPEC_PATTERN - testFilesInSetup.html} (92%) rename packages/errors/__snapshot-html__/{MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html => RENAMED_TO_SPEC_PATTERN.html} (91%) diff --git a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - componentFolder.html b/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - componentFolder.html similarity index 91% rename from packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - componentFolder.html rename to packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - componentFolder.html index 1ee9646bb1e3..39b6f759ef6f 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - componentFolder.html +++ b/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - componentFolder.html @@ -51,5 +51,5 @@ Error: fail whale at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts) - at MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+ at RENAMED_TO_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html b/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - testFiles.html similarity index 68% rename from packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html rename to packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - testFiles.html index a829f37a7a59..a5438fa4a67a 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html +++ b/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - testFiles.html @@ -36,12 +36,7 @@
The testFiles configuration option is now invalid when set on the config object in Cypress version 10.0.0.
 
-<<<<<<< HEAD:packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html
 It is now merged with integrationFolder or componentFolder into specPattern option and configured separately as a testing type property
-=======
- It is now renamed to specPattern and configured separately as a testing type property: e2e.specPattern and component.specPattern
- 
->>>>>>> 10.0-release:packages/errors/__snapshot-html__/TEST_FILES_RENAMED.html
 
 {
   e2e: {
@@ -52,13 +47,9 @@
   },
 }
 
-<<<<<<< HEAD:packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html
 https://on.cypress.io/migration-guide
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-=======
- https://on.cypress.io/migration-guide
->>>>>>> 10.0-release:packages/errors/__snapshot-html__/TEST_FILES_RENAMED.html
+    at RENAMED_TO_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFilesInSetup.html b/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - testFilesInSetup.html similarity index 92% rename from packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFilesInSetup.html rename to packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - testFilesInSetup.html index 459a6b2c816b..dae93f27e966 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFilesInSetup.html +++ b/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - testFilesInSetup.html @@ -52,5 +52,5 @@ Error: fail whale at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts) - at MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+ at RENAMED_TO_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html b/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN.html similarity index 91% rename from packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html rename to packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN.html index 03d34d21b358..2fbacd9a5c51 100644 --- a/packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN.html +++ b/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN.html @@ -51,5 +51,5 @@ Error: fail whale at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts) - at MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+ at RENAMED_TO_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/TEST_FILES_RENAMED.html b/packages/errors/__snapshot-html__/TEST_FILES_RENAMED.html index a829f37a7a59..64355172e9bb 100644 --- a/packages/errors/__snapshot-html__/TEST_FILES_RENAMED.html +++ b/packages/errors/__snapshot-html__/TEST_FILES_RENAMED.html @@ -36,12 +36,8 @@
The testFiles configuration option is now invalid when set on the config object in Cypress version 10.0.0.
 
-<<<<<<< HEAD:packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html
-It is now merged with integrationFolder or componentFolder into specPattern option and configured separately as a testing type property
-=======
  It is now renamed to specPattern and configured separately as a testing type property: e2e.specPattern and component.specPattern
  
->>>>>>> 10.0-release:packages/errors/__snapshot-html__/TEST_FILES_RENAMED.html
 
 {
   e2e: {
@@ -52,13 +48,5 @@
   },
 }
 
-<<<<<<< HEAD:packages/errors/__snapshot-html__/MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN - testFiles.html
-https://on.cypress.io/migration-guide
-
-Error: fail whale
-    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at MIGRATED_CONFIG_OPTIONS_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-=======
  https://on.cypress.io/migration-guide
->>>>>>> 10.0-release:packages/errors/__snapshot-html__/TEST_FILES_RENAMED.html
 
\ No newline at end of file From 18835f8be69b5a0653f0788b917f11d9fabb9e4b Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 22 Mar 2022 12:06:07 -0500 Subject: [PATCH 74/96] fix types --- packages/config/src/options.ts | 4 +++- packages/errors/src/errors.ts | 2 +- packages/errors/test/unit/visualSnapshotErrors_spec.ts | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/config/src/options.ts b/packages/config/src/options.ts index c9c2f44d6309..bc707363ac87 100644 --- a/packages/config/src/options.ts +++ b/packages/config/src/options.ts @@ -566,11 +566,13 @@ export const breakingOptions: Array = [ }, { name: 'testFiles', errorKey: 'TEST_FILES_RENAMED', + newName: 'specPattern', isWarning: false, }, { name: 'ignoreTestFiles', - errorKey: 'IGNORE_TEST_FILES_RENAMED', + errorKey: 'TEST_FILES_RENAMED', + newName: 'excludeSpecPattern', isWarning: false, }, { diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index 562fe20c281f..b2b27d9f9ca3 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1376,7 +1376,7 @@ export const AllCypressErrors = { return errTemplate`\ The ${fmt.highlight(errShape.name)} configuration option is now invalid when set on the config object in ${fmt.cypressVersion(`10.0.0`)}. - It is now renamed to ${fmt.highlight('specPattern')} and configured separately as a testing type property: ${fmt.highlightSecondary('e2e.specPattern')} and ${fmt.highlightSecondary('component.specPattern')} + It is now renamed to ${fmt.highlight(errShape.newName || '')} and configured separately as a testing type property: ${fmt.highlightSecondary('e2e.specPattern')} and ${fmt.highlightSecondary('component.specPattern')} ${fmt.code(code)} https://on.cypress.io/migration-guide` diff --git a/packages/errors/test/unit/visualSnapshotErrors_spec.ts b/packages/errors/test/unit/visualSnapshotErrors_spec.ts index 67660e054595..ff01b2f242d5 100644 --- a/packages/errors/test/unit/visualSnapshotErrors_spec.ts +++ b/packages/errors/test/unit/visualSnapshotErrors_spec.ts @@ -1114,7 +1114,7 @@ describe('visual error templates', () => { }, TEST_FILES_RENAMED: () => { return { - default: [{ name: 'testFiles', configFile: '/path/to/cypress.config.js.ts' }], + default: [{ name: 'testFiles', newName: 'specPattern', configFile: '/path/to/cypress.config.js.ts' }], } }, COMPONENT_FOLDER_REMOVED: () => { From a26dbb5a36008baf547121926f7b1d34281de33d Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 22 Mar 2022 12:19:49 -0500 Subject: [PATCH 75/96] move plugin config wrapper towards config --- packages/config/src/index.ts | 2 ++ .../src/wrap-invalid-plugin-options.ts} | 14 ++++++-------- packages/server/lib/plugins/child/run_plugins.js | 6 ++++-- 3 files changed, 12 insertions(+), 10 deletions(-) rename packages/{server/lib/plugins/child/wrap-non-migrated-config.js => config/src/wrap-invalid-plugin-options.ts} (80%) diff --git a/packages/config/src/index.ts b/packages/config/src/index.ts index 1bd955dbfebd..ab9ede9eb1cf 100644 --- a/packages/config/src/index.ts +++ b/packages/config/src/index.ts @@ -5,6 +5,7 @@ import type { BreakingOption, BreakingOptionErrorKey } from './options' // this export has to be done in 2 lines because of a bug in babel typescript import * as validation from './validation' +import { wrapInvalidPluginOptions } from './wrap-invalid-plugin-options' export { validation, @@ -12,6 +13,7 @@ export { breakingOptions, BreakingOption, BreakingOptionErrorKey, + wrapInvalidPluginOptions, } const debug = Debug('cypress:config:validator') diff --git a/packages/server/lib/plugins/child/wrap-non-migrated-config.js b/packages/config/src/wrap-invalid-plugin-options.ts similarity index 80% rename from packages/server/lib/plugins/child/wrap-non-migrated-config.js rename to packages/config/src/wrap-invalid-plugin-options.ts index 0ceadf6aae75..47c198656151 100644 --- a/packages/server/lib/plugins/child/wrap-non-migrated-config.js +++ b/packages/config/src/wrap-invalid-plugin-options.ts @@ -1,14 +1,12 @@ -const debugLib = require('debug') +import debugLib from 'debug' +import { breakingOptions, breakingRootOptions } from './options' -const debug = debugLib(`cypress:lifecycle:child:WrapNonMigrated:${process.pid}`) -const { breakingOptions, breakingRootOptions } = require('@packages/config') +const debug = debugLib(`cypress:config:child:wrap-plugin-errors:${process.pid}`) /** * Throw the error with the proper codeFrame - * @param {string} errorKey - * @param {string} name */ -function throwInvalidOptionError (errorKey, name) { +function throwInvalidOptionError (errorKey: string, name: string) { debug('throwing err %s', name) const errInternal = new Error() @@ -20,7 +18,7 @@ function throwInvalidOptionError (errorKey, name) { // only works if config.myProperty = 'something' // this will not throw config = {...config, myProperty: 'something'} -function setInvalidPropSetterWarning (opts, errorKey, optionName, optionNameForError = optionName) { +function setInvalidPropSetterWarning (opts: Record, errorKey: string, optionName: string, optionNameForError = optionName) { debug('setting invalid property %s', optionName) Object.defineProperty(opts, optionName, { set: throwInvalidOptionError.bind(null, errorKey, optionNameForError), @@ -39,7 +37,7 @@ function setInvalidPropSetterWarning (opts, errorKey, optionName, optionNameForE * has generated. Cypress opens the file and they can fix the problem. * @param {Cypress.Config} options the config object passed to setupNodeEvents */ -module.exports = function wrapNonMigratedOptions (options) { +export function wrapInvalidPluginOptions (options: Record) { debug('wrapping non-migrated options') breakingOptions.filter(({ isWarning }) => !isWarning).forEach(({ name, errorKey }) => { setInvalidPropSetterWarning(options, errorKey, name) diff --git a/packages/server/lib/plugins/child/run_plugins.js b/packages/server/lib/plugins/child/run_plugins.js index b0eb856cb96f..f625c81f5f1e 100644 --- a/packages/server/lib/plugins/child/run_plugins.js +++ b/packages/server/lib/plugins/child/run_plugins.js @@ -5,6 +5,7 @@ const debugLib = require('debug') const Promise = require('bluebird') const _ = require('lodash') +const { wrapInvalidPluginOptions } = require('@packages/config') const debug = debugLib(`cypress:lifecycle:child:RunPlugins:${process.pid}`) @@ -14,7 +15,6 @@ const resolve = require('../../util/resolve') const browserLaunch = require('./browser_launch') const util = require('../util') const validateEvent = require('./validate_event') -const wrapNonMigratedOptions = require('./wrap-non-migrated-config') const UNDEFINED_SERIALIZED = '__cypress_undefined__' @@ -116,7 +116,9 @@ class RunPlugins { .try(() => { debug('Calling setupNodeEvents') // setup all setters for 10.X+ non-supported config options - wrapNonMigratedOptions(initialConfig) + // so that where setters are called they error. This will + // help users find the issue and fix it. + wrapInvalidPluginOptions(initialConfig) return setupNodeEvents(registerChildEvent, initialConfig) }) From 25f1ed5c60cbbea936f6677ded40e59d582157f3 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 22 Mar 2022 12:25:21 -0500 Subject: [PATCH 76/96] make config simpler, better debug too --- packages/server/lib/config.ts | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/packages/server/lib/config.ts b/packages/server/lib/config.ts index a664b8941db3..4dff70d710bd 100644 --- a/packages/server/lib/config.ts +++ b/packages/server/lib/config.ts @@ -199,7 +199,7 @@ export function mergeDefaults ( config = setNodeBinary(config, options.userNodePath, options.userNodeVersion) - debug('validate that there is no breaking changes before plugins') + debug('validate that there is no breaking config options before setupNodeEvents') configUtils.validateNoBreakingConfig(config, errors.warning, (err, ...args) => { throw errors.get(err, ...args) @@ -256,6 +256,8 @@ export function updateWithPluginValues (cfg, overrides) { return errors.throwErr('CONFIG_VALIDATION_ERROR', 'configFile', configFile, validationResult) }) + debug('validate that there is no breaking config options added by setupNodeEvents') + configUtils.validateNoBreakingConfig(overrides, errors.warning, (err, options) => { throw errors.get(err, { ...options, @@ -263,18 +265,10 @@ export function updateWithPluginValues (cfg, overrides) { }) }) - let originalResolvedBrowsers = cfg - && cfg.resolved - && cfg.resolved.browsers - && _.cloneDeep(cfg.resolved.browsers) - - if (!originalResolvedBrowsers) { - // have something to resolve with if plugins return nothing - originalResolvedBrowsers = { - value: cfg.browsers, - from: 'default', - } as ResolvedFromConfig - } + const originalResolvedBrowsers = _.cloneDeep(cfg?.resolved?.browsers) ?? { + value: cfg.browsers, + from: 'default', + } as ResolvedFromConfig const diffs = deepDiff(cfg, overrides, true) From 3abd1e72a086e1db982d78f41a5c0eda8890ed86 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 22 Mar 2022 14:54:07 -0500 Subject: [PATCH 77/96] finish error renaming --- packages/errors/src/errors.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index b2b27d9f9ca3..b9359c1f2215 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1363,6 +1363,7 @@ export const AllCypressErrors = { }, TEST_FILES_RENAMED: (errShape: BreakingErrResult) => { + const newName = errShape.newName || '' const code = errPartial` { e2e: { @@ -1376,7 +1377,7 @@ export const AllCypressErrors = { return errTemplate`\ The ${fmt.highlight(errShape.name)} configuration option is now invalid when set on the config object in ${fmt.cypressVersion(`10.0.0`)}. - It is now renamed to ${fmt.highlight(errShape.newName || '')} and configured separately as a testing type property: ${fmt.highlightSecondary('e2e.specPattern')} and ${fmt.highlightSecondary('component.specPattern')} + It is now renamed to ${fmt.highlight(newName)} and configured separately as a testing type property: ${fmt.highlightSecondary(`e2e.${newName}`)} and ${fmt.highlightSecondary(`component.${newName}`)} ${fmt.code(code)} https://on.cypress.io/migration-guide` From 552d68ae864c042178b98fc2efdbe32d2ece496a Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 22 Mar 2022 16:06:42 -0500 Subject: [PATCH 78/96] avoid changing mocha --- npm/webpack-batteries-included-preprocessor/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/webpack-batteries-included-preprocessor/package.json b/npm/webpack-batteries-included-preprocessor/package.json index 1420de1f13c2..1844b995deb1 100644 --- a/npm/webpack-batteries-included-preprocessor/package.json +++ b/npm/webpack-batteries-included-preprocessor/package.json @@ -27,7 +27,7 @@ "devDependencies": { "@cypress/eslint-plugin-dev": "0.0.0-development", "@cypress/webpack-preprocessor": "0.0.0-development", - "@types/mocha": "8.0.3", + "@types/mocha": "^8.0.2", "@types/webpack": "^4.41.21", "@typescript-eslint/eslint-plugin": "^4.18.0", "@typescript-eslint/parser": "^4.18.0", From 460147382f423f3ebdee52750cddf03a6810f057 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 22 Mar 2022 16:08:34 -0500 Subject: [PATCH 79/96] remove unrelated fixes --- packages/types/src/config.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/types/src/config.ts b/packages/types/src/config.ts index 73c79f840127..265043a6f61c 100644 --- a/packages/types/src/config.ts +++ b/packages/types/src/config.ts @@ -44,3 +44,27 @@ export interface SettingsOptions { testingType?: 'component' |'e2e' args?: AllModeOptions } + +// Todo, move to @packages/config when it becomes type-safe + +export type BreakingOption = + | 'RENAMED_CONFIG_OPTION' + | 'EXPERIMENTAL_COMPONENT_TESTING_REMOVED' + | 'EXPERIMENTAL_SAMESITE_REMOVED' + | 'EXPERIMENTAL_NETWORK_STUBBING_REMOVED' + | 'EXPERIMENTAL_RUN_EVENTS_REMOVED' + | 'EXPERIMENTAL_SHADOW_DOM_REMOVED' + | 'EXPERIMENTAL_STUDIO_REMOVED' + | 'FIREFOX_GC_INTERVAL_REMOVED' + | 'NODE_VERSION_DEPRECATION_SYSTEM' + | 'NODE_VERSION_DEPRECATION_BUNDLED' + | 'CONFIG_FILE_INVALID_ROOT_CONFIG' + | 'CONFIG_FILE_INVALID_ROOT_CONFIG_E2E' + | 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT' + +export type BreakingErrResult = { + name: string + newName?: string + value?: any + configFile: string +} From 13175c0bb721e14aec28e9b69cd9818b4adb808d Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Tue, 22 Mar 2022 16:09:57 -0500 Subject: [PATCH 80/96] remove changes to example --- packages/example/cypress/fixtures/example.json | 0 packages/example/cypress/plugins/index.js | 0 packages/example/cypress/support/commands.js | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 packages/example/cypress/fixtures/example.json mode change 100644 => 100755 packages/example/cypress/plugins/index.js mode change 100644 => 100755 packages/example/cypress/support/commands.js diff --git a/packages/example/cypress/fixtures/example.json b/packages/example/cypress/fixtures/example.json old mode 100644 new mode 100755 diff --git a/packages/example/cypress/plugins/index.js b/packages/example/cypress/plugins/index.js old mode 100644 new mode 100755 diff --git a/packages/example/cypress/support/commands.js b/packages/example/cypress/support/commands.js old mode 100644 new mode 100755 From e1750c0e0bbf1887f0736a7d3e247d408c6f83bd Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 23 Mar 2022 11:12:35 -0500 Subject: [PATCH 81/96] make error management simpler --- packages/config/src/options.ts | 37 +++++------- packages/config/src/validation.ts | 4 -- .../COMPONENT_FOLDER_REMOVED.html | 5 +- ...N.html => INTEGRATION_FOLDER_REMOVED.html} | 15 ++--- ...MED_TO_SPEC_PATTERN - componentFolder.html | 55 ------------------ .../RENAMED_TO_SPEC_PATTERN - testFiles.html | 55 ------------------ ...ED_TO_SPEC_PATTERN - testFilesInSetup.html | 56 ------------------- .../__snapshot-html__/TEST_FILES_RENAMED.html | 5 +- packages/errors/src/errors.ts | 56 ++++++++----------- .../test/unit/visualSnapshotErrors_spec.ts | 7 +-- .../example/cypress/fixtures/example.json | 0 packages/example/cypress/plugins/index.js | 0 packages/example/cypress/support/commands.js | 0 packages/graphql/schemas/schema.graphql | 2 +- yarn.lock | 7 ++- 15 files changed, 61 insertions(+), 243 deletions(-) rename packages/errors/__snapshot-html__/{RENAMED_TO_SPEC_PATTERN.html => INTEGRATION_FOLDER_REMOVED.html} (62%) delete mode 100644 packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - componentFolder.html delete mode 100644 packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - testFiles.html delete mode 100644 packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - testFilesInSetup.html mode change 100755 => 100644 packages/example/cypress/fixtures/example.json mode change 100755 => 100644 packages/example/cypress/plugins/index.js mode change 100755 => 100644 packages/example/cypress/support/commands.js diff --git a/packages/config/src/options.ts b/packages/config/src/options.ts index bc707363ac87..76e655fd167a 100644 --- a/packages/config/src/options.ts +++ b/packages/config/src/options.ts @@ -5,6 +5,7 @@ import pkg from '@packages/root' export type BreakingOptionErrorKey = | 'COMPONENT_FOLDER_REMOVED' + | 'INTEGRATION_FOLDER_REMOVED' | 'CONFIG_FILE_INVALID_ROOT_CONFIG' | 'CONFIG_FILE_INVALID_ROOT_CONFIG_E2E' | 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT' @@ -20,7 +21,6 @@ export type BreakingOptionErrorKey = | 'PLUGINS_FILE_CONFIG_OPTION_REMOVED' | 'RENAMED_CONFIG_OPTION' | 'TEST_FILES_RENAMED' - | 'RENAMED_TO_SPEC_PATTERN' type TestingType = 'e2e' | 'component' @@ -521,6 +521,20 @@ export const breakingOptions: Array = [ name: 'componentFolder', errorKey: 'COMPONENT_FOLDER_REMOVED', isWarning: false, + }, { + name: 'integrationFolder', + errorKey: 'INTEGRATION_FOLDER_REMOVED', + isWarning: false, + }, { + name: 'testFiles', + errorKey: 'TEST_FILES_RENAMED', + newName: 'specPattern', + isWarning: false, + }, { + name: 'ignoreTestFiles', + errorKey: 'TEST_FILES_RENAMED', + newName: 'excludeSpecPattern', + isWarning: false, }, { name: 'experimentalComponentTesting', errorKey: 'EXPERIMENTAL_COMPONENT_TESTING_REMOVED', @@ -563,27 +577,6 @@ export const breakingOptions: Array = [ }, { name: 'pluginsFile', errorKey: 'PLUGINS_FILE_CONFIG_OPTION_REMOVED', - }, { - name: 'testFiles', - errorKey: 'TEST_FILES_RENAMED', - newName: 'specPattern', - isWarning: false, - }, - { - name: 'ignoreTestFiles', - errorKey: 'TEST_FILES_RENAMED', - newName: 'excludeSpecPattern', - isWarning: false, - }, - { - name: 'integrationFolder', - errorKey: 'RENAMED_TO_SPEC_PATTERN', - isWarning: false, - }, - { - name: 'componentFolder', - errorKey: 'RENAMED_TO_SPEC_PATTERN', - isWarning: false, }, ] diff --git a/packages/config/src/validation.ts b/packages/config/src/validation.ts index 5b8513ac039a..87e8367006c3 100644 --- a/packages/config/src/validation.ts +++ b/packages/config/src/validation.ts @@ -213,10 +213,6 @@ export const isValidClientCertificatesSet = (_key: string, certsForUrls: Array<{ for (let j = 0; j < certsForUrl.certs.length; j++) { let certInfo = certsForUrl.certs[j]! - if (!certInfo) { - continue - } - // Only one of PEM or PFX cert allowed if (certInfo.cert && certInfo.pfx) { return `\`clientCertificates[${i}].certs[${j}]\` has both PEM and PFX defined` diff --git a/packages/errors/__snapshot-html__/COMPONENT_FOLDER_REMOVED.html b/packages/errors/__snapshot-html__/COMPONENT_FOLDER_REMOVED.html index cbe24d89a813..e46f393aea31 100644 --- a/packages/errors/__snapshot-html__/COMPONENT_FOLDER_REMOVED.html +++ b/packages/errors/__snapshot-html__/COMPONENT_FOLDER_REMOVED.html @@ -45,5 +45,8 @@ }, } - https://on.cypress.io/migration-guide
+ https://on.cypress.io/migration-guide + + +
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN.html b/packages/errors/__snapshot-html__/INTEGRATION_FOLDER_REMOVED.html similarity index 62% rename from packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN.html rename to packages/errors/__snapshot-html__/INTEGRATION_FOLDER_REMOVED.html index 2fbacd9a5c51..e6b79e340a9f 100644 --- a/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN.html +++ b/packages/errors/__snapshot-html__/INTEGRATION_FOLDER_REMOVED.html @@ -36,20 +36,17 @@
The integrationFolder configuration option is now invalid when set on the config object in Cypress version 10.0.0.
 
-It is now merged with testFiles into specPattern option and configured separately as a testing type property
+ It is now renamed to specPattern and configured separately as a component testing property: component.specPattern
+ 
 
 {
   e2e: {
     specPattern: '...',
   },
-  component: {
-    specPattern: '...',
-  },
 }
 
-https://on.cypress.io/migration-guide
-
-Error: fail whale
-    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at RENAMED_TO_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+ https://on.cypress.io/migration-guide
+ 
+ 
+ 
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - componentFolder.html b/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - componentFolder.html deleted file mode 100644 index 39b6f759ef6f..000000000000 --- a/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - componentFolder.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - -
The componentFolder configuration option is now invalid when set on the config object in Cypress version 10.0.0.
-
-It is now merged with testFiles into specPattern option and configured separately as a testing type property
-
-{
-  e2e: {
-    specPattern: '...',
-  },
-  component: {
-    specPattern: '...',
-  },
-}
-
-https://on.cypress.io/migration-guide
-
-Error: fail whale
-    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at RENAMED_TO_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - testFiles.html b/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - testFiles.html deleted file mode 100644 index a5438fa4a67a..000000000000 --- a/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - testFiles.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - -
The testFiles configuration option is now invalid when set on the config object in Cypress version 10.0.0.
-
-It is now merged with integrationFolder or componentFolder into specPattern option and configured separately as a testing type property
-
-{
-  e2e: {
-    specPattern: '...',
-  },
-  component: {
-    specPattern: '...',
-  },
-}
-
-https://on.cypress.io/migration-guide
-
-Error: fail whale
-    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at RENAMED_TO_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - testFilesInSetup.html b/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - testFilesInSetup.html deleted file mode 100644 index dae93f27e966..000000000000 --- a/packages/errors/__snapshot-html__/RENAMED_TO_SPEC_PATTERN - testFilesInSetup.html +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - -
In setupNodeEvents(), you are attempting to update a the testFiles configuration option. 
-Its now invalid on the config object in Cypress version 10.0.0.
-
-It is now merged with integrationFolder or componentFolder into specPattern option and configured separately as a testing type property
-
-{
-  e2e: {
-    specPattern: '...',
-  },
-  component: {
-    specPattern: '...',
-  },
-}
-
-https://on.cypress.io/migration-guide
-
-Error: fail whale
-    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at RENAMED_TO_SPEC_PATTERN (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/TEST_FILES_RENAMED.html b/packages/errors/__snapshot-html__/TEST_FILES_RENAMED.html index 64355172e9bb..24200a6ee24a 100644 --- a/packages/errors/__snapshot-html__/TEST_FILES_RENAMED.html +++ b/packages/errors/__snapshot-html__/TEST_FILES_RENAMED.html @@ -48,5 +48,8 @@ }, } - https://on.cypress.io/migration-guide
+ https://on.cypress.io/migration-guide + + +
\ No newline at end of file diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index b9359c1f2215..f292dad0c232 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -1362,7 +1362,9 @@ export const AllCypressErrors = { ` }, - TEST_FILES_RENAMED: (errShape: BreakingErrResult) => { + TEST_FILES_RENAMED: (errShape: BreakingErrResult, err?: Error) => { + const stackTrace = err ? fmt.stackTrace(err) : null + const newName = errShape.newName || '' const code = errPartial` { @@ -1380,10 +1382,15 @@ export const AllCypressErrors = { It is now renamed to ${fmt.highlight(newName)} and configured separately as a testing type property: ${fmt.highlightSecondary(`e2e.${newName}`)} and ${fmt.highlightSecondary(`component.${newName}`)} ${fmt.code(code)} - https://on.cypress.io/migration-guide` + https://on.cypress.io/migration-guide + + ${stackTrace} + ` }, - COMPONENT_FOLDER_REMOVED: (errShape: BreakingErrResult) => { + COMPONENT_FOLDER_REMOVED: (errShape: BreakingErrResult, err?: Error) => { + const stackTrace = err ? fmt.stackTrace(err) : null + const code = errPartial` { component: { @@ -1397,49 +1404,32 @@ export const AllCypressErrors = { It is now renamed to ${fmt.highlight('specPattern')} and configured separately as a component testing property: ${fmt.highlightSecondary('component.specPattern')} ${fmt.code(code)} - https://on.cypress.io/migration-guide` + https://on.cypress.io/migration-guide + + ${stackTrace} + ` }, - RENAMED_TO_SPEC_PATTERN: ({ name, setupNodeEvents = false }: {name: string, setupNodeEvents?: boolean}, err?: Error) => { + INTEGRATION_FOLDER_REMOVED: (errShape: BreakingErrResult, err?: Error) => { const stackTrace = err ? fmt.stackTrace(err) : null - // some keys come prefixed with a `component.` or `e2e.` but they are not referenced - // in the errors maps with this prefix. strip it out. - const rootKey = name.replace(/^(component|e2e)\./, '') - - const testingTypePrefix = name.includes('component.') ? 'component.' : name.includes('e2e.') ? 'e2e.' : '' - - const mergedOptionKey = 'testFiles' === rootKey - ? errPartial`${fmt.highlight('integrationFolder')} or ${fmt.highlight('componentFolder')}` - : errPartial`${fmt.highlight('testFiles')}` - - const message = setupNodeEvents ? errPartial` - In ${fmt.highlight('setupNodeEvents()')}, you are attempting to update a the ${fmt.highlight(name)} configuration option. - Its now invalid on the config object in ${fmt.cypressVersion(`10.0.0`)}. - ` : errPartial` - The ${fmt.highlight(name)} configuration option is now invalid when set on the config object in ${fmt.cypressVersion(`10.0.0`)}. - ` - const code = errPartial` { e2e: { specPattern: '...', }, - component: { - specPattern: '...', - }, }` - return errTemplate` - ${message} - It is now merged with ${mergedOptionKey} into ${fmt.highlight(`${testingTypePrefix}specPattern`)} option and configured separately as a testing type property - - ${fmt.code(code)} + return errTemplate`\ + The ${fmt.highlight(errShape.name)} configuration option is now invalid when set on the config object in ${fmt.cypressVersion(`10.0.0`)}. - https://on.cypress.io/migration-guide + It is now renamed to ${fmt.highlight('specPattern')} and configured separately as a component testing property: ${fmt.highlightSecondary('component.specPattern')} + ${fmt.code(code)} - ${stackTrace} - ` + https://on.cypress.io/migration-guide + + ${stackTrace} + ` }, } as const diff --git a/packages/errors/test/unit/visualSnapshotErrors_spec.ts b/packages/errors/test/unit/visualSnapshotErrors_spec.ts index ff01b2f242d5..890cfb5e80c5 100644 --- a/packages/errors/test/unit/visualSnapshotErrors_spec.ts +++ b/packages/errors/test/unit/visualSnapshotErrors_spec.ts @@ -1122,12 +1122,9 @@ describe('visual error templates', () => { default: [{ name: 'componentFolder', configFile: '/path/to/cypress.config.js.ts' }], } }, - RENAMED_TO_SPEC_PATTERN: () => { + INTEGRATION_FOLDER_REMOVED: () => { return { - default: [{ name: 'integrationFolder' }, makeErr()], - testFiles: [{ name: 'testFiles' }, makeErr()], - componentFolder: [{ name: 'componentFolder' }, makeErr()], - testFilesInSetup: [{ name: 'testFiles', setupNodeEvents: true }, makeErr()], + default: [{ name: 'integrationFolder', configFile: '/path/to/cypress.config.js.ts' }], } }, }) diff --git a/packages/example/cypress/fixtures/example.json b/packages/example/cypress/fixtures/example.json old mode 100755 new mode 100644 diff --git a/packages/example/cypress/plugins/index.js b/packages/example/cypress/plugins/index.js old mode 100755 new mode 100644 diff --git a/packages/example/cypress/support/commands.js b/packages/example/cypress/support/commands.js old mode 100755 new mode 100644 diff --git a/packages/graphql/schemas/schema.graphql b/packages/graphql/schemas/schema.graphql index 391303c926c2..b3704899d3cd 100644 --- a/packages/graphql/schemas/schema.graphql +++ b/packages/graphql/schemas/schema.graphql @@ -551,6 +551,7 @@ enum ErrorTypeEnum { INCOMPATIBLE_PLUGIN_RETRIES INCORRECT_CI_BUILD_ID_USAGE INDETERMINATE_CI_BUILD_ID + INTEGRATION_FOLDER_REMOVED INVALID_CONFIG_OPTION INVALID_CYPRESS_INTERNAL_ENV INVALID_REPORTER_NAME @@ -579,7 +580,6 @@ enum ErrorTypeEnum { RECORD_KEY_MISSING RECORD_PARAMS_WITHOUT_RECORDING RENAMED_CONFIG_OPTION - RENAMED_TO_SPEC_PATTERN RENDERER_CRASHED RUN_GROUPING_FEATURE_NOT_AVAILABLE_IN_PLAN SETUP_NODE_EVENTS_DO_NOT_SUPPORT_DEV_SERVER diff --git a/yarn.lock b/yarn.lock index 7a300e7f7d8a..20ed8e0ec79d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9893,7 +9893,7 @@ resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.0.3.tgz#51b21b6acb6d1b923bbdc7725c38f9f455166402" integrity sha512-vyxR57nv8NfcU0GZu8EUXZLTbCMupIUwy95LJ6lllN+JRPG25CwMHoB1q5xKh8YKhQnHYRAn4yW2yuHbf/5xgg== -"@types/mocha@8.2.2", "@types/mocha@^8.0.3": +"@types/mocha@8.2.2": version "8.2.2" resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.2.2.tgz#91daa226eb8c2ff261e6a8cbf8c7304641e095e0" integrity sha512-Lwh0lzzqT5Pqh6z61P3c3P5nm6fzQK/MMHl9UKeneAeInVflBSz1O2EkX6gM6xfJd7FBXBY5purtLx7fUiZ7Hw== @@ -9903,6 +9903,11 @@ resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.0.0.tgz#3205bcd15ada9bc681ac20bef64e9e6df88fd297" integrity sha512-scN0hAWyLVAvLR9AyW7HoFF5sJZglyBsbPuHO4fv7JRvfmPBMfp1ozWqOf/e4wwPNxezBZXRfWzMb6iFLgEVRA== +"@types/mocha@^8.0.2", "@types/mocha@^8.0.3": + version "8.2.3" + resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.2.3.tgz#bbeb55fbc73f28ea6de601fbfa4613f58d785323" + integrity sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw== + "@types/mock-fs@4.10.0": version "4.10.0" resolved "https://registry.yarnpkg.com/@types/mock-fs/-/mock-fs-4.10.0.tgz#460061b186993d76856f669d5317cda8a007c24b" From 7118dcad71ee0d1d18e1896a3f6acd524c469282 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 23 Mar 2022 11:18:15 -0500 Subject: [PATCH 82/96] make errors tests type safe again --- system-tests/package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/system-tests/package.json b/system-tests/package.json index 58df6eafaeca..2d8df3a5c906 100644 --- a/system-tests/package.json +++ b/system-tests/package.json @@ -30,7 +30,7 @@ "@packages/ts": "0.0.0-development", "@storybook/testing-vue3": "0.0.1", "@types/chai": "4.2.15", - "@types/mocha": "^8.0.3", + "@types/mocha": "9.1.0", "babel-loader": "8.1.0", "bluebird": "3.7.2", "body-parser": "1.19.0", diff --git a/yarn.lock b/yarn.lock index 20ed8e0ec79d..9dd41a695f05 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9893,7 +9893,7 @@ resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.0.3.tgz#51b21b6acb6d1b923bbdc7725c38f9f455166402" integrity sha512-vyxR57nv8NfcU0GZu8EUXZLTbCMupIUwy95LJ6lllN+JRPG25CwMHoB1q5xKh8YKhQnHYRAn4yW2yuHbf/5xgg== -"@types/mocha@8.2.2": +"@types/mocha@8.2.2", "@types/mocha@^8.0.2", "@types/mocha@^8.0.3": version "8.2.2" resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.2.2.tgz#91daa226eb8c2ff261e6a8cbf8c7304641e095e0" integrity sha512-Lwh0lzzqT5Pqh6z61P3c3P5nm6fzQK/MMHl9UKeneAeInVflBSz1O2EkX6gM6xfJd7FBXBY5purtLx7fUiZ7Hw== @@ -9903,10 +9903,10 @@ resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.0.0.tgz#3205bcd15ada9bc681ac20bef64e9e6df88fd297" integrity sha512-scN0hAWyLVAvLR9AyW7HoFF5sJZglyBsbPuHO4fv7JRvfmPBMfp1ozWqOf/e4wwPNxezBZXRfWzMb6iFLgEVRA== -"@types/mocha@^8.0.2", "@types/mocha@^8.0.3": - version "8.2.3" - resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.2.3.tgz#bbeb55fbc73f28ea6de601fbfa4613f58d785323" - integrity sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw== +"@types/mocha@9.1.0": + version "9.1.0" + resolved "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.0.tgz#baf17ab2cca3fcce2d322ebc30454bff487efad5" + integrity sha512-QCWHkbMv4Y5U9oW10Uxbr45qMMSzl4OzijsozynUAgx3kEHUdXB00udx2dWDQ7f2TU2a2uuiFaRZjCe3unPpeg== "@types/mock-fs@4.10.0": version "4.10.0" From 5a64874a716ffc2cdf71a00e195bc70dc9609e99 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 23 Mar 2022 11:36:41 -0500 Subject: [PATCH 83/96] fix types --- packages/server/lib/config.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/server/lib/config.ts b/packages/server/lib/config.ts index 4dff70d710bd..6752ea2369ce 100644 --- a/packages/server/lib/config.ts +++ b/packages/server/lib/config.ts @@ -261,7 +261,6 @@ export function updateWithPluginValues (cfg, overrides) { configUtils.validateNoBreakingConfig(overrides, errors.warning, (err, options) => { throw errors.get(err, { ...options, - setupNodeEvents: true, }) }) From 5950d2a0bc1afaca0e22017ffad54abd41070bac Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 23 Mar 2022 11:37:45 -0500 Subject: [PATCH 84/96] simplify --- packages/server/lib/config.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/server/lib/config.ts b/packages/server/lib/config.ts index 6752ea2369ce..d717f9b3dece 100644 --- a/packages/server/lib/config.ts +++ b/packages/server/lib/config.ts @@ -259,9 +259,7 @@ export function updateWithPluginValues (cfg, overrides) { debug('validate that there is no breaking config options added by setupNodeEvents') configUtils.validateNoBreakingConfig(overrides, errors.warning, (err, options) => { - throw errors.get(err, { - ...options, - }) + throw errors.get(err, options) }) const originalResolvedBrowsers = _.cloneDeep(cfg?.resolved?.browsers) ?? { From bdbd753c86a7006d6ac080edd13069d6237e0b9e Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 23 Mar 2022 11:40:45 -0500 Subject: [PATCH 85/96] remove changed files --- packages/example/cypress/fixtures/example.json | 0 packages/example/cypress/plugins/index.js | 0 packages/example/cypress/support/commands.js | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 packages/example/cypress/fixtures/example.json mode change 100644 => 100755 packages/example/cypress/plugins/index.js mode change 100644 => 100755 packages/example/cypress/support/commands.js diff --git a/packages/example/cypress/fixtures/example.json b/packages/example/cypress/fixtures/example.json old mode 100644 new mode 100755 diff --git a/packages/example/cypress/plugins/index.js b/packages/example/cypress/plugins/index.js old mode 100644 new mode 100755 diff --git a/packages/example/cypress/support/commands.js b/packages/example/cypress/support/commands.js old mode 100644 new mode 100755 From 33a4b5c995e4e101d71aea0c6885f40c93661b84 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 23 Mar 2022 12:07:05 -0500 Subject: [PATCH 86/96] fix snapshots in unit tests --- packages/config/__snapshots__/index.spec.ts.js | 9 ++++----- packages/config/__snapshots__/validation.spec.ts.js | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/config/__snapshots__/index.spec.ts.js b/packages/config/__snapshots__/index.spec.ts.js index 5e3843f98458..4ba6d1d86f55 100644 --- a/packages/config/__snapshots__/index.spec.ts.js +++ b/packages/config/__snapshots__/index.spec.ts.js @@ -1,9 +1,9 @@ exports['src/index .getBreakingKeys returns list of breaking config keys 1'] = [ - "integrationFolder", - "componentFolder", - "testFiles", "blacklistHosts", "componentFolder", + "integrationFolder", + "testFiles", + "ignoreTestFiles", "experimentalComponentTesting", "experimentalGetCookiesSameSite", "experimentalNetworkStubbing", @@ -13,8 +13,7 @@ exports['src/index .getBreakingKeys returns list of breaking config keys 1'] = [ "firefoxGcInterval", "nodeVersion", "nodeVersion", - "pluginsFile", - "testFiles" + "pluginsFile" ] exports['src/index .getDefaultValues returns list of public config keys 1'] = { diff --git a/packages/config/__snapshots__/validation.spec.ts.js b/packages/config/__snapshots__/validation.spec.ts.js index a9920482ef11..1b3d0e62bfce 100644 --- a/packages/config/__snapshots__/validation.spec.ts.js +++ b/packages/config/__snapshots__/validation.spec.ts.js @@ -12,7 +12,7 @@ exports['src/validation .isValidClientCertificatesSet returns error message for exports['missing https protocol'] = { "key": "clientCertificates[0].url", "value": "http://url.com", - "type": "a valid URL" + "type": "an https protocol" } exports['invalid url'] = { From e91330a716a9e0e221b4373414a0d40dc23ac276 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 23 Mar 2022 12:46:14 -0500 Subject: [PATCH 87/96] make app tests work again --- .../data-context/src/data/ProjectLifecycleManager.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/data-context/src/data/ProjectLifecycleManager.ts b/packages/data-context/src/data/ProjectLifecycleManager.ts index 1a4f7353f879..5685f45d26be 100644 --- a/packages/data-context/src/data/ProjectLifecycleManager.ts +++ b/packages/data-context/src/data/ProjectLifecycleManager.ts @@ -1001,15 +1001,17 @@ export class ProjectLifecycleManager { private forkConfigProcess () { const configProcessArgs = ['--projectRoot', this.projectRoot, '--file', this.configFilePath] + // allow the use of ts-node in subprocesses tests by removing the env constant from it + // without this line, packages/ts/register.js never registers the ts-node module for config and + // run_plugins can't use the config module. + const { CYPRESS_INTERNAL_E2E_TESTING_SELF, ...env } = process.env + + env.NODE_OPTIONS = process.env.ORIGINAL_NODE_OPTIONS || '' const childOptions: ForkOptions = { stdio: 'pipe', cwd: path.dirname(this.configFilePath), - env: { - ...process.env, - NODE_OPTIONS: process.env.ORIGINAL_NODE_OPTIONS || '', - // DEBUG: '*', - }, + env, execPath: this.ctx.nodePath ?? undefined, } From 7294e21002348f66a5c257cf040a10393920b927 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 23 Mar 2022 13:54:28 -0500 Subject: [PATCH 88/96] remove changes to the plugins error processing --- packages/config/src/index.ts | 2 - .../config/src/wrap-invalid-plugin-options.ts | 56 ------------------- .../src/data/ProjectLifecycleManager.ts | 12 ++-- .../e2e/config-files-error-handling.cy.ts | 4 -- .../server/lib/plugins/child/run_plugins.js | 11 +--- 5 files changed, 7 insertions(+), 78 deletions(-) delete mode 100644 packages/config/src/wrap-invalid-plugin-options.ts diff --git a/packages/config/src/index.ts b/packages/config/src/index.ts index ab9ede9eb1cf..1bd955dbfebd 100644 --- a/packages/config/src/index.ts +++ b/packages/config/src/index.ts @@ -5,7 +5,6 @@ import type { BreakingOption, BreakingOptionErrorKey } from './options' // this export has to be done in 2 lines because of a bug in babel typescript import * as validation from './validation' -import { wrapInvalidPluginOptions } from './wrap-invalid-plugin-options' export { validation, @@ -13,7 +12,6 @@ export { breakingOptions, BreakingOption, BreakingOptionErrorKey, - wrapInvalidPluginOptions, } const debug = Debug('cypress:config:validator') diff --git a/packages/config/src/wrap-invalid-plugin-options.ts b/packages/config/src/wrap-invalid-plugin-options.ts deleted file mode 100644 index 47c198656151..000000000000 --- a/packages/config/src/wrap-invalid-plugin-options.ts +++ /dev/null @@ -1,56 +0,0 @@ -import debugLib from 'debug' -import { breakingOptions, breakingRootOptions } from './options' - -const debug = debugLib(`cypress:config:child:wrap-plugin-errors:${process.pid}`) - -/** - * Throw the error with the proper codeFrame - */ -function throwInvalidOptionError (errorKey: string, name: string) { - debug('throwing err %s', name) - const errInternal = new Error() - - Error.captureStackTrace(errInternal, throwInvalidOptionError) - const err = require('@packages/errors').getError(errorKey, { name, setupNodeEvents: true }, errInternal) - - throw err -} - -// only works if config.myProperty = 'something' -// this will not throw config = {...config, myProperty: 'something'} -function setInvalidPropSetterWarning (opts: Record, errorKey: string, optionName: string, optionNameForError = optionName) { - debug('setting invalid property %s', optionName) - Object.defineProperty(opts, optionName, { - set: throwInvalidOptionError.bind(null, errorKey, optionNameForError), - }) -} - -/** - * When using setupNodeEvents, setting some config values is invalid. - * We validate this after running the function. - * The config that the function returns is checked for those invalid values. - * But this after-the-fact error only tells them: "you can't do that" - * - * The wrapNonMigratedOptions function wraps the config object and throws - * an error at the line the user tries to set a value that is not allowed. - * This way, the user can simply click on the codeFrame that the error - * has generated. Cypress opens the file and they can fix the problem. - * @param {Cypress.Config} options the config object passed to setupNodeEvents - */ -export function wrapInvalidPluginOptions (options: Record) { - debug('wrapping non-migrated options') - breakingOptions.filter(({ isWarning }) => !isWarning).forEach(({ name, errorKey }) => { - setInvalidPropSetterWarning(options, errorKey, name) - - const testingTypes = ['component', 'e2e'] - - testingTypes.forEach((testingType) => { - options[testingType] = options[testingType] || {} - setInvalidPropSetterWarning(options[testingType], errorKey, name, `${testingType}.${name}`) - }) - }) - - breakingRootOptions.filter(({ isWarning }) => !isWarning).forEach(({ name, errorKey }) => { - setInvalidPropSetterWarning(options, errorKey, name) - }) -} diff --git a/packages/data-context/src/data/ProjectLifecycleManager.ts b/packages/data-context/src/data/ProjectLifecycleManager.ts index 5685f45d26be..1a4f7353f879 100644 --- a/packages/data-context/src/data/ProjectLifecycleManager.ts +++ b/packages/data-context/src/data/ProjectLifecycleManager.ts @@ -1001,17 +1001,15 @@ export class ProjectLifecycleManager { private forkConfigProcess () { const configProcessArgs = ['--projectRoot', this.projectRoot, '--file', this.configFilePath] - // allow the use of ts-node in subprocesses tests by removing the env constant from it - // without this line, packages/ts/register.js never registers the ts-node module for config and - // run_plugins can't use the config module. - const { CYPRESS_INTERNAL_E2E_TESTING_SELF, ...env } = process.env - - env.NODE_OPTIONS = process.env.ORIGINAL_NODE_OPTIONS || '' const childOptions: ForkOptions = { stdio: 'pipe', cwd: path.dirname(this.configFilePath), - env, + env: { + ...process.env, + NODE_OPTIONS: process.env.ORIGINAL_NODE_OPTIONS || '', + // DEBUG: '*', + }, execPath: this.ctx.nodePath ?? undefined, } diff --git a/packages/launchpad/cypress/e2e/config-files-error-handling.cy.ts b/packages/launchpad/cypress/e2e/config-files-error-handling.cy.ts index 07d8c7e9c474..51d6bdef86be 100644 --- a/packages/launchpad/cypress/e2e/config-files-error-handling.cy.ts +++ b/packages/launchpad/cypress/e2e/config-files-error-handling.cy.ts @@ -157,8 +157,6 @@ describe('Launchpad: Error System Tests', () => { cy.findByText('E2E Testing').click() cy.get('h1').should('contain', 'Error Loading Config') cy.percySnapshot() - - cy.get('[data-testid="error-code-frame"]').should('contain', 'cypress.config.js:5:32') }) it('throws an error when in setupNodeEvents updating a config value on a clone of config that was removed in 10.X', () => { @@ -179,7 +177,5 @@ describe('Launchpad: Error System Tests', () => { cy.findByText('E2E Testing').click() cy.get('h1').should('contain', 'Error Loading Config') cy.percySnapshot() - - cy.get('[data-testid="error-code-frame"]').should('contain', 'cypress.config.js:5:36') }) }) diff --git a/packages/server/lib/plugins/child/run_plugins.js b/packages/server/lib/plugins/child/run_plugins.js index f625c81f5f1e..0b6ac4af617c 100644 --- a/packages/server/lib/plugins/child/run_plugins.js +++ b/packages/server/lib/plugins/child/run_plugins.js @@ -5,7 +5,6 @@ const debugLib = require('debug') const Promise = require('bluebird') const _ = require('lodash') -const { wrapInvalidPluginOptions } = require('@packages/config') const debug = debugLib(`cypress:lifecycle:child:RunPlugins:${process.pid}`) @@ -115,10 +114,6 @@ class RunPlugins { Promise .try(() => { debug('Calling setupNodeEvents') - // setup all setters for 10.X+ non-supported config options - // so that where setters are called they error. This will - // help users find the issue and fix it. - wrapInvalidPluginOptions(initialConfig) return setupNodeEvents(registerChildEvent, initialConfig) }) @@ -138,14 +133,12 @@ class RunPlugins { }) .catch((err) => { debug('plugins file errored:', err && err.stack) - const processedError = err.isCypressErr ? err : require('@packages/errors').getError( + this.ipc.send('setupTestingType:error', util.serializeError(require('@packages/errors').getError( 'CONFIG_FILE_SETUP_NODE_EVENTS_ERROR', this.requiredFile, initialConfig.testingType, err, - ) - - this.ipc.send('setupTestingType:error', util.serializeError(processedError)) + ))) }) } From ce08508e864527dcedbac8d97537d2a40da7db54 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 23 Mar 2022 14:17:35 -0500 Subject: [PATCH 89/96] remove integrationFolder from all tests --- packages/server/lib/plugins/preprocessor.js | 1 - .../server/test/integration/cypress_spec.js | 24 ------------------- .../test/integration/http_requests_spec.js | 18 +++++++++----- packages/server/test/unit/modes/run_spec.js | 6 ----- .../test/unit/plugins/preprocessor_spec.js | 8 ------- packages/server/test/unit/project_spec.js | 20 ++++++++-------- 6 files changed, 22 insertions(+), 55 deletions(-) diff --git a/packages/server/lib/plugins/preprocessor.js b/packages/server/lib/plugins/preprocessor.js index 160809a29886..0908614a3307 100644 --- a/packages/server/lib/plugins/preprocessor.js +++ b/packages/server/lib/plugins/preprocessor.js @@ -71,7 +71,6 @@ const API = { const baseFilePath = filePath .replace(config.projectRoot, '') - .replace(config.integrationFolder, '') fileObject = (fileObjects[filePath] = _.extend(new EE(), { filePath, diff --git a/packages/server/test/integration/cypress_spec.js b/packages/server/test/integration/cypress_spec.js index 4c35f53b4261..38d980785714 100644 --- a/packages/server/test/integration/cypress_spec.js +++ b/packages/server/test/integration/cypress_spec.js @@ -429,30 +429,6 @@ describe('lib/cypress', () => { }) }) - // NOTE: We no longer do this in the new flow - it.skip('scaffolds out integration and example specs if they do not exist when not runMode', function () { - ctx.actions.project.setCurrentProjectAndTestingTypeForTestSetup(this.pristineWithConfigPath) - - return config.get(this.pristineWithConfigPath) - .then((cfg) => { - return fs.statAsync(cfg.integrationFolder) - .then(() => { - throw new Error('integrationFolder should not exist!') - }).catch(() => { - return cypress.start([`--run-project=${this.pristineWithConfigPath}`, '--no-run-mode']) - }).then(() => { - return fs.statAsync(cfg.integrationFolder) - }).then(() => { - return Promise.join( - fs.statAsync(path.join(cfg.integrationFolder, '1-getting-started', 'todo.spec.js')), - fs.statAsync(path.join(cfg.integrationFolder, '2-advanced-examples', 'actions.spec.js')), - fs.statAsync(path.join(cfg.integrationFolder, '2-advanced-examples', 'files.spec.js')), - fs.statAsync(path.join(cfg.integrationFolder, '2-advanced-examples', 'viewport.spec.js')), - ) - }) - }) - }) - it('does not scaffold when headless and exits with error when no existing project', function () { const ensureDoesNotExist = function (inspection, index) { if (!inspection.isRejected()) { diff --git a/packages/server/test/integration/http_requests_spec.js b/packages/server/test/integration/http_requests_spec.js index 10f14c81fe79..aa46ae9f6150 100644 --- a/packages/server/test/integration/http_requests_spec.js +++ b/packages/server/test/integration/http_requests_spec.js @@ -585,8 +585,10 @@ describe('Routes', () => { return this.setup({ projectRoot: Fixtures.projectPath('no-server'), config: { - integrationFolder: 'my-tests', - supportFile: 'helpers/includes.js', + e2e: { + specPattern: 'my-tests/**/*', + supportFile: 'helpers/includes.js', + }, }, }) }) @@ -791,9 +793,11 @@ describe('Routes', () => { return this.setup({ projectRoot: Fixtures.projectPath('todos'), config: { - integrationFolder: 'tests', + e2e: { + specPattern: 'tests/**/*', + supportFile: false, + }, fixturesFolder: 'tests/_fixtures', - supportFile: false, }, }) }) @@ -3100,8 +3104,10 @@ describe('Routes', () => { projectRoot: Fixtures.projectPath('no-server'), config: { fileServerFolder: 'dev', - integrationFolder: 'my-tests', - supportFile: false, + e2e: { + specPattern: 'my-tests/**/*', + supportFile: false, + }, }, }) .then(() => { diff --git a/packages/server/test/unit/modes/run_spec.js b/packages/server/test/unit/modes/run_spec.js index d4cf7890dacd..657523a394da 100644 --- a/packages/server/test/unit/modes/run_spec.js +++ b/packages/server/test/unit/modes/run_spec.js @@ -649,12 +649,6 @@ describe.skip('lib/modes/run', () => { proxyUrl: 'http://localhost:12345', video: true, videosFolder: 'videos', - integrationFolder: '/path/to/integrationFolder', - resolved: { - integrationFolder: { - integrationFolder: { value: '/path/to/integrationFolder', from: 'config' }, - }, - }, } sinon.stub(electron.app, 'on').withArgs('ready').yieldsAsync() diff --git a/packages/server/test/unit/plugins/preprocessor_spec.js b/packages/server/test/unit/plugins/preprocessor_spec.js index a85ca5d592a7..6fec8874aec6 100644 --- a/packages/server/test/unit/plugins/preprocessor_spec.js +++ b/packages/server/test/unit/plugins/preprocessor_spec.js @@ -14,7 +14,6 @@ describe('lib/plugins/preprocessor', () => { this.filePath = 'path/to/test.coffee' this.fullFilePath = path.join(this.todosPath, this.filePath) - this.integrationFolder = '/integration-path/' this.testPath = path.join(this.todosPath, 'test.coffee') this.localPreprocessorPath = path.join(this.todosPath, 'prep.coffee') @@ -45,13 +44,6 @@ describe('lib/plugins/preprocessor', () => { expect(this.plugin.lastCall.args[0].outputPath).to.equal(expectedPath) }) - it('executes the plugin with output path when integrationFolder was defined', function () { - preprocessor.getFile(this.integrationFolder + this.filePath, Object.assign({ integrationFolder: this.integrationFolder }, this.config)) - const expectedPath = appData.projectsPath(appData.toHashName(this.todosPath), 'bundles', this.filePath) - - expect(this.plugin.lastCall.args[0].outputPath).to.equal(expectedPath) - }) - it('returns a promise resolved with the plugin\'s outputPath', function () { return preprocessor.getFile(this.filePath, this.config).then((filePath) => { expect(filePath).to.equal('/path/to/output.js') diff --git a/packages/server/test/unit/project_spec.js b/packages/server/test/unit/project_spec.js index 5b4f8e656fcd..a63ecda652c4 100644 --- a/packages/server/test/unit/project_spec.js +++ b/packages/server/test/unit/project_spec.js @@ -94,10 +94,10 @@ describe.skip('lib/project-base', () => { context('#saveState', function () { beforeEach(function () { - const integrationFolder = 'the/save/state/test' + const supportFile = 'the/save/state/test' - sinon.stub(config, 'get').withArgs(this.todosPath).resolves({ integrationFolder }) - this.project.cfg = { integrationFolder } + sinon.stub(config, 'get').withArgs(this.todosPath).resolves({ supportFile }) + this.project.cfg = { supportFile } return savedState.create(this.project.projectRoot) .then((state) => state.remove()) @@ -135,11 +135,11 @@ describe.skip('lib/project-base', () => { }) context('#initializeConfig', () => { - const integrationFolder = 'foo/bar/baz' + const supportFile = 'foo/bar/baz' beforeEach(function () { sinon.stub(config, 'get').withArgs(this.todosPath, { foo: 'bar', configFile: 'cypress.config.js' }) - .resolves({ baz: 'quux', integrationFolder, browsers: [] }) + .resolves({ baz: 'quux', supportFile, browsers: [] }) }) it('calls config.get with projectRoot + options + saved state', function () { @@ -151,7 +151,7 @@ describe.skip('lib/project-base', () => { await this.project.initializeConfig() expect(this.project.getConfig()).to.deep.eq({ - integrationFolder, + supportFile, browsers: [], baz: 'quux', state: { @@ -163,12 +163,12 @@ describe.skip('lib/project-base', () => { it('resolves if cfg is already set', async function () { this.project._cfg = { - integrationFolder, + supportFile, foo: 'bar', } expect(this.project.getConfig()).to.deep.eq({ - integrationFolder, + supportFile, foo: 'bar', }) }) @@ -188,7 +188,7 @@ describe.skip('lib/project-base', () => { it('attaches warning to non-chrome browsers when chromeWebSecurity:false', async function () { const cfg = Object.assign({}, { - integrationFolder, + supportFile, browsers: [{ family: 'chromium', name: 'Canary' }, { family: 'some-other-family', name: 'some-other-name' }], chromeWebSecurity: false, }) @@ -225,7 +225,7 @@ This option will not have an effect in Some-other-name. Tests that rely on web s it('only attaches warning to non-chrome browsers when chromeWebSecurity:true', async function () { ctx.lifecycleManager.restore?.() sinon.stub(ctx.lifecycleManager, 'getFullInitialConfig').returns({ - integrationFolder, + supportFile, browsers: [{ family: 'chromium', name: 'Canary' }, { family: 'some-other-family', name: 'some-other-name' }], chromeWebSecurity: true, }) From f6253bc8cc7f01c77a4fd0ad17b56f98fd5a1461 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 23 Mar 2022 14:35:04 -0500 Subject: [PATCH 90/96] test: make sure tests fail --- .../config-update-non-migrated-value-e2e/cypress.config.js | 2 ++ .../projects/config-update-non-migrated-value/cypress.config.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/system-tests/projects/config-update-non-migrated-value-e2e/cypress.config.js b/system-tests/projects/config-update-non-migrated-value-e2e/cypress.config.js index fe61ca3c919f..461d0bb6a24d 100644 --- a/system-tests/projects/config-update-non-migrated-value-e2e/cypress.config.js +++ b/system-tests/projects/config-update-non-migrated-value-e2e/cypress.config.js @@ -3,6 +3,8 @@ module.exports = { supportFile: false, setupNodeEvents (on, config) { config.e2e.integrationFolder = 'path/to/integration/folder' + + return config }, }, } diff --git a/system-tests/projects/config-update-non-migrated-value/cypress.config.js b/system-tests/projects/config-update-non-migrated-value/cypress.config.js index 37cde0d63cec..16258119ab0d 100644 --- a/system-tests/projects/config-update-non-migrated-value/cypress.config.js +++ b/system-tests/projects/config-update-non-migrated-value/cypress.config.js @@ -3,6 +3,8 @@ module.exports = { supportFile: false, setupNodeEvents (on, config) { config.integrationFolder = 'path/to/integration/folder' + + return config }, }, } From bcbee9d135fbec91ded02cc6f6df640d9926661b Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 23 Mar 2022 14:41:25 -0500 Subject: [PATCH 91/96] better tests --- packages/config/tsconfig.json | 3 +-- .../e2e/config-files-error-handling.cy.ts | 2 ++ packages/types/src/config.ts | 24 ------------------- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json index 38874842a655..ee5b3255a487 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/tsconfig.json @@ -4,8 +4,7 @@ "src/*.ts" ], "exclude": [ - "test", - "script" + "test" ], "compilerOptions": { "strict": true, diff --git a/packages/launchpad/cypress/e2e/config-files-error-handling.cy.ts b/packages/launchpad/cypress/e2e/config-files-error-handling.cy.ts index 51d6bdef86be..f18ba9d5c587 100644 --- a/packages/launchpad/cypress/e2e/config-files-error-handling.cy.ts +++ b/packages/launchpad/cypress/e2e/config-files-error-handling.cy.ts @@ -149,7 +149,9 @@ describe('Launchpad: Error System Tests', () => { cy.get('[data-testid="error-code-frame"]').should('contain', 'cypress.config.js:4:23') }) +}) +describe('setupNodeEvents', () => { it('throws an error when in setupNodeEvents updating a config value that was removed in 10.X', () => { cy.scaffoldProject('config-update-non-migrated-value') cy.openProject('config-update-non-migrated-value') diff --git a/packages/types/src/config.ts b/packages/types/src/config.ts index 265043a6f61c..73c79f840127 100644 --- a/packages/types/src/config.ts +++ b/packages/types/src/config.ts @@ -44,27 +44,3 @@ export interface SettingsOptions { testingType?: 'component' |'e2e' args?: AllModeOptions } - -// Todo, move to @packages/config when it becomes type-safe - -export type BreakingOption = - | 'RENAMED_CONFIG_OPTION' - | 'EXPERIMENTAL_COMPONENT_TESTING_REMOVED' - | 'EXPERIMENTAL_SAMESITE_REMOVED' - | 'EXPERIMENTAL_NETWORK_STUBBING_REMOVED' - | 'EXPERIMENTAL_RUN_EVENTS_REMOVED' - | 'EXPERIMENTAL_SHADOW_DOM_REMOVED' - | 'EXPERIMENTAL_STUDIO_REMOVED' - | 'FIREFOX_GC_INTERVAL_REMOVED' - | 'NODE_VERSION_DEPRECATION_SYSTEM' - | 'NODE_VERSION_DEPRECATION_BUNDLED' - | 'CONFIG_FILE_INVALID_ROOT_CONFIG' - | 'CONFIG_FILE_INVALID_ROOT_CONFIG_E2E' - | 'CONFIG_FILE_INVALID_TESTING_TYPE_CONFIG_COMPONENT' - -export type BreakingErrResult = { - name: string - newName?: string - value?: any - configFile: string -} From 7fbe49c53363bcb0976abf4f811f9be0dff44714 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 23 Mar 2022 15:15:20 -0500 Subject: [PATCH 92/96] fix: validate testing type --- packages/config/package.json | 1 + packages/server/lib/config.ts | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/packages/config/package.json b/packages/config/package.json index 4b7f6b1449e6..faf10399d68f 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -24,6 +24,7 @@ "@packages/root": "0.0.0-development", "@packages/ts": "0.0.0-development", "@packages/types": "0.0.0-development", + "@types/mocha": "9.1.0", "chai": "4.2.0", "mocha": "7.0.1" }, diff --git a/packages/server/lib/config.ts b/packages/server/lib/config.ts index d717f9b3dece..747a41bc30e2 100644 --- a/packages/server/lib/config.ts +++ b/packages/server/lib/config.ts @@ -262,6 +262,14 @@ export function updateWithPluginValues (cfg, overrides) { throw errors.get(err, options) }) + configUtils.validateNoBreakingConfig(overrides.e2e, errors.warning, (err, options) => { + throw errors.get(err, { ...options, name: `e2e.${options.name}` }) + }) + + configUtils.validateNoBreakingConfig(overrides.component, errors.warning, (err, options) => { + throw errors.get(err, { ...options, name: `component.${options.name}` }) + }) + const originalResolvedBrowsers = _.cloneDeep(cfg?.resolved?.browsers) ?? { value: cfg.browsers, from: 'default', From 909e9855218718baef0e640e9c38d03085134aef Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 23 Mar 2022 16:21:32 -0500 Subject: [PATCH 93/96] test: fix integration test for server --- .../test/integration/http_requests_spec.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/server/test/integration/http_requests_spec.js b/packages/server/test/integration/http_requests_spec.js index aa46ae9f6150..92f95f6b7103 100644 --- a/packages/server/test/integration/http_requests_spec.js +++ b/packages/server/test/integration/http_requests_spec.js @@ -585,10 +585,8 @@ describe('Routes', () => { return this.setup({ projectRoot: Fixtures.projectPath('no-server'), config: { - e2e: { - specPattern: 'my-tests/**/*', - supportFile: 'helpers/includes.js', - }, + specPattern: 'my-tests/**/*', + supportFile: 'helpers/includes.js', }, }) }) @@ -793,10 +791,8 @@ describe('Routes', () => { return this.setup({ projectRoot: Fixtures.projectPath('todos'), config: { - e2e: { - specPattern: 'tests/**/*', - supportFile: false, - }, + specPattern: 'tests/**/*', + supportFile: false, fixturesFolder: 'tests/_fixtures', }, }) @@ -3104,10 +3100,8 @@ describe('Routes', () => { projectRoot: Fixtures.projectPath('no-server'), config: { fileServerFolder: 'dev', - e2e: { - specPattern: 'my-tests/**/*', - supportFile: false, - }, + specPattern: 'my-tests/**/*', + supportFile: false, }, }) .then(() => { From cac84aa9486a934b7def7f41942476342b1d0445 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 23 Mar 2022 16:50:14 -0500 Subject: [PATCH 94/96] update snapshot errors --- system-tests/__snapshots__/config_spec.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/system-tests/__snapshots__/config_spec.js b/system-tests/__snapshots__/config_spec.js index 99fbe39101cf..51972201ed98 100644 --- a/system-tests/__snapshots__/config_spec.js +++ b/system-tests/__snapshots__/config_spec.js @@ -303,6 +303,9 @@ The testFiles configuration option is now invalid when set on the config object https://on.cypress.io/migration-guide + + + ` exports['e2e config throws an error if componentFolder is set on the config file 1'] = ` @@ -319,4 +322,7 @@ The componentFolder configuration option is now invalid when set on the config o https://on.cypress.io/migration-guide + + + ` From db778b753b0be2c5e1fcf3b325dcafab657a17b3 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 23 Mar 2022 16:52:41 -0500 Subject: [PATCH 95/96] fix: make error_ui spec work --- .../project-root/cypress.config.js | 2 +- system-tests/test/error_ui_spec.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system-tests/projects/integration-outside-project-root/project-root/cypress.config.js b/system-tests/projects/integration-outside-project-root/project-root/cypress.config.js index b94c92b7a745..318c23cc16a8 100644 --- a/system-tests/projects/integration-outside-project-root/project-root/cypress.config.js +++ b/system-tests/projects/integration-outside-project-root/project-root/cypress.config.js @@ -1,6 +1,6 @@ module.exports = { - 'integrationFolder': '../integration', 'e2e': { + 'specPattern': '../integration/**/*', 'supportFile': false, }, } diff --git a/system-tests/test/error_ui_spec.ts b/system-tests/test/error_ui_spec.ts index 966fd622b3fd..8fa8bebc7b09 100644 --- a/system-tests/test/error_ui_spec.ts +++ b/system-tests/test/error_ui_spec.ts @@ -34,7 +34,7 @@ describe('e2e error ui', function () { }) // https://github.com/cypress-io/cypress/issues/16255 - systemTests.it('handles errors when integration folder is outside of project root', { + systemTests.it('handles errors when test files are outside of project root', { project: 'integration-outside-project-root/project-root', spec: '../../../e2e/failing.cy.js', expectedExitCode: 1, From b6cd9d864c4cf24c87ea28c9f4aa376fd040c617 Mon Sep 17 00:00:00 2001 From: ElevateBart Date: Wed, 23 Mar 2022 17:36:48 -0500 Subject: [PATCH 96/96] test: fix snapshots --- system-tests/__snapshots__/config_spec.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/system-tests/__snapshots__/config_spec.js b/system-tests/__snapshots__/config_spec.js index 51972201ed98..9bd60e9dfffa 100644 --- a/system-tests/__snapshots__/config_spec.js +++ b/system-tests/__snapshots__/config_spec.js @@ -302,9 +302,9 @@ The testFiles configuration option is now invalid when set on the config object } https://on.cypress.io/migration-guide - - - + + + ` @@ -322,7 +322,7 @@ The componentFolder configuration option is now invalid when set on the config o https://on.cypress.io/migration-guide - - + + `