Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(test): do not require typescript for tests
  • Loading branch information
adamdbradley committed Aug 24, 2020
1 parent 4ffbe4a commit 43c5d98
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 0 additions & 1 deletion scripts/bundles/testing.ts
Expand Up @@ -55,7 +55,6 @@ export async function testing(opts: BuildOptions) {
'@rollup/plugin-node-resolve',
'stream',
'tty',
'typescript',
'url',
'util',
'vm',
Expand Down
17 changes: 14 additions & 3 deletions src/testing/jest/jest-preprocessor.ts
@@ -1,7 +1,7 @@
import type { TranspileOptions, Diagnostic } from '@stencil/core/internal';
import { loadTypeScriptDiagnostic, normalizePath } from '@utils';
import { transpile } from '../test-transpile';
import ts from 'typescript';
import { ts } from '@stencil/core/compiler';

export const jestPreprocessor = {
process(sourceText: string, filePath: string, jestConfig: { rootDir: string }) {
Expand Down Expand Up @@ -44,7 +44,12 @@ export const jestPreprocessor = {
return this._tsCompilerOptions;
},

getCacheKey(code: string, filePath: string, jestConfigStr: string, transformOptions: { instrument: boolean; rootDir: string }) {
getCacheKey(
code: string,
filePath: string,
jestConfigStr: string,
transformOptions: { instrument: boolean; rootDir: string },
) {
// https://github.com/facebook/jest/blob/v23.6.0/packages/jest-runtime/src/script_transformer.js#L61-L90
if (!this._tsCompilerOptionsKey) {
const opts = this.getCompilerOptions(transformOptions.rootDir);
Expand Down Expand Up @@ -102,7 +107,13 @@ function getCompilerOptions(rootDir: string) {
throw new Error(formatDiagnostic(loadTypeScriptDiagnostic(tsconfigResults.error)));
}

const parseResult = ts.parseJsonConfigFileContent(tsconfigResults.config, ts.sys, rootDir, undefined, tsconfigFilePath);
const parseResult = ts.parseJsonConfigFileContent(
tsconfigResults.config,
ts.sys,
rootDir,
undefined,
tsconfigFilePath,
);

return parseResult.options;
}
Expand Down

0 comments on commit 43c5d98

Please sign in to comment.