chore(repo): fix e2e setup
This commit is contained in:
parent
23c365f426
commit
099608f896
@ -1,8 +1,11 @@
|
||||
/* eslint-disable */
|
||||
export default {
|
||||
displayName: 'rspack-e2e',
|
||||
preset: '../../jest.preset.js',
|
||||
displayName: 'e2e-rspack',
|
||||
preset: '../jest.preset.e2e.js',
|
||||
maxWorkers: 1,
|
||||
globals: {},
|
||||
globalSetup: '../utils/global-setup.ts',
|
||||
globalTeardown: '../utils/global-teardown.ts',
|
||||
transform: {
|
||||
'^.+\\.[tj]s$': [
|
||||
'ts-jest',
|
||||
@ -12,5 +15,5 @@ export default {
|
||||
],
|
||||
},
|
||||
moduleFileExtensions: ['ts', 'js', 'html'],
|
||||
coverageDirectory: '../../coverage/e2e/rspack-e2e',
|
||||
coverageDirectory: '../../coverage/e2e/e2e-rspack',
|
||||
};
|
||||
|
||||
@ -1,19 +1,10 @@
|
||||
{
|
||||
"name": "rspack-e2e",
|
||||
"name": "e2e-rspack",
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"projectType": "application",
|
||||
"sourceRoot": "e2e/rspack-e2e/src",
|
||||
"targets": {
|
||||
"e2e": {
|
||||
"executor": "@nx/jest:jest",
|
||||
"options": {
|
||||
"jestConfig": "e2e/rspack-e2e/jest.config.ts",
|
||||
"runInBand": true,
|
||||
"passWithNoTests": false
|
||||
},
|
||||
"dependsOn": ["rspack:build"]
|
||||
}
|
||||
},
|
||||
"sourceRoot": "e2e/rspack",
|
||||
"// targets": "to see all targets run: nx show project e2e-rspack --web",
|
||||
"targets": {},
|
||||
"tags": [],
|
||||
"implicitDependencies": ["rspack"]
|
||||
}
|
||||
|
||||
@ -1,18 +1,21 @@
|
||||
import { getPackageManagerCommand } from '@nx/devkit';
|
||||
import {
|
||||
checkFilesExist,
|
||||
ensureNxProject,
|
||||
cleanupProject,
|
||||
listFiles,
|
||||
runNxCommandAsync,
|
||||
newProject,
|
||||
tmpProjPath,
|
||||
uniq,
|
||||
updateFile,
|
||||
} from '@nx/plugin/testing';
|
||||
runCLI,
|
||||
} from '@nx/e2e/utils';
|
||||
import { execSync } from 'child_process';
|
||||
import { writeFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
describe('rspack e2e', () => {
|
||||
let proj: string;
|
||||
|
||||
// Setting up individual workspaces per
|
||||
// test can cause e2e runs to take a long time.
|
||||
// For this reason, we recommend each suite only
|
||||
@ -20,18 +23,14 @@ describe('rspack e2e', () => {
|
||||
// on a unique project in the workspace, such that they
|
||||
// are not dependant on one another.
|
||||
beforeAll(() => {
|
||||
ensureNxProject('@nx/rspack', 'dist/packages/rspack');
|
||||
proj = newProject({ packages: ['@nx/rspack'] });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
// `nx reset` kills the daemon, and performs
|
||||
// some work which can help clean up e2e leftovers
|
||||
runNxCommandAsync('reset');
|
||||
});
|
||||
afterAll(() => cleanupProject());
|
||||
|
||||
it('should create rspack root project and additional apps', async () => {
|
||||
const project = uniq('myapp');
|
||||
await runNxCommandAsync(
|
||||
runCLI(
|
||||
`generate @nx/rspack:preset ${project} --framework=react --unitTestRunner=jest --e2eTestRunner=cypress`
|
||||
);
|
||||
|
||||
@ -61,18 +60,18 @@ describe('rspack e2e', () => {
|
||||
{ cwd: tmpProjPath() }
|
||||
);
|
||||
|
||||
let result = await runNxCommandAsync(`build ${project}`, {
|
||||
let result = runCLI(`build ${project}`, {
|
||||
env: { NODE_ENV: 'production' },
|
||||
});
|
||||
expect(result.stdout).toContain('Successfully ran target build');
|
||||
expect(result).toContain('Successfully ran target build');
|
||||
// Make sure expected files are present.
|
||||
expect(listFiles(`dist/${project}`)).toHaveLength(5);
|
||||
|
||||
result = await runNxCommandAsync(`test ${project}`);
|
||||
expect(result.stdout).toContain('Successfully ran target test');
|
||||
result = runCLI(`test ${project}`);
|
||||
expect(result).toContain('Successfully ran target test');
|
||||
|
||||
// TODO(Colum): re-enable when cypress issue is resolved
|
||||
// result = await runNxCommandAsync(`e2e e2e`);
|
||||
// result = runCLI(`e2e e2e`);
|
||||
// expect(result.stdout).toContain('Successfully ran target e2e');
|
||||
|
||||
// Update app and make sure previous dist files are not present.
|
||||
@ -80,15 +79,15 @@ describe('rspack e2e', () => {
|
||||
return `${content}\nconsole.log('hello');
|
||||
`;
|
||||
});
|
||||
result = await runNxCommandAsync(`build ${project}`, {
|
||||
result = runCLI(`build ${project}`, {
|
||||
env: { NODE_ENV: 'production' },
|
||||
});
|
||||
expect(result.stdout).toContain('Successfully ran target build');
|
||||
expect(result).toContain('Successfully ran target build');
|
||||
expect(listFiles(`dist/${project}`)).toHaveLength(5); // same length as before
|
||||
|
||||
// Generate a new app and check that the files are correct
|
||||
const app2 = uniq('app2');
|
||||
await runNxCommandAsync(
|
||||
runCLI(
|
||||
`generate @nx/rspack:app ${app2} --framework=react --unitTestRunner=jest --e2eTestRunner=cypress --style=css`
|
||||
);
|
||||
checkFilesExist(`${app2}/project.json`, `${app2}-e2e/project.json`);
|
||||
@ -112,36 +111,34 @@ describe('rspack e2e', () => {
|
||||
`
|
||||
);
|
||||
|
||||
result = await runNxCommandAsync(`build ${app2}`, {
|
||||
result = runCLI(`build ${app2}`, {
|
||||
env: { NODE_ENV: 'production' },
|
||||
});
|
||||
expect(result.stdout).toContain('Successfully ran target build');
|
||||
expect(result).toContain('Successfully ran target build');
|
||||
// Make sure expected files are present.
|
||||
expect(listFiles(`dist/${app2}`)).toHaveLength(5);
|
||||
|
||||
result = await runNxCommandAsync(`test ${app2}`);
|
||||
expect(result.stdout).toContain('Successfully ran target test');
|
||||
result = runCLI(`test ${app2}`);
|
||||
expect(result).toContain('Successfully ran target test');
|
||||
|
||||
// TODO(Colum): re-enable when cypress issue is resolved
|
||||
// result = await runNxCommandAsync(`e2e ${app2}-e2e`);
|
||||
// result = runCLI(`e2e ${app2}-e2e`);
|
||||
// expect(result.stdout).toContain('Successfully ran target e2e');
|
||||
|
||||
// Generate a Nest app and verify build output
|
||||
const app3 = uniq('app3');
|
||||
await runNxCommandAsync(
|
||||
runCLI(
|
||||
`generate @nx/rspack:app ${app3} --framework=nest --unitTestRunner=jest --no-interactive`
|
||||
);
|
||||
checkFilesExist(`${app3}/project.json`);
|
||||
|
||||
result = await runNxCommandAsync(`build ${app3}`);
|
||||
expect(result.stdout).toContain('Successfully ran target build');
|
||||
result = runCLI(`build ${app3}`);
|
||||
expect(result).toContain('Successfully ran target build');
|
||||
// Make sure expected files are present.
|
||||
expect(listFiles(`dist/${app3}`)).toHaveLength(2);
|
||||
|
||||
result = await runNxCommandAsync(
|
||||
`build ${app3} --generatePackageJson=true`
|
||||
);
|
||||
expect(result.stdout).toContain('Successfully ran target build');
|
||||
result = runCLI(`build ${app3} --generatePackageJson=true`);
|
||||
expect(result).toContain('Successfully ran target build');
|
||||
// Make sure expected files are present.
|
||||
expect(listFiles(`dist/${app3}`)).toHaveLength(4);
|
||||
}, 200_000);
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"types": ["node", "jest"]
|
||||
},
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
|
||||
@ -56,6 +56,7 @@ const nxPackages = [
|
||||
`@nx/rollup`,
|
||||
`@nx/react`,
|
||||
`@nx/remix`,
|
||||
`@nx/rspack`,
|
||||
`@nx/storybook`,
|
||||
`@nx/vue`,
|
||||
`@nx/vite`,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user