From 31e3d916457c7e36f7a7ebd8d42591e596a513b1 Mon Sep 17 00:00:00 2001 From: Dmitriy Stepanenko <33101123+dmitry-stepanenko@users.noreply.github.com> Date: Sun, 29 Oct 2023 07:47:05 +0000 Subject: [PATCH] test: do not use snapshots for error verification in e2e --- .../__snapshots__/application.spec.ts.snap | 33 ------------------- .../tests/__snapshots__/preset.spec.ts.snap | 33 ------------------- .../tests/application-basic-behavior.suite.ts | 12 +++++-- 3 files changed, 10 insertions(+), 68 deletions(-) delete mode 100644 e2e/qwik-nx-e2e/tests/__snapshots__/application.spec.ts.snap delete mode 100644 e2e/qwik-nx-e2e/tests/__snapshots__/preset.spec.ts.snap diff --git a/e2e/qwik-nx-e2e/tests/__snapshots__/application.spec.ts.snap b/e2e/qwik-nx-e2e/tests/__snapshots__/application.spec.ts.snap deleted file mode 100644 index df934ada..00000000 --- a/e2e/qwik-nx-e2e/tests/__snapshots__/application.spec.ts.snap +++ /dev/null @@ -1,33 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`appGenerator e2e Basic behavior with app generator should run type checking before the build step: stderr 1`] = `""`; - -exports[`appGenerator e2e Basic behavior with app generator should run type checking before the build step: stdout 1`] = ` -" -> nx run PROJECT_NAME:build - - >  NX  Running type check for the \\"PROJECT_NAME\\".. - npx tsc --incremental --noEmit --pretty -p REPLACED_PATH/tsconfig.app.json -LIB_PROJECT_NAME/src/lib/LIB_PROJECT_NAME.tsx:7:22 - error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -7 b.push(1); -   ~ -PROJECT_NAME/src/routes/index.tsx:8:15 - error TS2322: Type 'string' is not assignable to type 'number'. -8 a = 'not-a-number'; -   ~ -Found 2 errors in 2 files. -Errors Files - 1 LIB_PROJECT_NAME/src/lib/LIB_PROJECT_NAME.tsx:7 - 1 PROJECT_NAME/src/routes/index.tsx:8 - - - - > NX Running target build for project PROJECT_NAME failed - - Failed tasks: - - - PROJECT_NAME:build - - Hint: run the command with --verbose for more details. - -" -`; diff --git a/e2e/qwik-nx-e2e/tests/__snapshots__/preset.spec.ts.snap b/e2e/qwik-nx-e2e/tests/__snapshots__/preset.spec.ts.snap deleted file mode 100644 index 9dcd61eb..00000000 --- a/e2e/qwik-nx-e2e/tests/__snapshots__/preset.spec.ts.snap +++ /dev/null @@ -1,33 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`presetGenerator e2e Basic behavior with preset generator should run type checking before the build step: stderr 1`] = `""`; - -exports[`presetGenerator e2e Basic behavior with preset generator should run type checking before the build step: stdout 1`] = ` -" -> nx run PROJECT_NAME:build - - >  NX  Running type check for the \\"PROJECT_NAME\\".. - npx tsc --incremental --noEmit --pretty -p REPLACED_PATH/tsconfig.app.json -apps/PROJECT_NAME/src/routes/index.tsx:8:15 - error TS2322: Type 'string' is not assignable to type 'number'. -8 a = 'not-a-number'; -   ~ -libs/LIB_PROJECT_NAME/src/lib/LIB_PROJECT_NAME.tsx:7:22 - error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -7 b.push(1); -   ~ -Found 2 errors in 2 files. -Errors Files - 1 apps/PROJECT_NAME/src/routes/index.tsx:8 - 1 libs/LIB_PROJECT_NAME/src/lib/LIB_PROJECT_NAME.tsx:7 - - - - > NX Running target build for project PROJECT_NAME failed - - Failed tasks: - - - PROJECT_NAME:build - - Hint: run the command with --verbose for more details. - -" -`; diff --git a/e2e/qwik-nx-e2e/tests/application-basic-behavior.suite.ts b/e2e/qwik-nx-e2e/tests/application-basic-behavior.suite.ts index 096c6db3..7254e4fa 100644 --- a/e2e/qwik-nx-e2e/tests/application-basic-behavior.suite.ts +++ b/e2e/qwik-nx-e2e/tests/application-basic-behavior.suite.ts @@ -147,8 +147,16 @@ export function testApplicationBasicBehavior(generator: 'app' | 'preset') { .replace(/-p .+/, '-p REPLACED_PATH/tsconfig.app.json'); } - expect(replaceDynamicContent(result.stderr)).toMatchSnapshot('stderr'); - expect(replaceDynamicContent(result.stdout)).toMatchSnapshot('stdout'); + const stdout = replaceDynamicContent(stripConsoleColors(result.stdout)); + expect(stdout).toContain( + `PROJECT_NAME/src/routes/index.tsx:8:15 - error TS2322: Type 'string' is not assignable to type 'number'.` + ); + expect(stdout).toContain( + `LIB_PROJECT_NAME/src/lib/LIB_PROJECT_NAME.tsx:7:22 - error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.` + ); + expect(stdout).toContain( + `Running target build for project PROJECT_NAME failed` + ); }, DEFAULT_E2E_TIMEOUT );