1

When I run all my component cypress tests locally on a Macbook pro on a react-vite project with around ~10 tests, I get the following error:

An uncaught error was detected outside of a test:
     TypeError: The following error originated from your test code, not from Cypress.

  > Failed to fetch dynamically imported module: http://localhost:5173/__cypress/src/cypress/support/component.ts

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.

the error is not Consistant and doesn't show up on every run. It also throws on a random test every run. How can I solve this?

update: I think a possible lead could be that I import files on my project with the absolute paths pattern. For example:

import {comp1, comp2} from 'components'

where as components is configured in my tsconfig.ts file

Matan Gubkin
  • 3,019
  • 6
  • 25
  • 44

1 Answers1

0

ok so after countless attempts to fix this and also encountering terminal freezes when I execute cypress run. I've gave up and created a bash script to run each of the tests in the code base separately:

set -x
#!/bin/bash

for file in $( find . -type f -name '*.spec.cy.tsx' );
    do yarn cypress run --component --browser chrome --spec $file || exit 1
done

for now it seems to get the job done. Hope this helps anyone else that encounters this

Matan Gubkin
  • 3,019
  • 6
  • 25
  • 44