[Component Testing] New test code is not being bundled using NextJS 11.1 and Webpack 5
See original GitHub issueCurrent behavior
When creating a new *.spec.{tsx, jsx}
file in the specified component folder, these tests cannot be run.
Similarly, if you delete a spec file the compiler will complain that the file {file}.spec.tsx
cannot be found.
The only work around I’ve found is to manually delete the .next folder so that it actually bundles the code when I run cypress open-ct
.
Desired behavior
No response
Test code to reproduce
- clone https://github.com/drj17/cypress-component-test-bug
- run
yarn install && yarn cypress open-ct
- Duplicate existing
cypress/pages/index.spec.jsx
file - Try to run it, see “No tests found error”
- Delete
.next
folder, re-runyarn cypress open-ct
, tests now show show up.
Cypress Version
8.3.1
Other
package.json
{
"name": "cypress-test",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"next": "11.1.0",
"react": "17.0.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"@cypress/react": "^5.9.4",
"@cypress/webpack-dev-server": "^1.4.0",
"@types/react": "^17.0.19",
"cypress": "^8.3.1",
"eslint": "7.32.0",
"eslint-config-next": "11.1.0",
"html-webpack-plugin": "5",
"webpack": "5",
"webpack-dev-server": "3"
}
}
plugins/index.js
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
/**
* @type {Cypress.PluginConfig}
*/
// eslint-disable-next-line no-unused-vars
const injectDevServer = require("@cypress/react/plugins/next");
module.exports = (on, config) => {
injectDevServer(on, config);
return config;
};
cypress.json:
{
"testFiles": "**/*.spec.jsx",
"componentFolder": "cypress/pages"
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Blog - Next.js 11
Next.js 11 continues our mission to create the best developer experience with a new conformance system and performance improvements.
Read more >Changelog
Fixed an issue with Angular Component Testing where urls within SASS/SCSS files were not being correctly resolved which could result in incomplete styling....
Read more >How to fix "FATAL ERROR: Ineffective mark-compacts near ...
That problem is related with large files in your project. I'm using create-react-app, and I got that error, after doing some search, ...
Read more >How to keep your Lighthouse score high in Next.js ...
Let's talk about one of the most useful technical SEO performance tools that can be used to test web pages. It's automated, and...
Read more >Migrating from nextjs 10 to 11 @smallcase
Webpack 5 : With next.js 11, webpack 5 is now enabled by default which ... the appropriate CSS was not getting applied to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It does seem related, but in my case it only was fixed when I deleted the .next folder
This was released as @cypress/webpack-dev-server-v1.8.1 on 2022-02-08.