Skip to content
This repository was archived by the owner on Jan 14, 2019. It is now read-only.

Commit 8ad69fa

Browse files
committed
test: add check if registered path exists
1 parent 45edfd6 commit 8ad69fa

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tests/ast-alignment/fixtures-tester.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import glob from 'glob';
2+
import fs from 'fs';
23
import path from 'path';
34

45
export interface CreateFixturePatternConfig {
@@ -18,6 +19,8 @@ export interface FixturePatternConfig {
1819
ignoreSourceType: boolean;
1920
}
2021

22+
const fixturesDirPath = path.join(__dirname, '../fixtures');
23+
2124
export class FixturesTester {
2225
protected babelFixtures: FixturePatternConfig[] = [];
2326
protected espreeFixtures: FixturePatternConfig[] = [];
@@ -28,6 +31,10 @@ export class FixturesTester {
2831
fixturesSubPath: string,
2932
config: CreateFixturePatternConfig = {}
3033
) {
34+
if (!fs.existsSync(path.join(fixturesDirPath, fixturesSubPath))) {
35+
throw new Error(`Registered path '${path.join(__dirname, fixturesSubPath)}' was not found`);
36+
}
37+
3138
const ignoreBabel = config.ignoreBabel || [];
3239
const ignoreEspree = config.ignoreEspree || [];
3340
const fileType = config.fileType || 'js';
@@ -63,8 +70,6 @@ export class FixturesTester {
6370
}
6471

6572
protected processFixtures(fixtures: FixturePatternConfig[]): Fixture[] {
66-
const fixturesDirPath = path.join(__dirname, '../fixtures');
67-
6873
return fixtures
6974
.map(fixtures => {
7075
return glob

0 commit comments

Comments
 (0)