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
Problems with migrating to 5.0 version due to issues with webpack configuration #8373
Comments
The first error looks like it's being thrown from Can you narrow down your example? Try removing some of the plugins to see if the errors still exist? Want to narrow down if it's an issue with one of the plugins or with Cypress. |
Well, originally at the beginning we had a different package complaining on the same reason. We have an api client that we have generated and added to our test framework. When we run tests, we get :
Error. I checked the changelog of cypress 5.0 and saw this :
I checked out project and googled a bit my error and saw that this is related to Webpack configuration. Since we didn't have Webpack before, i have added it like i specified in the description of the issues. After i applied this change i found that the same issue is still appearing, but now different package is complaining on this ( probably this package was first in order to get loaded, so Webpack failed earlier). To me it looks like there should be some specific webpack configuration added in order to properly load all the modules, but i'm strugling with this. So i was hoping that you could help. |
We'll need a smaller reproducible example - to track down exactly why the error is occuring in order to help. Can you provide what you're running now? |
What i'm running now is quite big and complex, but i will try to come up with something smaller. |
Ok, @jennifer-shehane i managed to reproduce the issue:
|
I'm seeing a similar issue here. Rolling back to v4.11.0 until this is resolved. |
@jennifer-shehane any chance you can check the example i have provided? |
@azakordonets I checked out the example and it seems like it can be fixed by changing the spec to the following: import SwaggerPetstore from 'swagger-petstore'
/// <reference types="cypress" />
describe('page', () => {
it('works', () => {
const pet = new SwaggerPetstore.PetApi();
cy.log(pet)
cy.visit('https://example.cypress.io')
})
}) |
@chrisbreiding thanks for the tip! It did actually solved the problem, but not all the problems i'm having unfortunately. At first with PetStore i was trying to simulate the easiest and simplest example to reproduce the error. However, in our project we have another generated api client, that has the same structure and setup as Petstore api client, but it doesn't want to work and I can't figure out why. I have pushed a new setup for the issue into https://github.com/azakordonets/cypress-test-tiny/tree/webpack-compiler-error-issue branch. I'm banging my head over and i can't figure out what is the difference and why Webpack is complaining about this. Maybe you could shed the light on it ? |
Looks like swagger-generated code and webpack don't play well together. They have a workaround in their documentation here. Here's how to implement it with Cypress. Install the necessary dependencies: npm i -D @cypress/webpack-preprocessor @cypress/webpack-batteries-included-preprocessor Add the following to const wp = require('@cypress/webpack-batteries-included-preprocessor')
module.exports = (on, config) => {
const options = wp.defaultOptions
options.webpackOptions.module.rules.push({
parser: { amd: false },
})
on('file:preprocessor', wp(options))
} I'll have to research whether or not it makes sense to bake this into Cypress or whether it will end up breaking projects that rely on webpack supporting AMD. |
Omg! @chrisbreiding you are the wizzard :) I still find Webpack a dark box of magic, but the fix you suggested did that trick and i don't see this Webpack compilation error anymore. Thanks a lot! |
Current behavior:
We are trying to migrate to Cypress 5.0 and having some issues with webpack compilation. Here's what we did:
plugins/index.js
When we run `$(yarn bin)/cypress open and run any of our tests, the browser crashes and in the debug log we see
error. Full log attached:
However, in the cypress itself we see this :
Desired behavior:
From what i understand, we need to setup webpack config in some way, but i can't figure out in which exactly way. Your help would be much appreciated
Versions
Operating system : Mac OS Catalina 10.15.6
Cypress version: 5.0
Our dependencies :
The text was updated successfully, but these errors were encountered: