Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ reports/
# Mutation testing temp files
.stryker-tmp

# TypeScript transpilation cache
.testy-cache
# TypeScript transpilation temporary files
*.ts.testy-tmp.js

# JSDoc
doc/jsdoc/
Expand Down
8 changes: 2 additions & 6 deletions lib/typescript/typescript_transpiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ export class TypescriptTranspiler {
const tsCode = fs.readFileSync(filePath, 'utf8');
const jsCode = await this.transpileTypeScript(tsCode);

const tempDir = path.join(process.cwd(), '.testy-cache');
if (!fs.existsSync(tempDir)) {
fs.mkdirSync(tempDir, { recursive: true });
}

const tempFilePath = path.join(tempDir, `${path.basename(filePath)}.js`);
// Written next to the original so relative imports keep resolving against the same directory.
const tempFilePath = path.join(path.dirname(filePath), `${path.basename(filePath)}.testy-tmp.js`);
fs.writeFileSync(tempFilePath, jsCode);

return { importPath: tempFilePath };
Expand Down
2 changes: 2 additions & 0 deletions tests/core/fixtures/loader_fixture_dependency.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Fixture used by test_file_loader_test.js: a local TypeScript module imported by another fixture.
export const dependencyMarker: string = 'loader-fixture-dependency-ts';
4 changes: 4 additions & 0 deletions tests/core/fixtures/loader_fixture_imports_local.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Fixture used by test_file_loader_test.js: a TypeScript module that imports a sibling module via a relative path.
import { dependencyMarker } from './loader_fixture_dependency.ts';

export const importedMarker: string = dependencyMarker;
10 changes: 10 additions & 0 deletions tests/core/test_file_loader_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ suite('TestFileLoader', () => {
});
});

test('loads a TypeScript file that imports a sibling module through a relative path', async() => {
await withRunner(async runner => {
const loader = new TestFileLoader(ui, runner);

await loader.loadAll([fixturesDir], /loader_fixture_imports_local\.ts$/u);

assert.that(fakeProcess.lastExitCode()).isNull();
});
});

test('uses the injected module loader to evaluate matched files', async() => {
await withRunner(async runner => {
const seen = [];
Expand Down
Loading