-1

I'm running cypress on docker using docker run command. I got the following error:

Oops...we found an error preparing this test file:                                                                                                                                  
                                                                                                                                                                                    
  > cypress/support/commands.js                                                                                                                                                     
                                                                                                                                                                                    
The error was:                                                                                                                                                                      
                                                                                                                                                                                    
Error: Webpack Compilation Error                                                                                                                                                    
./cypress/support/commands.js                                                                                                                                                       
Module not found: Error: Can't resolve 'cypress-iframe' in '/e2e/cypress/support'                                                                                                   
resolve 'cypress-iframe' in '/e2e/cypress/support'                                                                                                                                  
  Parsed request is a module                                                                                                                                                        
  using description file: /e2e/package.json (relative path: ./cypress/support)                                                                                                      
    Field 'browser' doesn't contain a valid alias configuration                                                                                                                     
    Looked for and couldn't find the file at the following paths: or is not a directory                                                                                             
[/e2e/cypress/support/node_modules]                                                                                                                                                 
[/e2e/cypress/node_modules]                                                                                                                                                         
[/e2e/node_modules]                                                                                                                                                                 
[/node_modules]                                                                                                                                                                     
 @ ./cypress/support/commands.js 5:0-25  

I will be grateful for help, thanks

Seura
  • 35
  • 6
  • 1
    What does your `cypress/support/commands.js` file look like? Have you installed `cypress-iframe` using npm? – agoff Nov 09 '22 at 14:27
  • I haven't installed cypress-iframe.Should i install it on the server or inside the docker container? I'm using docker run -it -v $PWD:/e2e -w /e2e cypress/included:10.11.0 run command to run cypress. – Seura Nov 10 '22 at 10:02
  • You should add it to your `package.json` file, and when building (or starting) the container, you should add a step to run `npm install`. This is commonplace setup for docker containers using node (not just ones for Cypress) – agoff Nov 10 '22 at 14:33

1 Answers1

1

If you installed cypress-iframe you should simply:

In your cypress/support/commands.js file, add the following:

import 'cypress-iframe';
// or
require('cypress-iframe');

Amit Kahlon
  • 108
  • 1
  • 1
  • 10