Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
4 changes: 2 additions & 2 deletions browser-versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"chrome:beta": "94.0.4606.54",
"chrome:stable": "94.0.4606.54"
"chrome:beta": "95.0.4638.32",
"chrome:stable": "94.0.4606.71"
}
14 changes: 14 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,7 @@ jobs:
- run: yarn lerna run types
# check for compile errors with the releaserc scripts
- run: yarn test-npm-package-release-script

- verify-mocha-results:
expectedResultCount: 9
- store_test_results:
Expand All @@ -1043,6 +1044,14 @@ jobs:
path: cli/test/html
- store-npm-logs

unit-tests-release:
<<: *defaults
resource_class: medium
parallelism: 1
steps:
- restore_cached_workspace
- run: yarn test-npm-package-release-script

lint-types:
<<: *defaults
parallelism: 1
Expand Down Expand Up @@ -2055,6 +2064,10 @@ linux-workflow: &linux-workflow
- unit-tests:
requires:
- build
- unit-tests-release:
context: test-runner:npm-release
requires:
- build
- server-unit-tests:
requires:
- build
Expand Down Expand Up @@ -2204,6 +2217,7 @@ linux-workflow: &linux-workflow
- server-integration-tests
- server-unit-tests
- unit-tests
- unit-tests-release
- cli-visual-tests

# various testing scenarios, like building full binary
Expand Down
17 changes: 17 additions & 0 deletions cli/lib/cypress.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ const cypressModuleApi = {
return cli.parseRunCommand(args)
},
},

/**
* Provides automatic code completion for configuration in many popular code editors.
* While it's not strictly necessary for Cypress to parse your configuration, we
* recommend wrapping your config object with `defineConfig()`
* @example
* module.exports = defineConfig({
* viewportWith: 400
* })
*
* @see ../types/cypress-npm-api.d.ts
* @param {Cypress.ConfigOptions} config
* @returns {Cypress.ConfigOptions} the configuration passed in parameter
*/
defineConfig (config) {
return config
},
}

module.exports = cypressModuleApi
15 changes: 15 additions & 0 deletions cli/types/cypress-npm-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,21 @@ declare module 'cypress' {
* Cypress does
*/
cli: CypressCommandLine.CypressCliParser

/**
* Provides automatic code completion for configuration in many popular code editors.
* While it's not strictly necessary for Cypress to parse your configuration, we
* recommend wrapping your config object with `defineConfig()`
* @example
* module.exports = defineConfig({
* viewportWith: 400
* })
*
* @see ../types/cypress-npm-api.d.ts
* @param {Cypress.ConfigOptions} config
* @returns {Cypress.ConfigOptions} the configuration passed in parameter
*/
defineConfig(config: Cypress.ConfigOptions): Cypress.ConfigOptions
}

// export Cypress NPM module interface
Expand Down
181 changes: 88 additions & 93 deletions cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ declare namespace Cypress {
/**
* The interface for user-defined properties in Window object under test.
*/
interface ApplicationWindow {} // tslint:disable-line
interface ApplicationWindow { } // tslint:disable-line

/**
* Several libraries are bundled with Cypress by default.
Expand Down Expand Up @@ -521,7 +521,7 @@ declare namespace Cypress {
/**
* @see https://on.cypress.io/keyboard-api
*/
Keyboard: {
Keyboard: {
defaults(options: Partial<KeyboardDefaultsOptions>): void
}

Expand Down Expand Up @@ -579,7 +579,7 @@ declare namespace Cypress {
}

interface SessionOptions {
validate?: () => false|void
validate?: () => false | void
}

type CanReturnChainable = void | Chainable | Promise<unknown>
Expand Down Expand Up @@ -717,36 +717,36 @@ declare namespace Cypress {
```
*/
clearLocalStorage(re: RegExp): Chainable<Storage>
/**
* Clear data in local storage.
* Cypress automatically runs this command before each test to prevent state from being
* shared across tests. You shouldn’t need to use this command unless you’re using it
* to clear localStorage inside a single test. Yields `localStorage` object.
*
* @see https://on.cypress.io/clearlocalstorage
* @param {options} [object] - options object
* @example
```
// Removes all local storage items, without logging
cy.clearLocalStorage({ log: false })
```
*/
/**
* Clear data in local storage.
* Cypress automatically runs this command before each test to prevent state from being
* shared across tests. You shouldn’t need to use this command unless you’re using it
* to clear localStorage inside a single test. Yields `localStorage` object.
*
* @see https://on.cypress.io/clearlocalstorage
* @param {options} [object] - options object
* @example
```
// Removes all local storage items, without logging
cy.clearLocalStorage({ log: false })
```
*/
clearLocalStorage(options: Partial<Loggable>): Chainable<Storage>
/**
* Clear data in local storage.
* Cypress automatically runs this command before each test to prevent state from being
* shared across tests. You shouldn’t need to use this command unless you’re using it
* to clear localStorage inside a single test. Yields `localStorage` object.
*
* @see https://on.cypress.io/clearlocalstorage
* @param {string} [key] - name of a particular item to remove (optional).
* @param {options} [object] - options object
* @example
```
// Removes item "todos" without logging
cy.clearLocalStorage("todos", { log: false })
```
*/
/**
* Clear data in local storage.
* Cypress automatically runs this command before each test to prevent state from being
* shared across tests. You shouldn’t need to use this command unless you’re using it
* to clear localStorage inside a single test. Yields `localStorage` object.
*
* @see https://on.cypress.io/clearlocalstorage
* @param {string} [key] - name of a particular item to remove (optional).
* @param {options} [object] - options object
* @example
```
// Removes item "todos" without logging
cy.clearLocalStorage("todos", { log: false })
```
*/
clearLocalStorage(key: string, options: Partial<Loggable>): Chainable<Storage>

/**
Expand Down Expand Up @@ -834,7 +834,7 @@ declare namespace Cypress {
* // or use this shortcut
* cy.clock().invoke('restore')
*/
clock(now: number|Date, options?: Loggable): Chainable<Clock>
clock(now: number | Date, options?: Loggable): Chainable<Clock>
/**
* Mocks global clock but only overrides specific functions.
*
Expand All @@ -843,7 +843,7 @@ declare namespace Cypress {
* // keep current date but override "setTimeout" and "clearTimeout"
* cy.clock(null, ['setTimeout', 'clearTimeout'])
*/
clock(now: number|Date, functions?: Array<'setTimeout' | 'clearTimeout' | 'setInterval' | 'clearInterval' | 'Date'>, options?: Loggable): Chainable<Clock>
clock(now: number | Date, functions?: Array<'setTimeout' | 'clearTimeout' | 'setInterval' | 'clearInterval' | 'Date'>, options?: Loggable): Chainable<Clock>
/**
* Mocks global clock and all functions.
*
Expand Down Expand Up @@ -977,14 +977,14 @@ declare namespace Cypress {
*/
debug(options?: Partial<Loggable>): Chainable<Subject>

/**
* Save/Restore browser Cookies, LocalStorage, and SessionStorage data resulting from the supplied `setup` function.
*
* Only available if the `experimentalSessionSupport` config option is enabled.
*
* @see https://on.cypress.io/session
*/
session(id: string|object, setup?: SessionOptions['validate'], options?: SessionOptions): Chainable<null>
/**
* Save/Restore browser Cookies, LocalStorage, and SessionStorage data resulting from the supplied `setup` function.
*
* Only available if the `experimentalSessionSupport` config option is enabled.
*
* @see https://on.cypress.io/session
*/
session(id: string | object, setup?: SessionOptions['validate'], options?: SessionOptions): Chainable<null>

/**
* Get the window.document of the page that is currently active.
Expand Down Expand Up @@ -1648,17 +1648,11 @@ declare namespace Cypress {
scrollTo(x: number | string, y: number | string, options?: Partial<ScrollToOptions>): Chainable<Subject>

/**
* Select an `<option>` with specific text within a `<select>`.
*
* @see https://on.cypress.io/select
*/
select(text: string | string[], options?: Partial<SelectOptions>): Chainable<Subject>
/**
* Select an `<option>` with specific value(s) within a `<select>`.
* Select an `<option>` with specific text, value, or index within a `<select>`.
*
* @see https://on.cypress.io/select
*/
select(value: string | string[], options?: Partial<SelectOptions>): Chainable<Subject>
select(valueOrTextOrIndex: string | number | Array<string | number>, options?: Partial<SelectOptions>): Chainable<Subject>

/**
* @deprecated Use `cy.intercept()` instead.
Expand Down Expand Up @@ -1909,13 +1903,13 @@ declare namespace Cypress {
*
* @see https://on.cypress.io/then
*/
then<S extends HTMLElement>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<JQuery<S>>
/**
* Enables you to work with the subject yielded from the previous command / promise.
*
* @see https://on.cypress.io/then
*/
then<S extends ArrayLike<HTMLElement>>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<JQuery<S extends ArrayLike<infer T> ? T : never>>
then<S extends HTMLElement>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<JQuery<S>>
/**
* Enables you to work with the subject yielded from the previous command / promise.
*
* @see https://on.cypress.io/then
*/
then<S extends ArrayLike<HTMLElement>>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<JQuery<S extends ArrayLike<infer T> ? T : never>>
/**
* Enables you to work with the subject yielded from the previous command / promise.
*
Expand Down Expand Up @@ -2754,7 +2748,7 @@ declare namespace Cypress {
* To enable test retries only in runMode, set e.g. `{ openMode: null, runMode: 2 }`
* @default null
*/
retries: Nullable<number | {runMode?: Nullable<number>, openMode?: Nullable<number>}>
retries: Nullable<number | { runMode?: Nullable<number>, openMode?: Nullable<number> }>
/**
* Enables including elements within the shadow DOM when using querying
* commands (e.g. cy.get(), cy.find()). Can be set globally in cypress.json,
Expand Down Expand Up @@ -2891,7 +2885,7 @@ declare namespace Cypress {
* All configuration items are optional.
*/
type CoreConfigOptions = Partial<Omit<ResolvedConfigOptions, TestingType>>
type ConfigOptions = CoreConfigOptions & {e2e?: CoreConfigOptions, component?: CoreConfigOptions }
type ConfigOptions = CoreConfigOptions & { e2e?: CoreConfigOptions, component?: CoreConfigOptions }

interface PluginConfigOptions extends ResolvedConfigOptions {
/**
Expand Down Expand Up @@ -2998,6 +2992,7 @@ declare namespace Cypress {
disableTimersAndAnimations: boolean
padding: Padding
scale: boolean
overwrite: boolean
onBeforeScreenshot: ($el: JQuery) => void
onAfterScreenshot: ($el: JQuery, props: {
path: string
Expand Down Expand Up @@ -5703,48 +5698,48 @@ declare namespace Cypress {
}
```
*/
interface cy extends Chainable<undefined> {}
interface cy extends Chainable<undefined> { }
}

declare namespace Mocha {
interface TestFunction {
/**
* Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
* as a thunk.
*/
(title: string, config: Cypress.TestConfigOverrides, fn?: Func): Test

/**
* Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
* as a thunk.
*/
(title: string, config: Cypress.TestConfigOverrides, fn?: AsyncFunc): Test
/**
* Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
* as a thunk.
*/
(title: string, config: Cypress.TestConfigOverrides, fn?: Func): Test

/**
* Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
* as a thunk.
*/
(title: string, config: Cypress.TestConfigOverrides, fn?: AsyncFunc): Test
}
interface ExclusiveTestFunction {
/**
* Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
* as a thunk.
*/
(title: string, config: Cypress.TestConfigOverrides, fn?: Func): Test

/**
* Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
* as a thunk.
*/
(title: string, config: Cypress.TestConfigOverrides, fn?: AsyncFunc): Test
/**
* Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
* as a thunk.
*/
(title: string, config: Cypress.TestConfigOverrides, fn?: Func): Test

/**
* Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
* as a thunk.
*/
(title: string, config: Cypress.TestConfigOverrides, fn?: AsyncFunc): Test
}
interface PendingTestFunction {
/**
* Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
* as a thunk.
*/
(title: string, config: Cypress.TestConfigOverrides, fn?: Func): Test

/**
* Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
* as a thunk.
*/
(title: string, config: Cypress.TestConfigOverrides, fn?: AsyncFunc): Test
/**
* Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
* as a thunk.
*/
(title: string, config: Cypress.TestConfigOverrides, fn?: Func): Test

/**
* Describe a specification or test-case with the given `title`, TestOptions, and callback `fn` acting
* as a thunk.
*/
(title: string, config: Cypress.TestConfigOverrides, fn?: AsyncFunc): Test
}

interface SuiteFunction {
Expand Down
Loading