From 158e12ace10bf3ed3e0be0231b776db526debf68 Mon Sep 17 00:00:00 2001 From: Thomas Skalnik Date: Mon, 23 Sep 2019 11:11:54 +0200 Subject: [PATCH] feat(testing): set transpileOnly=true ... ... and use the ForkTsCheckerWebpackPlugin for the cypress test execution. Closes #1871 --- packages/cypress/package.json | 1 + packages/cypress/src/plugins/preprocessor.spec.ts | 4 +++- packages/cypress/src/plugins/preprocessor.ts | 11 ++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/cypress/package.json b/packages/cypress/package.json index bc85d730811f4..64a4f7f1fa78f 100644 --- a/packages/cypress/package.json +++ b/packages/cypress/package.json @@ -38,6 +38,7 @@ "@angular-devkit/architect": "0.803.3", "@angular-devkit/core": "8.3.3", "@cypress/webpack-preprocessor": "~4.1.0", + "fork-ts-checker-webpack-plugin": "^0.4.9", "tree-kill": "1.2.1", "ts-loader": "5.3.1", "tsconfig-paths-webpack-plugin": "3.2.0", diff --git a/packages/cypress/src/plugins/preprocessor.spec.ts b/packages/cypress/src/plugins/preprocessor.spec.ts index 646c2623fa289..28d652c71cdbd 100644 --- a/packages/cypress/src/plugins/preprocessor.spec.ts +++ b/packages/cypress/src/plugins/preprocessor.spec.ts @@ -21,7 +21,9 @@ describe('getWebpackConfig', () => { options: { configFile: './tsconfig.json', // https://github.com/TypeStrong/ts-loader/pull/685 - experimentalWatchApi: true + experimentalWatchApi: true, + // https://github.com/cypress-io/cypress/issues/2316 + transpileOnly: true } }); }); diff --git a/packages/cypress/src/plugins/preprocessor.ts b/packages/cypress/src/plugins/preprocessor.ts index ea38af6c13095..364a997f14b74 100644 --- a/packages/cypress/src/plugins/preprocessor.ts +++ b/packages/cypress/src/plugins/preprocessor.ts @@ -2,6 +2,8 @@ import * as wp from '@cypress/webpack-preprocessor'; import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin'; import * as nodeExternals from 'webpack-node-externals'; +import ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); + export function preprocessTypescript(config: any) { if (!config.env.tsConfig) { throw new Error( @@ -35,11 +37,18 @@ export function getWebpackConfig(config: any) { options: { configFile: config.env.tsConfig, // https://github.com/TypeStrong/ts-loader/pull/685 - experimentalWatchApi: true + experimentalWatchApi: true, + // https://github.com/cypress-io/cypress/issues/2316 + transpileOnly: true } } ] }, + plugins: [ + new ForkTsCheckerWebpackPlugin({ + tsconfig: config.env.tsConfig + }) + ], externals: [nodeExternals()] }; }