-
Notifications
You must be signed in to change notification settings - Fork 2.6k
chore(repo): split slow e2e tests - misc, run, workspace, and react c… #33009
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
Closed
Closed
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a4cbcde
chore(repo): split slow e2e tests - misc, run, workspace, and react c…
rarmatei 1186a72
Merge remote-tracking branch 'upstream/master' into split-remaining-s…
rarmatei 67583be
chore(repo): fix failing tests
rarmatei 0a77cdb
chore(repo): fix failing tests
rarmatei f5dd0df
chore(repo): merge upstream/master and resolve conflicts
rarmatei 0e424c8
chore(repo): integrate pnpm catalog test from upstream
rarmatei 4f63fa6
chore(repo): revert some test splits
rarmatei 785cc2b
chore(repo): fix failing test
rarmatei f13129d
chore(repo): inline test files again
rarmatei b595a5c
chore(repo): restore misc-rspack test files that were incorrectly merge
rarmatei cf62b6e
chore(repo): bust cache
rarmatei f467158
chore(repo): run conflicting tests serially
rarmatei bf05b82
chore(repo): run hungry tests serially
rarmatei 9ec289d
chore(repo): switch all e2e tests to run serially
rarmatei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { | ||
| cleanupProject, | ||
| newProject, | ||
| runCLI, | ||
| uniq, | ||
| updateFile, | ||
| } from '@nx/e2e-utils'; | ||
| import { join } from 'path'; | ||
|
|
||
| describe('cross-workspace implicit dependencies', () => { | ||
| beforeAll(() => | ||
| newProject({ | ||
| packages: ['@nx/js'], | ||
| }) | ||
| ); | ||
|
|
||
| afterAll(() => cleanupProject()); | ||
|
|
||
| it('should successfully build a project graph when cross-workspace implicit dependencies are present', () => { | ||
| const npmPackage = uniq('npm-package'); | ||
| runCLI(`generate @nx/workspace:npm-package ${npmPackage}`); | ||
|
|
||
| function setImplicitDependencies(deps: string[]) { | ||
| updateFile(join(npmPackage, 'package.json'), (content) => { | ||
| const json = JSON.parse(content); | ||
| json.nx = { | ||
| ...json.nx, | ||
| implicitDependencies: deps, | ||
| }; | ||
| return JSON.stringify(json, null, 2); | ||
| }); | ||
| } | ||
|
|
||
| // First set the implicit dependencies to an intentionally invalid value to prove the command fails during project graph construction | ||
| setImplicitDependencies(['this-project-does-not-exist']); | ||
| expect( | ||
| runCLI(`test ${npmPackage}`, { | ||
| silenceError: true, | ||
| }) | ||
| ).toContain('Failed to process project graph'); | ||
|
|
||
| // Now set the implicit dependencies to a cross-workspace reference to prove that it is valid, despite not being resolvable in the current workspace | ||
| setImplicitDependencies(['nx-cloud:another-workspace']); | ||
| expect( | ||
| runCLI(`test ${npmPackage}`, { | ||
| silenceError: true, | ||
| }) | ||
| ).toContain('Successfully ran target test'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| import { | ||
| cleanupProject, | ||
| isNotWindows, | ||
| runCLI, | ||
| runCLIAsync, | ||
| uniq, | ||
| updateFile, | ||
| } from '@nx/e2e-utils'; | ||
| import * as path from 'path'; | ||
| import { setupMiscTests } from './misc-setup'; | ||
|
|
||
| describe('Nx Commands - format', () => { | ||
| const myapp = uniq('myapp'); | ||
| const mylib = uniq('mylib'); | ||
|
|
||
| beforeAll(() => { | ||
| setupMiscTests(); | ||
| runCLI(`generate @nx/web:app apps/${myapp}`); | ||
| runCLI(`generate @nx/js:lib libs/${mylib}`); | ||
| }); | ||
|
|
||
| afterAll(() => cleanupProject()); | ||
|
|
||
| beforeEach(() => { | ||
| updateFile( | ||
| `apps/${myapp}/src/main.ts`, | ||
| ` | ||
| const x = 1111; | ||
| ` | ||
| ); | ||
|
|
||
| updateFile( | ||
| `apps/${myapp}/src/app/app.element.spec.ts`, | ||
| ` | ||
| const y = 1111; | ||
| ` | ||
| ); | ||
|
|
||
| updateFile( | ||
| `apps/${myapp}/src/app/app.element.ts`, | ||
| ` | ||
| const z = 1111; | ||
| ` | ||
| ); | ||
|
|
||
| updateFile( | ||
| `libs/${mylib}/index.ts`, | ||
| ` | ||
| const x = 1111; | ||
| ` | ||
| ); | ||
| updateFile( | ||
| `libs/${mylib}/src/${mylib}.spec.ts`, | ||
| ` | ||
| const y = 1111; | ||
| ` | ||
| ); | ||
|
|
||
| updateFile( | ||
| `README.md`, | ||
| ` | ||
| my new readme; | ||
| ` | ||
| ); | ||
| }); | ||
|
|
||
| it('should check libs and apps specific files', async () => { | ||
| if (isNotWindows()) { | ||
| const stdout = runCLI( | ||
| `format:check --files="libs/${mylib}/index.ts,package.json" --libs-and-apps`, | ||
| { silenceError: true } | ||
| ); | ||
| expect(stdout).toContain(path.normalize(`libs/${mylib}/index.ts`)); | ||
| expect(stdout).toContain( | ||
| path.normalize(`libs/${mylib}/src/${mylib}.spec.ts`) | ||
| ); | ||
| expect(stdout).not.toContain(path.normalize(`README.md`)); // It will be contained only in case of exception, that we fallback to all | ||
| } | ||
| }, 90000); | ||
|
|
||
| it('should check specific project', async () => { | ||
| if (isNotWindows()) { | ||
| const stdout = runCLI(`format:check --projects=${myapp}`, { | ||
| silenceError: true, | ||
| }); | ||
| expect(stdout).toContain(path.normalize(`apps/${myapp}/src/main.ts`)); | ||
| expect(stdout).toContain( | ||
| path.normalize(`apps/${myapp}/src/app/app.element.ts`) | ||
| ); | ||
| expect(stdout).toContain( | ||
| path.normalize(`apps/${myapp}/src/app/app.element.spec.ts`) | ||
| ); | ||
| expect(stdout).not.toContain(path.normalize(`libs/${mylib}/index.ts`)); | ||
| expect(stdout).not.toContain( | ||
| path.normalize(`libs/${mylib}/src/${mylib}.spec.ts`) | ||
| ); | ||
| expect(stdout).not.toContain(path.normalize(`README.md`)); | ||
| } | ||
| }, 90000); | ||
|
|
||
| it('should check multiple projects', async () => { | ||
| if (isNotWindows()) { | ||
| const stdout = runCLI(`format:check --projects=${myapp},${mylib}`, { | ||
| silenceError: true, | ||
| }); | ||
| expect(stdout).toContain(path.normalize(`apps/${myapp}/src/main.ts`)); | ||
| expect(stdout).toContain( | ||
| path.normalize(`apps/${myapp}/src/app/app.element.spec.ts`) | ||
| ); | ||
| expect(stdout).toContain( | ||
| path.normalize(`apps/${myapp}/src/app/app.element.ts`) | ||
| ); | ||
| expect(stdout).toContain(path.normalize(`libs/${mylib}/index.ts`)); | ||
| expect(stdout).toContain( | ||
| path.normalize(`libs/${mylib}/src/${mylib}.spec.ts`) | ||
| ); | ||
| expect(stdout).not.toContain(path.normalize(`README.md`)); | ||
| } | ||
| }, 90000); | ||
|
|
||
| it('should check all', async () => { | ||
| if (isNotWindows()) { | ||
| const stdout = runCLI(`format:check --all`, { silenceError: true }); | ||
| expect(stdout).toContain(path.normalize(`apps/${myapp}/src/main.ts`)); | ||
| expect(stdout).toContain( | ||
| path.normalize(`apps/${myapp}/src/app/app.element.spec.ts`) | ||
| ); | ||
| expect(stdout).toContain( | ||
| path.normalize(`apps/${myapp}/src/app/app.element.ts`) | ||
| ); | ||
| expect(stdout).toContain(path.normalize(`libs/${mylib}/index.ts`)); | ||
| expect(stdout).toContain( | ||
| path.normalize(`libs/${mylib}/src/${mylib}.spec.ts`) | ||
| ); | ||
| expect(stdout).toContain(path.normalize(`README.md`)); | ||
| } | ||
| }, 90000); | ||
|
|
||
| it('should throw error if passing both projects and --all param', async () => { | ||
| if (isNotWindows()) { | ||
| const { stderr } = await runCLIAsync( | ||
| `format:check --projects=${myapp},${mylib} --all`, | ||
| { | ||
| silenceError: true, | ||
| } | ||
| ); | ||
| expect(stderr).toContain( | ||
| 'Arguments all and projects are mutually exclusive' | ||
| ); | ||
| } | ||
| }, 90000); | ||
|
|
||
| it('should reformat the code', async () => { | ||
| if (isNotWindows()) { | ||
| runCLI( | ||
| `format:write --files="apps/${myapp}/src/app/app.element.spec.ts,apps/${myapp}/src/app/app.element.ts"` | ||
| ); | ||
| const stdout = runCLI('format:check --all', { silenceError: true }); | ||
| expect(stdout).toContain(path.normalize(`apps/${myapp}/src/main.ts`)); | ||
| expect(stdout).not.toContain( | ||
| path.normalize(`apps/${myapp}/src/app/app.element.spec.ts`) | ||
| ); | ||
| expect(stdout).not.toContain( | ||
| path.normalize(`apps/${myapp}/src/app/app.element.ts`) | ||
| ); | ||
|
|
||
| runCLI('format:write --all'); | ||
| expect(runCLI('format:check --all')).not.toContain( | ||
| path.normalize(`apps/${myapp}/src/main.ts`) | ||
| ); | ||
| } | ||
| }, 300000); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| import { | ||
| createNonNxProjectDirectory, | ||
| e2eCwd, | ||
| getPackageManagerCommand, | ||
| getPublishedVersion, | ||
| newProject, | ||
| readFile, | ||
| readJson, | ||
| runCommand, | ||
| updateFile, | ||
| updateJson, | ||
| } from '@nx/e2e-utils'; | ||
| import { ensureDirSync, writeFileSync } from 'fs-extra'; | ||
| import * as path from 'path'; | ||
| import { major } from 'semver'; | ||
|
|
||
| describe('global installation', () => { | ||
| // Additionally, installing Nx under e2eCwd like this still acts like a global install, | ||
| // but is easier to cleanup and doesn't mess with the users PC if running tests locally. | ||
| const globalsPath = path.join(e2eCwd, 'globals', 'node_modules', '.bin'); | ||
|
|
||
| let oldPath: string; | ||
|
|
||
| beforeAll(() => { | ||
| ensureDirSync(globalsPath); | ||
| writeFileSync( | ||
| path.join(path.dirname(path.dirname(globalsPath)), 'package.json'), | ||
| JSON.stringify( | ||
| { | ||
| dependencies: { | ||
| nx: getPublishedVersion(), | ||
| }, | ||
| }, | ||
| null, | ||
| 2 | ||
| ) | ||
| ); | ||
|
|
||
| runCommand(getPackageManagerCommand().install, { | ||
| cwd: path.join(e2eCwd, 'globals'), | ||
| }); | ||
|
|
||
| // Update process.path to have access to modules installed in e2ecwd/node_modules/.bin, | ||
| // this lets commands run things like `nx`. We put it at the beginning so they are found first. | ||
| oldPath = process.env.PATH; | ||
| process.env.PATH = globalsPath + path.delimiter + process.env.PATH; | ||
| }); | ||
|
|
||
| afterAll(() => { | ||
| process.env.PATH = oldPath; | ||
| }); | ||
|
|
||
| describe('inside nx directory', () => { | ||
| beforeAll(() => { | ||
| newProject(); | ||
| }); | ||
|
|
||
| it('should invoke Nx commands from local repo', () => { | ||
| const nxJsContents = readFile('node_modules/nx/bin/nx.js'); | ||
| updateFile('node_modules/nx/bin/nx.js', `console.log('local install');`); | ||
| let output: string; | ||
| expect(() => { | ||
| output = runCommand(`nx show projects`); | ||
| }).not.toThrow(); | ||
| expect(output).toContain('local install'); | ||
| updateFile('node_modules/nx/bin/nx.js', nxJsContents); | ||
| }); | ||
|
|
||
| it('should warn if local Nx has higher major version', () => { | ||
| const packageJsonContents = readFile('node_modules/nx/package.json'); | ||
| updateJson('node_modules/nx/package.json', (json) => { | ||
| json.version = `${major(getPublishedVersion()) + 2}.0.0`; | ||
| return json; | ||
| }); | ||
| let output: string; | ||
| expect(() => { | ||
| output = runCommand(`nx show projects`); | ||
| }).not.toThrow(); | ||
| expect(output).toContain(`It's time to update Nx`); | ||
| updateFile('node_modules/nx/package.json', packageJsonContents); | ||
| }); | ||
|
|
||
| it('--version should display global installs version', () => { | ||
| const packageJsonContents = readFile('node_modules/nx/package.json'); | ||
| const localVersion = `${major(getPublishedVersion()) + 2}.0.0`; | ||
| updateJson('node_modules/nx/package.json', (json) => { | ||
| json.version = localVersion; | ||
| return json; | ||
| }); | ||
| let output: string; | ||
| expect(() => { | ||
| output = runCommand(`nx --version`); | ||
| }).not.toThrow(); | ||
| expect(output).toContain(`- Local: v${localVersion}`); | ||
| expect(output).toContain(`- Global: v${getPublishedVersion()}`); | ||
| updateFile('node_modules/nx/package.json', packageJsonContents); | ||
| }); | ||
|
|
||
| it('report should display global installs version', () => { | ||
| const packageJsonContents = readFile('node_modules/nx/package.json'); | ||
| const localVersion = `${major(getPublishedVersion()) + 2}.0.0`; | ||
| updateJson('node_modules/nx/package.json', (json) => { | ||
| json.version = localVersion; | ||
| return json; | ||
| }); | ||
| let output: string; | ||
| expect(() => { | ||
| output = runCommand(`nx report`); | ||
| }).not.toThrow(); | ||
| expect(output).toEqual( | ||
| expect.stringMatching(new RegExp(`nx.*:.*${localVersion}`)) | ||
| ); | ||
| expect(output).toEqual( | ||
| expect.stringMatching( | ||
| new RegExp(`nx \\(global\\).*:.*${getPublishedVersion()}`) | ||
| ) | ||
| ); | ||
| updateFile('node_modules/nx/package.json', packageJsonContents); | ||
| }); | ||
| }); | ||
|
|
||
| describe('non-nx directory', () => { | ||
| beforeAll(() => { | ||
| createNonNxProjectDirectory(); | ||
| }); | ||
|
|
||
| it('--version should report global version and local not found', () => { | ||
| let output: string; | ||
| expect(() => { | ||
| output = runCommand(`nx --version`); | ||
| }).not.toThrow(); | ||
| expect(output).toContain(`- Local: Not found`); | ||
| expect(output).toContain(`- Global: v${getPublishedVersion()}`); | ||
| }); | ||
|
|
||
| it('graph should work in npm workspaces repo', () => { | ||
| expect(() => { | ||
| runCommand(`nx graph --file graph.json`); | ||
| }).not.toThrow(); | ||
| const { graph } = readJson('graph.json'); | ||
| expect(graph).toHaveProperty('nodes'); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There's a duplicate entry for 'e2e-cimodule-federation/misc-rspack-interoperability' on lines 42 and 45. One of these entries should be removed to avoid running the same test twice.
Spotted by Graphite Agent

Is this helpful? React 👍 or 👎 to let us know.