-
Notifications
You must be signed in to change notification settings - Fork 2.6k
chore(repo): split slow e2e tests - web, webpack, and workspace-create #33011
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
Draft
rarmatei
wants to merge
14
commits into
master
Choose a base branch
from
split-remaining-slow-e2e-2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,677
−1,334
Draft
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4ada933
chore(repo): split slow e2e tests - web, webpack, and workspace-create
rarmatei 979802a
Merge remote-tracking branch 'upstream/master' into split-remaining-s…
rarmatei e53e9e8
fix: format import statements in new e2e test files
nx-cloud[bot] f705974
chore(repo): fix failing tests
rarmatei c1ec8a1
chore(repo): fix failing tests
rarmatei d1e4fa4
chore(repo): format files
rarmatei 258a181
Merge branch 'master' into split-remaining-slow-e2e-2
rarmatei 02b9a15
chore(repo): setup all packages in webpack tests
rarmatei 18553f6
chore(repo): bust cache
rarmatei a63df81
chore(repo): run conflicting tests serially
rarmatei 866f0e2
chore(repo): run conflicting tests serially
rarmatei 0613153
chore(repo): run conflicting tests serially
rarmatei 42d74d5
Merge remote-tracking branch 'upstream/master' into split-remaining-s…
rarmatei cbf5d75
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,84 @@ | ||
import { readFile, runCLI, uniq, updateFile } from '@nx/e2e-utils'; | ||
import { setupWebTest } from './web-setup'; | ||
|
||
describe('Web Components Applications', () => { | ||
setupWebTest(); | ||
|
||
it('should emit decorator metadata when --compiler=babel and it is enabled in tsconfig', async () => { | ||
const appName = uniq('app'); | ||
runCLI( | ||
`generate @nx/web:app apps/${appName} --bundler=webpack --compiler=babel --no-interactive --unitTestRunner=vitest --linter=eslint` | ||
); | ||
|
||
updateFile(`apps/${appName}/src/app/app.element.ts`, (content) => { | ||
const newContent = `${content} | ||
function enumerable(value: boolean) { | ||
return function ( | ||
target: any, | ||
propertyKey: string, | ||
descriptor: PropertyDescriptor | ||
) { | ||
descriptor.enumerable = value; | ||
}; | ||
} | ||
function sealed(target: any) { | ||
return target; | ||
} | ||
|
||
@sealed | ||
class Foo { | ||
@enumerable(false) bar() {} | ||
} | ||
`; | ||
return newContent; | ||
}); | ||
|
||
updateFile(`apps/${appName}/src/app/app.element.ts`, (content) => { | ||
const newContent = `${content} | ||
// bust babel and nx cache | ||
`; | ||
return newContent; | ||
}); | ||
setPluginOption( | ||
`apps/${appName}/webpack.config.js`, | ||
'outputHashing', | ||
'none' | ||
); | ||
runCLI(`build ${appName}`); | ||
|
||
expect(readFile(`dist/apps/${appName}/main.js`)).toMatch( | ||
/Reflect\.metadata/ | ||
); | ||
|
||
// Turn off decorator metadata | ||
updateFile(`apps/${appName}/tsconfig.app.json`, (content) => { | ||
const json = JSON.parse(content); | ||
json.compilerOptions.emitDecoratorMetadata = false; | ||
return JSON.stringify(json); | ||
}); | ||
|
||
setPluginOption( | ||
`apps/${appName}/webpack.config.js`, | ||
'outputHashing', | ||
'none' | ||
); | ||
runCLI(`build ${appName}`); | ||
|
||
expect(readFile(`dist/apps/${appName}/main.js`)).not.toMatch( | ||
/Reflect\.metadata/ | ||
); | ||
}, 120000); | ||
}); | ||
|
||
function setPluginOption( | ||
webpackConfigPath: string, | ||
option: string, | ||
value: string | boolean | ||
): void { | ||
updateFile(webpackConfigPath, (content) => { | ||
return content.replace( | ||
new RegExp(`${option}: .+`), | ||
`${option}: ${typeof value === 'string' ? `'${value}'` : value},` | ||
); | ||
}); | ||
} |
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,66 @@ | ||
import { readFile, runCLI, uniq, updateFile } from '@nx/e2e-utils'; | ||
import { setupWebTest } from './web-setup'; | ||
|
||
describe('Web Components Applications', () => { | ||
setupWebTest(); | ||
|
||
it('should emit decorator metadata when using --compiler=swc', async () => { | ||
const appName = uniq('app'); | ||
runCLI( | ||
`generate @nx/web:app apps/${appName} --bundler=webpack --compiler=swc --no-interactive --unitTestRunner=vitest --linter=eslint` | ||
); | ||
|
||
updateFile(`apps/${appName}/src/app/app.element.ts`, (content) => { | ||
const newContent = `${content} | ||
function enumerable(value: boolean) { | ||
return function ( | ||
target: any, | ||
propertyKey: string, | ||
descriptor: PropertyDescriptor | ||
) { | ||
descriptor.enumerable = value; | ||
}; | ||
} | ||
function sealed(target: any) { | ||
return target; | ||
} | ||
|
||
@sealed | ||
class Foo { | ||
@enumerable(false) bar() {} | ||
} | ||
`; | ||
return newContent; | ||
}); | ||
|
||
updateFile(`apps/${appName}/src/app/app.element.ts`, (content) => { | ||
const newContent = `${content} | ||
// bust babel and nx cache | ||
`; | ||
return newContent; | ||
}); | ||
setPluginOption( | ||
`apps/${appName}/webpack.config.js`, | ||
'outputHashing', | ||
'none' | ||
); | ||
runCLI(`build ${appName}`); | ||
|
||
expect(readFile(`dist/apps/${appName}/main.js`)).toMatch( | ||
/Foo=.*?_decorate/ | ||
); | ||
}, 120000); | ||
}); | ||
|
||
function setPluginOption( | ||
webpackConfigPath: string, | ||
option: string, | ||
value: string | boolean | ||
): void { | ||
updateFile(webpackConfigPath, (content) => { | ||
return content.replace( | ||
new RegExp(`${option}: .+`), | ||
`${option}: ${typeof value === 'string' ? `'${value}'` : value},` | ||
); | ||
}); | ||
} |
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,125 @@ | ||
import { | ||
cleanupProject, | ||
newProject, | ||
readFile, | ||
runCLI, | ||
uniq, | ||
updateFile, | ||
} from '@nx/e2e-utils'; | ||
|
||
describe('CLI - Environment Variables', () => { | ||
it('should automatically load workspace and per-project environment variables', async () => { | ||
newProject(); | ||
|
||
const appName = uniq('app'); | ||
//test if the Nx CLI loads root .env vars | ||
updateFile( | ||
`.env`, | ||
'NX_PUBLIC_WS_BASE=ws-base\nNX_PUBLIC_SHARED_ENV=shared-in-workspace-base' | ||
); | ||
updateFile( | ||
`.env.local`, | ||
'NX_PUBLIC_WS_ENV_LOCAL=ws-env-local\nNX_PUBLIC_SHARED_ENV=shared-in-workspace-env-local' | ||
); | ||
updateFile( | ||
`.local.env`, | ||
'NX_PUBLIC_WS_LOCAL_ENV=ws-local-env\nNX_PUBLIC_SHARED_ENV=shared-in-workspace-local-env' | ||
); | ||
updateFile( | ||
`apps/${appName}/.env`, | ||
'NX_PUBLIC_APP_BASE=app-base\nNX_PUBLIC_SHARED_ENV=shared-in-app-base' | ||
); | ||
updateFile( | ||
`apps/${appName}/.env.local`, | ||
'NX_PUBLIC_APP_ENV_LOCAL=app-env-local\nNX_PUBLIC_SHARED_ENV=shared-in-app-env-local' | ||
); | ||
updateFile( | ||
`apps/${appName}/.local.env`, | ||
'NX_PUBLIC_APP_LOCAL_ENV=app-local-env\nNX_PUBLIC_SHARED_ENV=shared-in-app-local-env' | ||
); | ||
const main = `apps/${appName}/src/main.ts`; | ||
const newCode = ` | ||
const envVars = [process.env.NODE_ENV, process.env.NX_PUBLIC_WS_BASE, process.env.NX_PUBLIC_WS_ENV_LOCAL, process.env.NX_PUBLIC_WS_LOCAL_ENV, process.env.NX_PUBLIC_APP_BASE, process.env.NX_PUBLIC_APP_ENV_LOCAL, process.env.NX_PUBLIC_APP_LOCAL_ENV, process.env.NX_PUBLIC_SHARED_ENV]; | ||
const nodeEnv = process.env.NODE_ENV; | ||
const nxWsBase = process.env.NX_PUBLIC_WS_BASE; | ||
const nxWsEnvLocal = process.env.NX_PUBLIC_WS_ENV_LOCAL; | ||
const nxWsLocalEnv = process.env.NX_PUBLIC_WS_LOCAL_ENV; | ||
const nxAppBase = process.env.NX_PUBLIC_APP_BASE; | ||
const nxAppEnvLocal = process.env.NX_PUBLIC_APP_ENV_LOCAL; | ||
const nxAppLocalEnv = process.env.NX_PUBLIC_APP_LOCAL_ENV; | ||
const nxSharedEnv = process.env.NX_PUBLIC_SHARED_ENV; | ||
`; | ||
|
||
runCLI( | ||
`generate @nx/web:app apps/${appName} --bundler=webpack --no-interactive --compiler=babel --unitTestRunner=vitest --linter=eslint` | ||
); | ||
|
||
const content = readFile(main); | ||
|
||
updateFile(main, `${newCode}\n${content}`); | ||
|
||
const appName2 = uniq('app'); | ||
|
||
updateFile( | ||
`apps/${appName2}/.env`, | ||
'NX_PUBLIC_APP_BASE=app2-base\nNX_PUBLIC_SHARED_ENV=shared2-in-app-base' | ||
); | ||
updateFile( | ||
`apps/${appName2}/.env.local`, | ||
'NX_PUBLIC_APP_ENV_LOCAL=app2-env-local\nNX_PUBLIC_SHARED_ENV=shared2-in-app-env-local' | ||
); | ||
updateFile( | ||
`apps/${appName2}/.local.env`, | ||
'NX_PUBLIC_APP_LOCAL_ENV=app2-local-env\nNX_PUBLIC_SHARED_ENV=shared2-in-app-local-env' | ||
); | ||
const main2 = `apps/${appName2}/src/main.ts`; | ||
const newCode2 = `const envVars = [process.env.NODE_ENV, process.env.NX_PUBLIC_WS_BASE, process.env.NX_PUBLIC_WS_ENV_LOCAL, process.env.NX_PUBLIC_WS_LOCAL_ENV, process.env.NX_PUBLIC_APP_BASE, process.env.NX_PUBLIC_APP_ENV_LOCAL, process.env.NX_PUBLIC_APP_LOCAL_ENV, process.env.NX_PUBLIC_SHARED_ENV];`; | ||
|
||
runCLI( | ||
`generate @nx/web:app apps/${appName2} --bundler=webpack --no-interactive --compiler=babel --unitTestRunner=vitest --linter=eslint` | ||
); | ||
|
||
const content2 = readFile(main2); | ||
|
||
updateFile(main2, `${newCode2}\n${content2}`); | ||
|
||
setPluginOption( | ||
`apps/${appName}/webpack.config.js`, | ||
'outputHashing', | ||
'none' | ||
); | ||
setPluginOption(`apps/${appName}/webpack.config.js`, 'optimization', false); | ||
setPluginOption( | ||
`apps/${appName2}/webpack.config.js`, | ||
'outputHashing', | ||
'none' | ||
); | ||
setPluginOption( | ||
`apps/${appName2}/webpack.config.js`, | ||
'optimization', | ||
false | ||
); | ||
runCLI(`run-many --target build --node-env=test`); | ||
expect(readFile(`dist/apps/${appName}/main.js`)).toContain( | ||
'const envVars = ["test", "ws-base", "ws-env-local", "ws-local-env", "app-base", "app-env-local", "app-local-env", "shared-in-app-env-local"];' | ||
); | ||
expect(readFile(`dist/apps/${appName2}/main.js`)).toContain( | ||
'const envVars = ["test", "ws-base", "ws-env-local", "ws-local-env", "app2-base", "app2-env-local", "app2-local-env", "shared2-in-app-env-local"];' | ||
); | ||
|
||
cleanupProject(); | ||
}); | ||
}); | ||
|
||
function setPluginOption( | ||
webpackConfigPath: string, | ||
option: string, | ||
value: string | boolean | ||
): void { | ||
updateFile(webpackConfigPath, (content) => { | ||
return content.replace( | ||
new RegExp(`${option}: .+`), | ||
`${option}: ${typeof value === 'string' ? `'${value}'` : value},` | ||
); | ||
}); | ||
} |
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 appears to be a duplicate entry for
e2e-ci**module-federation/misc-rspack-interoperability**
in the targets list (lines 42 and 45). One of these entries should be removed to prevent the same test from running twice unnecessarily.Spotted by Graphite Agent

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