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

Dynamic require of is not supported when running a cypress test #304

Open
artipsingh opened this issue Jul 20, 2023 · 0 comments
Open

Dynamic require of is not supported when running a cypress test #304

artipsingh opened this issue Jul 20, 2023 · 0 comments

Comments

@artipsingh
Copy link

I am getting a message that Dynamic require of <> is not supported when I try to run a cypress test either from the command line or from the cypress GUI, not really sure what to do to fix this, I had been under the impression that putting the package in external: ['cypress-*'] would make esbuild ignore my package, but this does not appear to be the correct assumption.

Has anyone had this error before ?

My custom esbuild configurations in cypress/plugins/index.js

const bundler = createBundler({
      platform: 'node',
      format: 'iife',
      external: ['cypress-*'],
      packages: 'external',
  });
on('file:preprocessor', bundler);

node modules are :
"@bahmutov/cypress-esbuild-preprocessor": "2.2.0",
"esbuild": "0.17.19",

My error when I run a test with Cypress

The following error originated from your test code, not from Cypress.

Dynamic require of "cypress-file-upload" is not supported
When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
Cypress could not associate this error to any specific test.
We dynamically generated a new test to display this failure.

 at eval (https://<REDACTED>/__cypress/tests?p=cypress/support/e2e.js:27:11)
    at cypress/support/commands.js (<REDACTED>/__cypress/tests?p=cypress/support/e2e.js:40:36)
    at __init (https://<REDACTED>/__cypress/tests?p=cypress/support/e2e.js:30:58)
    at cypress/support/e2e.js (<REDACTED>/__cypress/tests?p=cypress/support/e2e.js:3453:7)
    at __require2 (https://<REDACTED>/__cypress/tests?p=cypress/support/e2e.js:33:52)
    at eval (<REDACTED>/__cypress/tests?p=cypress/support/e2e.js:3489:3)
    at eval (<REDACTED>/__cypress/tests?p=cypress/support/e2e.js:3490:3)
    at eval (<anonymous>)
From previous event:
    at evalScripts (<REDACTED>__cypress/runner/cypress_runner.js:168521:58)
    at <unknown> (<REDACTED>/__cypress/runner/cypress_runner.js:168530:152)
From previous event:
    at runScriptsFromUrls (https://<REDACTED>/__cypress/runner/cypress_runner.js:168530:136)
    at Object.runScripts (https://<REDACTED>/__cypress/runner/cypress_runner.js:168571:12)
    at $Cypress.onSpecWindow (https://<REDACTED>/__cypress/runner/cypress_runner.js:157151:75)

my cypress/support/e2e.js file

import './commands';
import 'cypress-axe';
import 'cypress-file-upload';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant