-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
feat: support custom workspaceRoot for angular CT #26030
feat: support custom workspaceRoot for angular CT #26030
Conversation
27 flaky tests on run #44554 ↗︎
Details:
commands/net_stubbing.cy.ts • 1 flaky test • 5x-driver-firefox
cypress/cypress.cy.js • 3 flaky tests • 5x-driver-firefox
cypress/cypress.cy.js • 3 flaky tests • 5x-driver-electron
create-from-component.cy.ts • 1 flaky test • app-e2e
specs_list_latest_runs.cy.ts • 1 flaky test • app-e2e
The first 5 flaky specs are shown, see all 14 specs in Cypress Cloud. This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. |
I think this looks good to me @barbados-clemens. The only thing I think we need to add are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - I want to try to add a few Nx system tests first though before merging
Looks like the nx test is failing. Once this is passing, we can merge it up. Are you interested in picking this one up @jordanpowell88 to help get over the line? We've also got another issue filed for adding more robust Nx infra to the monorepo. |
@jordanpowell88 Are you looking at the nx failure on this one? |
@mike-plummer It's blocked until we do this issue: #26045 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just one stylistic comment
@@ -253,7 +254,7 @@ async function getAngularCliWebpackConfig (devServerConfig: AngularWebpackDevSer | |||
|
|||
const buildOptions = getAngularBuildOptions(projectConfig.buildOptions, tsConfig) | |||
|
|||
const context = createFakeContext(projectRoot, projectConfig, logging) | |||
const context = createFakeContext(projectConfig.buildOptions.workspaceRoot || projectRoot, projectConfig, logging) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this just use the buildOptions
output from getAngularBuildOptions
above (same on line 279)? Slightly cleaner, perhaps
440bfd1
to
c7a7c37
Compare
Nx issue for ref: nrwl/nx#12113
Additional details
This is the same implementation as #25384 but to solve a different issue, primarly the issue where Nx + Cypress Angular CT is unable to load the workspace root tailwinds config file. This logic is hard coded within angular webpack utils that cypress CT calls.
The Angular CT handler sets the projectRoot as the workspaceRoot when working with the angular webpack utils which works when cypress is opened in the root of the workspace. But within an nx context Cypress is opened in the project root which means any tailwind config files in the workspace root aren't loaded.
This PR allows for an optional workspaceRoot option to be passed via the cypress config component testing project configuration. if one isn't provided then the default value of projectRoot is used to prevent any other integration/assumptions from breaking but allowing the customizations for tools like Nx to provide the expected behavior when the Cypress isn't opened in the workspaceRoot.
Steps to test
This change does requires changes to the @nrwl/angular nx component testing preset. Mainly the offset value is removed and a custom 'workspaceRoot' is passed to cypress. This can be done within node_modules if really wanted to test it works before this change is in Nx, See: nrwl/nx#15485
make a new nx angular workspace, npx create-nx-workspace@latest --preset=angular
add an tailwind to the workspace root
use a tailwind class in the apps create 'apps//src/app.component.html'
add CT to the app
nx g @nrwl/angular:cypress-component-configuration --project=<app-name>
run CT and notice the tailwind styles are not applied,
nx component-test <app-name> --watch
cloneable repo: https://github.com/kanidjar/nx-cypress-ct-styling-bug
How has the user experience changed?
No impact for direct consumers, more flexibility for 3rd party tools like Nx
PR Tasks
cypress-documentation
?type definitions
?