From 98874cccae6ba25e86314f7f311a5633acf49acd Mon Sep 17 00:00:00 2001 From: Chris Breiding Date: Mon, 24 Aug 2020 11:19:34 -0400 Subject: [PATCH 1/3] clean up plugins e2e spec --- packages/server/test/e2e/3_plugins_spec.js | 66 ++++++++++------------ 1 file changed, 29 insertions(+), 37 deletions(-) diff --git a/packages/server/test/e2e/3_plugins_spec.js b/packages/server/test/e2e/3_plugins_spec.js index b2dfab284519..009958476ffc 100644 --- a/packages/server/test/e2e/3_plugins_spec.js +++ b/packages/server/test/e2e/3_plugins_spec.js @@ -4,33 +4,10 @@ const e2e = require('../support/helpers/e2e').default const Fixtures = require('../support/helpers/fixtures') const e2eProject = Fixtures.projectPath('e2e') -const pluginExtension = Fixtures.projectPath('plugin-extension') -const pluginConfig = Fixtures.projectPath('plugin-config') -const pluginConfigVersion = Fixtures.projectPath('plugin-config-version') -const pluginFilterBrowsers = Fixtures.projectPath('plugin-filter-browsers') -const workingPreprocessor = Fixtures.projectPath('working-preprocessor') -const pluginsRootAsyncError = Fixtures.projectPath('plugins-root-async-error') -const pluginsAsyncError = Fixtures.projectPath('plugins-async-error') -const pluginsAbsolutePath = Fixtures.projectPath('plugins-absolute-path') -const pluginAfterScreenshot = Fixtures.projectPath('plugin-after-screenshot') -const pluginReturnsBadConfig = Fixtures.projectPath('plugin-returns-bad-config') -const pluginReturnsEmptyBrowsersList = Fixtures.projectPath('plugin-returns-empty-browsers-list') -const pluginReturnsInvalidBrowser = Fixtures.projectPath('plugin-returns-invalid-browser') -const pluginValidationError = Fixtures.projectPath('plugin-validation-error') -const pluginEmpty = Fixtures.projectPath('plugin-empty') describe('e2e plugins', function () { e2e.setup() - it('passes with working preprocessor', function () { - return e2e.exec(this, { - spec: 'app_spec.coffee', - project: workingPreprocessor, - sanitizeScreenshotDimensions: true, - snapshot: true, - }) - }) - // 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 @@ -38,7 +15,7 @@ describe('e2e plugins', function () { e2e.it('fails when there is an async error at the root', { browser: 'chrome', spec: 'app_spec.js', - project: pluginsRootAsyncError, + project: Fixtures.projectPath('plugins-root-async-error'), expectedExitCode: 1, onRun (exec) { return exec().then(({ stdout }) => { @@ -51,7 +28,7 @@ describe('e2e plugins', function () { it('fails when there is an async error inside an event handler', function () { return e2e.exec(this, { spec: 'app_spec.coffee', - project: pluginsAsyncError, + project: Fixtures.projectPath('plugins-async-error'), sanitizeScreenshotDimensions: true, snapshot: true, expectedExitCode: 1, @@ -63,7 +40,7 @@ describe('e2e plugins', function () { spec: 'app_spec.coffee', env: 'foo=foo,bar=bar', config: { pageLoadTimeout: 10000 }, - project: pluginConfig, + project: Fixtures.projectPath('plugin-config'), sanitizeScreenshotDimensions: true, snapshot: true, }) @@ -71,14 +48,14 @@ describe('e2e plugins', function () { it('passes version correctly', function () { return e2e.exec(this, { - project: pluginConfigVersion, + project: Fixtures.projectPath('plugin-config-version'), }) }) it('catches invalid viewportWidth returned from plugins', function () { // the test project returns config object with a bad value return e2e.exec(this, { - project: pluginReturnsBadConfig, + project: Fixtures.projectPath('plugin-returns-bad-config'), expectedExitCode: 1, snapshot: true, }) @@ -86,7 +63,7 @@ describe('e2e plugins', function () { it('catches invalid browsers list returned from plugins', function () { return e2e.exec(this, { - project: pluginReturnsEmptyBrowsersList, + project: Fixtures.projectPath('plugin-returns-empty-browsers-list'), expectedExitCode: 1, snapshot: true, }) @@ -94,7 +71,7 @@ describe('e2e plugins', function () { it('catches invalid browser returned from plugins', function () { return e2e.exec(this, { - project: pluginReturnsInvalidBrowser, + project: Fixtures.projectPath('plugin-returns-invalid-browser'), expectedExitCode: 1, snapshot: true, }) @@ -102,7 +79,7 @@ describe('e2e plugins', function () { it('can filter browsers from config', function () { return e2e.exec(this, { - project: pluginFilterBrowsers, + project: Fixtures.projectPath('plugin-filter-browsers'), // the test project filters available browsers // and returns a list with JUST Electron browser // and we ask to run in Chrome @@ -120,12 +97,14 @@ describe('e2e plugins', function () { browser: 'chrome', spec: 'app_spec.coffee', headed: true, - project: pluginExtension, + project: Fixtures.projectPath('plugin-extension'), sanitizeScreenshotDimensions: true, snapshot: true, }) it('handles absolute path to pluginsFile', function () { + const pluginsAbsolutePath = Fixtures.projectPath('plugins-absolute-path') + return e2e.exec(this, { spec: 'absolute_spec.coffee', config: { @@ -140,6 +119,8 @@ describe('e2e plugins', function () { }) }) + const pluginAfterScreenshot = Fixtures.projectPath('plugin-after-screenshot') + it('calls after:screenshot for cy.screenshot() and failure screenshots', function () { return e2e.exec(this, { spec: 'after_screenshot_spec.coffee', @@ -162,7 +143,7 @@ describe('e2e plugins', function () { it('fails when invalid event is registered', function () { return e2e.exec(this, { spec: 'app_spec.js', - project: pluginValidationError, + project: Fixtures.projectPath('plugin-validation-error'), sanitizeScreenshotDimensions: true, snapshot: true, expectedExitCode: 1, @@ -172,16 +153,27 @@ describe('e2e plugins', function () { it('fails when there is no function exported', function () { return e2e.exec(this, { spec: 'app_spec.js', - project: pluginEmpty, + project: Fixtures.projectPath('plugin-empty'), sanitizeScreenshotDimensions: true, snapshot: true, expectedExitCode: 1, }) }) - it('supports node builtins', function () { - return e2e.exec(this, { - spec: 'node_builtins_spec.js', + describe('preprocessor', function () { + it('passes with working preprocessor', function () { + return e2e.exec(this, { + spec: 'app_spec.coffee', + project: Fixtures.projectPath('working-preprocessor'), + sanitizeScreenshotDimensions: true, + snapshot: true, + }) + }) + + it('supports node builtins', function () { + return e2e.exec(this, { + spec: 'node_builtins_spec.js', + }) }) }) From f1ecbaf5f0f350b53ebcef7d898e2769a06984d8 Mon Sep 17 00:00:00 2001 From: Chris Breiding Date: Mon, 24 Aug 2020 14:38:52 -0400 Subject: [PATCH 2/3] fix: Fix support for .mjs files --- packages/server/__snapshots__/3_plugins_spec.js | 2 +- packages/server/package.json | 2 +- packages/server/test/e2e/3_plugins_spec.js | 7 +++++++ .../fixtures/projects/e2e/cypress/fixtures/mjs_file.mjs | 1 + .../projects/e2e/cypress/integration/mjs_spec.mjs | 5 +++++ yarn.lock | 8 ++++---- 6 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 packages/server/test/support/fixtures/projects/e2e/cypress/fixtures/mjs_file.mjs create mode 100644 packages/server/test/support/fixtures/projects/e2e/cypress/integration/mjs_spec.mjs diff --git a/packages/server/__snapshots__/3_plugins_spec.js b/packages/server/__snapshots__/3_plugins_spec.js index ebe43b1b2a64..5b676f189e05 100644 --- a/packages/server/__snapshots__/3_plugins_spec.js +++ b/packages/server/__snapshots__/3_plugins_spec.js @@ -1,4 +1,4 @@ -exports['e2e plugins passes with working preprocessor 1'] = ` +exports['e2e plugins preprocessor passes with working preprocessor 1'] = ` ==================================================================================================== diff --git a/packages/server/package.json b/packages/server/package.json index a0778a194229..530b81398e66 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -27,7 +27,7 @@ "@cypress/mocha-teamcity-reporter": "1.0.0", "@cypress/request": "2.88.5", "@cypress/request-promise": "4.2.6", - "@cypress/webpack-batteries-included-preprocessor": "2.0.1", + "@cypress/webpack-batteries-included-preprocessor": "2.1.1", "@cypress/webpack-preprocessor": "5.4.4", "@ffmpeg-installer/ffmpeg": "1.0.20", "ansi_up": "4.0.4", diff --git a/packages/server/test/e2e/3_plugins_spec.js b/packages/server/test/e2e/3_plugins_spec.js index 009958476ffc..857f35e04ffb 100644 --- a/packages/server/test/e2e/3_plugins_spec.js +++ b/packages/server/test/e2e/3_plugins_spec.js @@ -175,6 +175,13 @@ describe('e2e plugins', function () { spec: 'node_builtins_spec.js', }) }) + + // https://github.com/cypress-io/cypress/issues/8361 + it('supports .mjs files', function () { + return e2e.exec(this, { + spec: 'mjs_spec.mjs', + }) + }) }) describe('projectRoot and configFile', function () { diff --git a/packages/server/test/support/fixtures/projects/e2e/cypress/fixtures/mjs_file.mjs b/packages/server/test/support/fixtures/projects/e2e/cypress/fixtures/mjs_file.mjs new file mode 100644 index 000000000000..adce001e24fb --- /dev/null +++ b/packages/server/test/support/fixtures/projects/e2e/cypress/fixtures/mjs_file.mjs @@ -0,0 +1 @@ +export const imFromMjs = 'I am from .mjs :)' diff --git a/packages/server/test/support/fixtures/projects/e2e/cypress/integration/mjs_spec.mjs b/packages/server/test/support/fixtures/projects/e2e/cypress/integration/mjs_spec.mjs new file mode 100644 index 000000000000..a5a99ef8dafc --- /dev/null +++ b/packages/server/test/support/fixtures/projects/e2e/cypress/integration/mjs_spec.mjs @@ -0,0 +1,5 @@ +import { imFromMjs } from '../fixtures/mjs_file' + +it('supports .mjs', () => { + expect(imFromMjs).to.equal('I am from .mjs :)') +}) diff --git a/yarn.lock b/yarn.lock index 6aef2bd18927..e396e3ef79dc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1934,10 +1934,10 @@ dependencies: css.escape "^1.5.1" -"@cypress/webpack-batteries-included-preprocessor@2.0.1": - version "2.0.1" - resolved "https://registry.yarnpkg.com/@cypress/webpack-batteries-included-preprocessor/-/webpack-batteries-included-preprocessor-2.0.1.tgz#1c3aa575ead5f3f2f5a1da149e57a9ed30895813" - integrity sha512-pBg80Yur3GivxBiVsm62UFBrTIz/SnoPl2l2ybOR+O3DcbJIuxKFUbCqyDZ3tFP6POE8d/Zb2NgZCeLWSKsOVQ== +"@cypress/webpack-batteries-included-preprocessor@2.1.1": + version "2.1.1" + resolved "https://registry.yarnpkg.com/@cypress/webpack-batteries-included-preprocessor/-/webpack-batteries-included-preprocessor-2.1.1.tgz#4f914a25b2f3b619a1ee94418418c1635d75732f" + integrity sha512-2VOP1pyv8CNE5yGlebV4WnSffH4WymjZSUoww3Au8el2+xUY76uu1yr7Xpc2Tumey0JqI8lCikTYuNQ5GSf32A== dependencies: "@babel/core" "^7.11.1" "@babel/plugin-proposal-class-properties" "^7.10.4" From be20c16381b51b4dbeb05f5020d0b1cef208e4c4 Mon Sep 17 00:00:00 2001 From: Chris Breiding Date: Mon, 24 Aug 2020 15:43:39 -0400 Subject: [PATCH 3/3] update snapshots --- packages/server/__snapshots__/1_busted_support_file_spec.js | 1 + packages/server/__snapshots__/7_record_spec.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/packages/server/__snapshots__/1_busted_support_file_spec.js b/packages/server/__snapshots__/1_busted_support_file_spec.js index 13f96bdac038..db497dd97229 100644 --- a/packages/server/__snapshots__/1_busted_support_file_spec.js +++ b/packages/server/__snapshots__/1_busted_support_file_spec.js @@ -29,6 +29,7 @@ Looked for and couldn't find the file at the following paths: [/foo/bar/.projects/busted-support-file/cypress/support/does/not/exist.js] [/foo/bar/.projects/busted-support-file/cypress/support/does/not/exist.json] [/foo/bar/.projects/busted-support-file/cypress/support/does/not/exist.jsx] +[/foo/bar/.projects/busted-support-file/cypress/support/does/not/exist.mjs] [/foo/bar/.projects/busted-support-file/cypress/support/does/not/exist.coffee] [/foo/bar/.projects/busted-support-file/cypress/support/does/not/exist.ts] [/foo/bar/.projects/busted-support-file/cypress/support/does/not/exist.tsx] diff --git a/packages/server/__snapshots__/7_record_spec.js b/packages/server/__snapshots__/7_record_spec.js index a9d38b4101fd..503a95df307a 100644 --- a/packages/server/__snapshots__/7_record_spec.js +++ b/packages/server/__snapshots__/7_record_spec.js @@ -34,6 +34,7 @@ Looked for and couldn't find the file at the following paths: [/foo/bar/.projects/e2e/cypress/it/does/not/exist.js] [/foo/bar/.projects/e2e/cypress/it/does/not/exist.json] [/foo/bar/.projects/e2e/cypress/it/does/not/exist.jsx] +[/foo/bar/.projects/e2e/cypress/it/does/not/exist.mjs] [/foo/bar/.projects/e2e/cypress/it/does/not/exist.coffee] [/foo/bar/.projects/e2e/cypress/it/does/not/exist.ts] [/foo/bar/.projects/e2e/cypress/it/does/not/exist.tsx] @@ -981,6 +982,7 @@ Looked for and couldn't find the file at the following paths: [/foo/bar/.projects/e2e/cypress/it/does/not/exist.js] [/foo/bar/.projects/e2e/cypress/it/does/not/exist.json] [/foo/bar/.projects/e2e/cypress/it/does/not/exist.jsx] +[/foo/bar/.projects/e2e/cypress/it/does/not/exist.mjs] [/foo/bar/.projects/e2e/cypress/it/does/not/exist.coffee] [/foo/bar/.projects/e2e/cypress/it/does/not/exist.ts] [/foo/bar/.projects/e2e/cypress/it/does/not/exist.tsx]