Skip to content

Commit

Permalink
fix(breaking): exclude node_modules from cross-origin-callback-loader (
Browse files Browse the repository at this point in the history
…#24952)

* fix: exclude node_modules from cross-origin-callback-loader

* Update system-tests/test/cy_origin_error_spec.ts

Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>

* Update system-tests/projects/origin-dependencies/.gitignore

Co-authored-by: Ryan Manuel <ryanm@cypress.io>

Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
Co-authored-by: Matt Henkes <mjhenkes@gmail.com>
Co-authored-by: Ryan Manuel <ryanm@cypress.io>
  • Loading branch information
4 people committed Dec 2, 2022
1 parent a3d3074 commit 27c425d
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 2 deletions.
3 changes: 2 additions & 1 deletion npm/webpack-preprocessor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ const preprocessor: WebpackPreprocessor = (options: PreprocessorOptions = {}): F
})
.tap((opts) => {
if (opts.devtool === false) {
// disable any overrides if we've explictly turned off sourcemaps
// disable any overrides if we've explicitly turned off sourcemaps
overrideSourceMaps(false, options.typescript)

return
Expand All @@ -248,6 +248,7 @@ const preprocessor: WebpackPreprocessor = (options: PreprocessorOptions = {}): F
// so that it's working with plain javascript
webpackOptions.module.rules.unshift({
test: /\.(js|ts|jsx|tsx)$/,
exclude: /node_modules/,
use: [{
loader: require.resolve('@cypress/webpack-preprocessor/dist/lib/cross-origin-callback-loader.js'),
options: {
Expand Down
4 changes: 3 additions & 1 deletion packages/driver/src/cypress/error_messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,9 @@ export default {
Variables must either be defined within the ${cmd('origin')} command or passed in using the args option.
Using \`require()\` or \`import()\` to include dependencies requires enabling the \`experimentalOriginDependencies\` flag and using the latest version of \`@cypress/webpack-preprocessor\`.`,
Using \`require()\` or \`import()\` to include dependencies requires enabling the \`experimentalOriginDependencies\` flag and using the latest version of \`@cypress/webpack-preprocessor\`.
Note: Using \`require()\` or \`import()\` within ${cmd('origin')} from a \`node_modules\` plugin is not currently supported.`,
},
callback_mixes_sync_and_async: {
message: stripIndent`\
Expand Down
1 change: 1 addition & 0 deletions system-tests/projects/origin-dependencies/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!node_modules
5 changes: 5 additions & 0 deletions system-tests/projects/origin-dependencies/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
e2e: {
setupNodeEvents (on) {},
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
it('uses custom cy.origin command', () => {
cy.customOriginCommand()
})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'custom-origin-command'

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions system-tests/test/cy_origin_error_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,18 @@ describe('e2e cy.origin errors', () => {
expect(res.stdout).to.contain('Using `require()` or `import()` to include dependencies requires enabling the `experimentalOriginDependencies` flag and using the latest version of `@cypress/webpack-preprocessor`')
},
})

systemTests.it('errors when using a plugin that has a custom command that uses cy.origin with a dependency', {
browser: '!webkit', // TODO(webkit): cy.origin is not currently supported in webkit
project: 'origin-dependencies',
spec: 'cross_origin.cy.js',
expectedExitCode: 1,
config: commonConfig,
async onRun (exec) {
const res = await exec()

expect(res.stdout).to.contain('Using `require()` or `import()` to include dependencies requires enabling the `experimentalOriginDependencies` flag and using the latest version of `@cypress/webpack-preprocessor`')
expect(res.stdout).to.contain('Note: Using `require()` or `import()` within `cy.origin()` from a `node_modules` plugin is not currently supported.')
},
})
})

3 comments on commit 27c425d

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 27c425d Dec 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.0.0/linux-arm64/release/12.0.0-27c425dda318c316f751a000b77b39fe727999d5/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 27c425d Dec 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.0.0/linux-x64/release/12.0.0-27c425dda318c316f751a000b77b39fe727999d5/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 27c425d Dec 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.0.0/darwin-x64/release/12.0.0-27c425dda318c316f751a000b77b39fe727999d5/cypress.tgz

Please sign in to comment.