40 Commits

Author SHA1 Message Date
Leosvel Pérez Espinosa
80e6edd707
fix(testing): use correct server process reference when killing the server in the cypress preset (#30994)
## Current Behavior

Cypress e2e tasks fail when trying to kill the web server with:

```bash
TypeError: Cannot read properties of undefined (reading 'childProcess')
    at /<repo path>/node_modules/@nx/cypress/plugins/cypress-preset.js:65:30
    ...
```

## Expected Behavior

Cypress e2e tasks should not fail when trying to kill the web server.

## Related Issue(s)

Fixes #
2025-05-02 10:43:03 +00:00
Jack Hsu
7b9add5582
fix(core): use process#kill instead of tree-kill for windows and macos (#30976)
Prefer `process#kill` instead of `tree-kill` for Mac and Windows. This
fixes an issue on Windows where the `taskkill` is unsuccessful.

## Current Behavior
Windows does not always run successfully

## Expected Behavior
Windows runs successfully

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2025-05-01 16:35:22 -04:00
Leosvel Pérez Espinosa
9a60dec0de feat(testing): support continuous tasks (#30632)
## Current Behavior

The Cypress and Playwright graph plugins do not infer tasks configured
to take advantage of continuous tasks (do not add the task they run to
start the app/server as a dependency of the e2e task).

## Expected Behavior

The Cypress and Playwright graph plugins should infer tasks configured
to take advantage of continuous tasks.

## Related Issue(s)

Fixes #
2025-04-15 09:23:45 -04:00
Jason Jean
c5fb467118 feat(core): share continuous tasks (#29901)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

<!-- This is the behavior we have today -->

<!-- This is the behavior we should expect with the changes in this PR
-->

<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #

---------

Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com>
2025-04-15 09:23:45 -04:00
Leosvel Pérez Espinosa
6af298d0a9
feat(testing): add support for the ts solution config setup to the cypress plugin (#28637)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2024-10-31 18:29:53 +01:00
MaxKless
499300fd76
fix(core): repair SIGINT signals on windows (#28496)
using `windowsHide: true` is causing an issue on windows: Ctrl + C
handling isn't enabled and no `SIGINT` is sent to the child process when
users exit the process. See https://github.com/nodejs/node/issues/29837
and https://github.com/nodejs/node-v0.x-archive/issues/5054 for
reference. This will cause leftover processes throughout nx.

This PR sets `windowsHide: false` everywhere except for the plugin
workers and some short-lived utils. They `spawn` child processes but
have explicit handling to make sure they kill themselves when the parent
process dies, so the missing Ctrl + C handling doesn't cause issues.

We will follow up to make sure any other culprits that still cause
windows popups (especially when used through Nx Console) are handled.
Leaving no leftover processes running is more important for now, though.

Keep in mind the underlying tooling (like vite) might have some windows
popups themselves that Nx will inherit.
2024-10-17 15:03:37 -04:00
MaxKless
b73f1e0e00
fix(core): set windowsHide: true wherever possible (#28073)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2024-09-24 11:31:22 -04:00
Colum Ferry
1dcfbeeeee
feat(testing): e2e-ci should use serve-static or vite preview for playwright and cypress (#27240)
- fix(vite): preview should dependOn build
- fix(react): playwright should use vite preview
- fix(vue): playwright should use vite preview
- fix(web): playwright should use vite preview
- chore(testing): add e2e test

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
Currently, `playwright` uses the `vite serve` command when setting up
the web server to run the e2e tests against.

The `vite preview` command/target should also depend on `vite build`.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
`playwright` should use the `vite preview` command when setting up the
web server

`vite preview` targets add a `dependsOn["build"]`

Ensure `serve-static` has a dependsOn: ['build']

Cypress should use the `ciBaseUrl` if it exists when running the
`e2e-ci` targets

Migrations for Playwright and Cypress to use serve-static and preview
correctly

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2024-08-02 11:56:07 -04:00
Leosvel Pérez Espinosa
c7e1a1681e
fix(testing): use taskkill to kill web server process when running cypress on windows (#27068)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #26599
2024-07-24 15:48:59 -04:00
Tim van den Eijnden
764eceed67
feat(testing): support vite configOverrides for cypress (#26554)
We'd like to use shared cypress commands, but that's currently not
working because vite cannot resolve the import.
By allowing to pass options to the vite config we have the possibility
to add an alias or a plugin to fix this.

This adds support for an **optional** `viteConfigOverrides` object.

## Current Behavior
![Screenshot 2024-06-14 at 15 19
21](https://github.com/nrwl/nx/assets/951290/78f5037f-c839-4227-a3ea-4de4142006cf)

cypress.config.ts:
```ts
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
import { defineConfig } from 'cypress';

export default defineConfig({
  e2e: {
    ...nxE2EPreset(__filename, { cypressDir: 'cypress', bundler: 'vite' }),
  },
});
```

## Expected Behavior
![Screenshot 2024-06-14 at 15 23
56](https://github.com/nrwl/nx/assets/951290/385cde67-91b9-462e-9bfa-0c784d3947b7)

cypress.config.ts:
```ts
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
import { defineConfig } from 'cypress';

const viteConfigOverrides = {
  resolve: {
    alias: {
      '@cypress-shared-commands': '../../../shared-cypress-commands',
    },
  },
};

export default defineConfig({
  e2e: {
    ...nxE2EPreset(__filename, { cypressDir: 'cypress', bundler: 'vite', viteConfigOverrides }),
  },
});
```
## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2024-07-22 12:51:17 -04:00
Nicholas Cunningham
49af691b24
fix(core): nxComponentTestingPreset should not expose bundler option (#23009) 2024-04-26 09:31:11 +01:00
Leosvel Pérez Espinosa
2d9ecfd1fc
fix(testing): close cypress web server correctly on windows (#22125) 2024-03-04 13:11:01 -05:00
Leosvel Pérez Espinosa
dee40997da
fix(testing): increase the default timeout to 60s for the cypress web dev server to start (#22132) 2024-03-04 15:38:04 +01:00
Leosvel Pérez Espinosa
2bcde03c01
fix(testing): calculate correct support file path in cypress e2e preset (#22096) 2024-03-01 14:40:09 +01:00
Remco Krams
c87884ad6e
fix(react): generate correctly when --js is used for module federation host/remote (#20119)
Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
2024-02-12 20:42:11 +00:00
Jason Jean
2fe4396e51
fix(testing): ensure cypress closes the web dev server (#21759) 2024-02-09 18:10:17 -05:00
Leosvel Pérez Espinosa
fdae86c81c
fix(testing): increase the default timeout to 15s for the dev server to start (#21716) 2024-02-09 15:51:18 +01:00
Craigory Coppola
ebbb2f0241
fix(testing): cleanup e2e atomization plugins (#21688) 2024-02-07 18:00:55 -05:00
Jason Jean
396ffc4636
feat(core): enable project crystal by default (#21403)
Co-authored-by: Katerina Skroumpelou <sk.katherine@gmail.com>
Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
Co-authored-by: Colum Ferry <cferry09@gmail.com>
Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com>
Co-authored-by: Emily Xiong <xiongemi@gmail.com>
Co-authored-by: Nicholas Cunningham <ndcunningham@gmail.com>
2024-02-02 03:40:59 -05:00
Remco Krams
e4b1ab6c61
fix(testing): fix config references to js files (#21018) 2024-01-31 18:45:48 +02:00
Craigory Coppola
d047ad5927
fix(testing): avoid overwriting environment variables in nx cypress preset (#20748) 2023-12-14 11:47:57 -05:00
Nicholas Cunningham
b8d24e6d0e
feat(nextjs): Add support for create nodes for nextjs (#20193) 2023-12-06 16:52:09 -07:00
Jason Jean
78ab39b895
feat(testing): allow cypress preset to execute a command for a web server (#20355) 2023-11-27 13:30:01 -05:00
Jason Jean
a916794318
fix(testing): update the cypress plugin implementation (#20314) 2023-11-21 08:57:58 -05:00
Jason Jean
a86d926612
feat(testing): add cypress create nodes plugin (#19840) 2023-11-09 14:05:19 -05:00
Eric Renken
e8b6034b6c
feat(nextjs): can set compiler when setting up nxComponentTestingPreset (#19171) 2023-11-03 17:11:42 +02:00
Caleb Ukle
193206ac86
feat(testing): support cypress v13 (#18899) 2023-09-01 11:55:13 -04:00
Caleb Ukle
f3f74068ea
fix(testing): update default webpack config for react CT (#17562) 2023-06-21 11:41:33 -04:00
Jason Jean
2d195007b0
feat(core): switch packages to use the @nx scope (#16069) 2023-04-14 19:56:37 -04:00
Caleb Ukle
78fb3b9a4f
feat(testing): add cypress-e2e-configuration generator (#15736) 2023-03-24 17:53:47 -04:00
Katerina Skroumpelou
1ef01f8ccc
feat(testing): cypress vite (#13474) 2022-12-15 04:28:53 +00:00
Jason Jean
2c819048bc
fix(angular): fix imports into nx from ng-add (#13645) 2022-12-05 21:05:26 +00:00
Jason Jean
6d35fd4d85
chore(core): reconcile functions to find project of a path (#13364) 2022-11-24 11:02:32 -05:00
Miroslav Jonaš
bd4f4a23c2
feat(core): use createProjectFileMappings in TargetProjectLocator (#13268) 2022-11-21 14:43:40 +01:00
Miroslav Jonaš
de44bf86b1
feat(core): optimize project graph file mapping (#13249) 2022-11-18 14:34:58 +01:00
Miroslav Jonaš
ab6f62a9b5
feat(core): move runtime-lint-utils to eslint plugin (#13222) 2022-11-18 12:24:53 +01:00
Caleb Ukle
1a9df531b6
fix(testing): normalize paths for component-testing (#11963)
* fix(testing): normalize paths before accessing the project graph

* fix(testing): return object with offset input instead of string

* fix(testing): update schemas to provide better prompts
2022-09-13 14:17:49 +00:00
Caleb Ukle
a0904a601b
feat(testing): support angular cypress component testing (#11790)
* feat(testing): ng cypress component testing

closes: #11602

* chore(testing): move story utils into common util area

* feat(testing): add options for ng component testing

* docs(testing): add more info for component testing

* chore(testing): address PR feedback

* chore(testing): remove logs
2022-09-07 13:32:19 +00:00
Caleb Ukle
c7249db386
fix(testing): handle more complex projects for react component testing (#11725)
* fix(testing): use @nrwl/web:webpack utils to generate a more robust webpack config

fixes: #11372

* fix(testing): do not overwrite existing component test

* fix(testing): add component-test to cacheable operations

* chore(testing): address pr feedback
2022-08-30 16:42:42 +00:00
Caleb Ukle
8154191eb1
feat(testing): Cypress 10 and component testing support (#9201)
* feat(testing): add generator to aid in the migration to cypress 10

cypress 10 introduces a new configuration format and new layout that requires update settings and
files for e2e projects

* feat(testing): cypress component tests for react/next

initial work for cypress component tests for react and next

* feat(testing): add support for v10 e2e cypress projects

create the correct files for cypress projects >v10 and reorganize tests based on version to allow
easier parsing of tests

* feat(testing): add utils for modifying cypress v10 config

provide ts transformers to take in an existing cypress config and update/add properties within the
given configuration

* fix(testing): fix tests affected by the cypress v10 changes

update tests to assert the correct files/folders/file contents due to the cypress changes in v10

* cleanup(testing): move cypress component testing plugins into the respective packages

move the plugins into out of cypress plugins into the specific vertical plugin to prevent issues
with circular refs

* cleanup(testing): bump cypress version

bump to latest cypress v10 release

* docs(testing): update docs for cypress 10

update cypress docs to include info about component testing and migration to cypress v10

* fix(repo): revert cypress version bump

keep v9 of cypress installed for nx repo until v10 release

* fix(testing): update cypress gen tsconfig and infer targets with converter

* fix(testing): make sure tests use the cypress v10 (for the intermediate)

* fix(testing): update target name after feedback

* fix(testing): support multiple target w/custom configs for cypress v10 migration

* fix(testing): refactor cy component tests into seperate verticals

* feat(testing): create storybook cypress preset

* fix(testing): clean up cy v10 migration

* fix(testing): don't branch for cypress executor testingType

* fix(testing): move cy comp test generator to next

* fix(testing): bump cypress deps

* fix(testing): clean up cy component testing generators

* fix(testing): update cy component testing docs

* fix(testign): dep check. runtime plugin pulls from @nrwl/react

* fix(testing): move e2e into verticals

* fix(testing): address PR feedback

* fix(testing): clean up unit tests

* feat(angular): support migrating angular cli workspaces using cypress v10

* chore(testing): update e2e tests

* fix(testing): address pr feedback

* chore(testing): remove cypress component testing for next.js

* fix(testing): address pr feedback

Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com>
2022-07-08 14:34:00 -05:00