From c8df947e325d17387c2840a44d06a906fde1c5d9 Mon Sep 17 00:00:00 2001 From: Jack Hsu Date: Wed, 15 Feb 2023 15:30:52 -0500 Subject: [PATCH] feat: add rspack plugin (#143) --- jest.config.ts | 15 +++++++++++++++ project.json | 17 +++++++++++++++++ tests/rspack.spec.ts | 35 +++++++++++++++++++++++++++++++++++ tsconfig.json | 10 ++++++++++ tsconfig.spec.json | 9 +++++++++ 5 files changed, 86 insertions(+) create mode 100644 jest.config.ts create mode 100644 project.json create mode 100644 tests/rspack.spec.ts create mode 100644 tsconfig.json create mode 100644 tsconfig.spec.json diff --git a/jest.config.ts b/jest.config.ts new file mode 100644 index 0000000000..893fb612ef --- /dev/null +++ b/jest.config.ts @@ -0,0 +1,15 @@ +/* eslint-disable */ +export default { + displayName: 'rspack-e2e', + preset: '../../jest.preset.js', + globals: { + 'ts-jest': { + tsconfig: '/tsconfig.spec.json', + }, + }, + transform: { + '^.+\\.[tj]s$': 'ts-jest', + }, + moduleFileExtensions: ['ts', 'js', 'html'], + coverageDirectory: '../../coverage/e2e/rspack-e2e', +}; diff --git a/project.json b/project.json new file mode 100644 index 0000000000..d013186ec1 --- /dev/null +++ b/project.json @@ -0,0 +1,17 @@ +{ + "name": "rspack-e2e", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "projectType": "application", + "sourceRoot": "e2e/rspack-e2e/src", + "targets": { + "e2e": { + "executor": "@nrwl/nx-plugin:e2e", + "options": { + "target": "rspack:build", + "jestConfig": "e2e/rspack-e2e/jest.config.ts" + } + } + }, + "tags": [], + "implicitDependencies": ["rspack"] +} diff --git a/tests/rspack.spec.ts b/tests/rspack.spec.ts new file mode 100644 index 0000000000..801a7046d2 --- /dev/null +++ b/tests/rspack.spec.ts @@ -0,0 +1,35 @@ +import { + ensureNxProject, + runNxCommandAsync, + uniq, +} from '@nrwl/nx-plugin/testing'; + +describe('rspack e2e', () => { + // Setting up individual workspaces per + // test can cause e2e runs to take a long time. + // For this reason, we recommend each suite only + // consumes 1 workspace. The tests should each operate + // on a unique project in the workspace, such that they + // are not dependant on one another. + beforeAll(() => { + ensureNxProject('@nrwl/rspack', 'dist/packages/rspack'); + }); + + afterAll(() => { + // `nx reset` kills the daemon, and performs + // some work which can help clean up e2e leftovers + runNxCommandAsync('reset'); + }); + + it('should create rspack project', async () => { + const project = uniq('myapp'); + await runNxCommandAsync( + `generate @nrwl/rspack:preset ${project} --style=css --unitTestRunner=jest --e2eTestRunner=cypress` + ); + let result = await runNxCommandAsync(`build ${project}`); + expect(result.stdout).toContain('Successfully ran target build'); + + result = await runNxCommandAsync(`e2e e2e`); + expect(result.stdout).toContain('Successfully ran target e2e'); + }, 120_000); +}); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000000..b9c9d95376 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/tsconfig.spec.json b/tsconfig.spec.json new file mode 100644 index 0000000000..546f12877f --- /dev/null +++ b/tsconfig.spec.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"] +}