Closed Nasicus closed 2 years ago
In the meantime I tried to do the same (import styled from 'styled-components/macro'
) in a new CRA project with cypress component testing and there it works.
So it definitely only happens together with nx. (Not saying that I didn't configure anything wrong there, but still...).
I still have no idea to solve this btw.
I also tried updating all nrwl
and cypress
packages, but that didn't help.
I just had the same issue but for a node app after we upgraded to NX 13 and webpack 5. Before the upgrade all the tests did work. For me the failing libs are crypto
and stream
. Did someone find a workaround for this? Because we use the standard webpack config of NX, I suppose we do not have a way of configuring those fallback ourselves?
Hi, i have the same issue after updating NX 13 and angular 13.
Is anyone has found any solution to fix this ?
The problem is coming when i launch the nx serve cli
For anyone who wants to use Cypress component testing over a library, this is the webpack configuration I use. It requires Storybook configuration in your library because it leverages its webpack configuration:
const { startDevServer } = require('@cypress/webpack-dev-server')
const { webpack } = require('@nrwl/react/plugins/storybook/index')
const { getWebpackConfig } = require('@nrwl/cypress/plugins/preprocessor')
const { join } = require('path')
const project = require('../../project.json')
module.exports = async (on, config) => {
const cypressWebpack = getWebpackConfig(config)
const webpackConfig = await webpack(
{ ...cypressWebpack, mode: 'development' },
{
...project.targets.storybook.options,
configDir: join(__dirname, '../../.storybook'),
workspaceRoot: join(__dirname, '../../../../')
}
)
on('dev-server:start', (options) =>
startDevServer({ options, webpackConfig })
)
}
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! ๐
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
So after "some" research I managed to get nx together with Cypress component testing work.
This commit pretty much summarizes what I did to make it work (the template here was just a vanilla nx react webpack app).
However after that I tried to do the same in our real application (which is a "little" more complex), everything fails horribly ๐ .
I tried to make a minimal reproducible example with just one of the errors, because there are multiple, but I have hopes that if I solve one, the others will go away too.
As you can see in the commit above in the
app.spec.tsx
I describe, that this import line breaks it:I personally suspect it has something to do with the way cypress builds / serves the app. Something with babel seems to be missing. I'm not at all sure if this is my fault (maybe something in here?) or if there is a bug in nx or cypress.
Any help would be appreciated.
It basically will go from this:
To this.