cypress
cypress copied to clipboard
Could not detect tests when including 'splitChunks: all' in webpack.config.js
Current behavior
When Im using @cypress/webpack-preprocessor to preprosess the webpack.config.js file and include the option: splitChunks: all Cypress response with the message "Cypress could not detect tests in this file." after I run a basic test. The error only happens with splitChunks: all not splitChunks: async

Desired behavior
No response
Test code to reproduce
cypress/plugins/index.js
const webpackPreprocessor = require('@cypress/webpack-preprocessor')
module.exports = (on) => {
const options = {
webpackOptions: require('../../webpack.config'),
watchOptions: {},
}
on('file:preprocessor', webpackPreprocessor(options))
}
root/webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: [/node_modules/],
use: [{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
}],
},
],
},
optimization: {
splitChunks: {
chunks: 'all'
}
},
}
cypress/integration/detail.spec.js:
/// <reference types="Cypress" />
describe("Test detail page", () => {
before(() => {
cy.visit("/")
})
it("Should open hamburger menu and select detail page", () => {
cy.react('HamburgerMenu').should('exist');
cy.get('.hamburgerMenu_root-3yVlk > .MuiButtonBase-root').click();
})
})
Cypress Version
9.0.0
Other
No response
Hm, I'm not able to reproduce, which doesn't mean it's not a real issue, just that here's more going on in your project than in my sample one.
Here's the project I spun up to test it out: split-chunks.zip using the exact plugins file and webpack config you provided - it recognizes the test as expected, regardless of splitChunks setting.
Related to preprocessor + integration tests, not dev-server.
I'm seeing a similar issue. When chunks: 'initial' or chunks: 'all' is set then Cypress can't find any of the custom cy commands like cy.login. It looks like cy.react in the example code above is also a custom command and this may be breaking it.
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.
This issue has been closed due to inactivity.