Files
cypress/system-tests/test/plugins_spec.js
Rachel ab23d7797b chore: skip or fix flaky tests II (#23386)
* fix leftover percy network-idle-timeout

* Skip another instance of 23153

* fix 23147

* Revert fix 23147

* try percy upgrade again

* Update yarn.lock

* skip 23404

* bring in emilys override version change for percy ui

* skip 23406

* skip 23407

* downgrade percy to 1.2.0

* fix percy diff

* fix percy diff

* update comment

* restore lock file

* Update yarn.lock

* Update yarn.lock

* percy fixes

* possible fix

* fix verison flake??

* Revert "fix percy diff"

This reverts commit e4c4e2e990.

* Revert "Revert "fix percy diff""

This reverts commit 94284e4694.

* Remove version assertion

* Trigger Build

* ignore spec duration in percy snapshots

* use .each to preserve order of execution

* add comment

* fix comment

* try new logic for header wait

* Revert "try new logic for header wait"

This reverts commit bfed31edce.

* add timeout to choose a browser

* Trigger Build

* try without promise.all; revert timeout to choose a browser tests

* ignore spec-duration in percy in runner

* clean up .thens

* clean up diffs

* move around .thens

* wait for tooltip to take snapshot, skip flakers

* try hiding spec duration

* Revert: try hiding spec duration

* Bring back duration mock

* Add another duration mock

* try cy.contains with tooltip, comment out removeGlobalStyles

* skip 23417

* skip choose a browser failures

* skip 23419

* skip 23414

* bring back // removeGlobalStyles()

* skip 23422

* skip 23423

* skip 23424

* set version to empty string to make percy happy

* Remove duration mock

* Do not display top-nav-cypress-version-current-link, skip 23433?

* skip 23434, clean up diffs

* clean up diffs, skip percy flake

* skip 23434

* skip 23437

* fix 23156

* fix 23250 and similar

* fix 23157

* skip more percies

* skip 23443

* skip more tooltip snapshots

* Update net_stubbing.cy.ts

* Update cookies.cy.js

* Update e2e_cookies.cy.js

* add missing github issue

* Update circle.yml

* Skip all of network stubbing

* Skip 23158

* Skip 23448

* remove unnecessary async, add skip for 23444

* more skips for 23444

* skip 23451

* More skips 23436

* More skips 23444

* skip 23455

* more skips 23444

* skip 23457

* more skips 23444

* mroe skip 23455

* Trigger Build

* skip set cookie 23444

* skip 21300

* skip 23417

* Trigger Build

* potential fix for 23308

* skip 23472

* skip snapshot

* skip 23474

* Trigger Build

* Trigger Build

* Trigger Build

* Trigger Build

* skip more 23245

* Trigger Build

* Trigger Build

* Trigger Build

* Trigger Build

* Trigger Build

* Trigger Build

* Trigger Build

* skip 23480,23481

* skip 23307

* Trigger Build

* addtl skip 23481

* skip 23484

* try cy.origin stability fix on nav commands issue

* Revert: try cy.origin stability fix on nav commands issue

* skip more 23452

* Trigger Build

* Trigger Build

* Trigger Build

* Trigger Build

* Trigger Build

* Trigger Build

* Trigger Build

* Trigger Build

* skip 23493

* Trigger Build
2022-08-22 10:50:12 -07:00

252 lines
7.2 KiB
JavaScript

const path = require('path')
const systemTests = require('../lib/system-tests').default
const Fixtures = require('../lib/fixtures')
const e2eProject = Fixtures.projectPath('e2e')
describe('e2e plugins', function () {
systemTests.setup()
// this tests verifies stdout manually instead of via snapshot because
// there's a degree of randomness as to whether the error occurs before or
// after the run output starts. the important thing is that the run is
// failed and the right error is displayed
systemTests.it('fails when there is an async error at the root', {
browser: 'chrome',
spec: 'app.cy.js',
project: 'plugins-root-async-error',
expectedExitCode: 1,
onRun (exec) {
return exec().then(({ stdout }) => {
expect(stdout).to.include('We stopped running your tests because your config file crashed.')
expect(stdout).to.include('Your configFile threw an error from: cypress.config.js')
expect(stdout).to.include('Error: Root async error from config file')
})
},
})
// TODO: fix flaky test https://github.com/cypress-io/cypress/issues/23493
it.skip('fails when there is an async error inside an event handler', function () {
return systemTests.exec(this, {
spec: 'app.cy.js',
project: 'plugins-async-error',
sanitizeScreenshotDimensions: true,
snapshot: true,
expectedExitCode: 1,
config: {
video: false,
},
})
})
it('can modify config from plugins', function () {
return systemTests.exec(this, {
spec: 'app.cy.js',
env: 'foo=foo,bar=bar',
config: { pageLoadTimeout: 10000 },
project: 'plugin-config',
sanitizeScreenshotDimensions: true,
snapshot: true,
})
})
it('passes version correctly', function () {
return systemTests.exec(this, {
project: 'plugin-config-version',
})
})
it('catches invalid viewportWidth returned from plugins', function () {
// the test project returns config object with a bad value
return systemTests.exec(this, {
project: 'plugin-returns-bad-config',
expectedExitCode: 1,
snapshot: true,
})
})
it('catches invalid browsers list returned from plugins', function () {
return systemTests.exec(this, {
project: 'plugin-returns-empty-browsers-list',
expectedExitCode: 1,
snapshot: true,
})
})
it('catches invalid browser returned from plugins', function () {
return systemTests.exec(this, {
project: 'plugin-returns-invalid-browser',
expectedExitCode: 1,
snapshot: true,
})
})
it('can filter browsers from config', function () {
return systemTests.exec(this, {
project: 'plugin-filter-browsers',
// the test project filters available browsers
// and returns a list with JUST Electron browser
// and we ask to run in Chrome
// thus the test should fail
browser: 'chrome',
expectedExitCode: 1,
snapshot: true,
// we are interested in the actual filtered available browser name
// which should be "electron"
normalizeStdoutAvailableBrowsers: false,
})
})
systemTests.it('works with user extensions', {
browser: 'chrome',
spec: 'app.cy.js',
headed: true,
project: 'plugin-extension',
sanitizeScreenshotDimensions: true,
snapshot: true,
})
const pluginAfterScreenshot = 'plugin-after-screenshot'
it('calls after:screenshot for cy.screenshot() and failure screenshots', function () {
return systemTests.exec(this, {
spec: 'after_screenshot.cy.js',
project: pluginAfterScreenshot,
sanitizeScreenshotDimensions: true,
snapshot: true,
expectedExitCode: 1,
})
})
// https://github.com/cypress-io/cypress/issues/8079
it('does not report more screenshots than exist if user overwrites previous screenshot in afterScreenshot', function () {
return systemTests.exec(this, {
spec: 'after_screenshot_overwrite.cy.js',
project: pluginAfterScreenshot,
snapshot: true,
})
})
it('fails when invalid event is registered', function () {
return systemTests.exec(this, {
spec: 'app.cy.js',
project: 'plugin-validation-error',
sanitizeScreenshotDimensions: true,
snapshot: true,
expectedExitCode: 1,
})
})
it('fails when invalid event handler is registered', function () {
return systemTests.exec(this, {
spec: 'app.cy.js',
project: 'plugin-invalid-event-handler-error',
sanitizeScreenshotDimensions: true,
snapshot: true,
expectedExitCode: 1,
})
})
it('fails when setupNodeEvents is not a function', function () {
return systemTests.exec(this, {
spec: 'app.cy.js',
project: 'plugin-empty',
sanitizeScreenshotDimensions: true,
snapshot: true,
expectedExitCode: 1,
})
})
it('fails when there is no function exported', function () {
return systemTests.exec(this, {
spec: 'app_spec.js',
project: 'plugin-no-function-return',
sanitizeScreenshotDimensions: true,
snapshot: true,
expectedExitCode: 1,
})
})
it('fails when require throws synchronously', function () {
return systemTests.exec(this, {
spec: 'app_spec.js',
project: 'plugins-root-sync-error',
sanitizeScreenshotDimensions: true,
snapshot: true,
expectedExitCode: 1,
})
})
it('fails when require has a syntax error', function () {
return systemTests.exec(this, {
spec: 'app_spec.js',
project: 'plugins-root-syntax-error',
sanitizeScreenshotDimensions: true,
snapshot: true,
expectedExitCode: 1,
})
})
it('fails when function throws synchronously', function () {
return systemTests.exec(this, {
spec: 'app_spec.js',
project: 'plugins-function-sync-error',
sanitizeScreenshotDimensions: true,
snapshot: true,
expectedExitCode: 1,
})
})
describe('preprocessor', function () {
it('passes with working preprocessor', function () {
return systemTests.exec(this, {
spec: 'app.cy.js',
project: 'working-preprocessor',
sanitizeScreenshotDimensions: true,
snapshot: true,
})
})
it('supports node builtins', function () {
return systemTests.exec(this, {
spec: 'node_builtins.cy.js',
})
})
// https://github.com/cypress-io/cypress/issues/8361
it('supports .mjs files', function () {
return systemTests.exec(this, {
spec: 'mjs_spec.cy.mjs',
})
})
})
describe('extra properties', function () {
it('passes projectRoot and default configFile to plugins function', function () {
return systemTests.exec(this, {
spec: 'plugins_config_extras.cy.js',
config: {
env: {
projectRoot: e2eProject,
configFile: path.join(e2eProject, 'cypress.config.js'),
},
},
})
})
it('passes custom configFile to plugins function', function () {
return systemTests.exec(this, {
spec: 'plugins_config_extras.cy.js',
configFile: 'cypress-alt.config.js',
config: {
env: {
projectRoot: e2eProject,
configFile: path.join(e2eProject, 'cypress-alt.config.js'),
},
},
})
})
})
})