Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix mjs file support #8395

Merged
merged 5 commits into from
Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion packages/server/__snapshots__/3_plugins_spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exports['e2e plugins passes with working preprocessor 1'] = `
exports['e2e plugins preprocessor passes with working preprocessor 1'] = `

====================================================================================================

Expand Down
2 changes: 2 additions & 0 deletions packages/server/__snapshots__/7_record_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
73 changes: 36 additions & 37 deletions packages/server/test/e2e/3_plugins_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,18 @@ 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
// failed and the right error is displayed
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 }) => {
Expand All @@ -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,
Expand All @@ -63,46 +40,46 @@ 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,
})
})

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,
})
})

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,
})
})

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,
})
})

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
Expand All @@ -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: {
Expand All @@ -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',
Expand All @@ -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,
Expand All @@ -172,16 +153,34 @@ 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',
})
})

// https://github.com/cypress-io/cypress/issues/8361
it('supports .mjs files', function () {
return e2e.exec(this, {
spec: 'mjs_spec.mjs',
})
})
})

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const imFromMjs = 'I am from .mjs :)'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { imFromMjs } from '../fixtures/mjs_file'

it('supports .mjs', () => {
expect(imFromMjs).to.equal('I am from .mjs :)')
})
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down