Skip to content

Commit af5c97d

Browse files
committed
test: removes any tsconfig.json in the way of the tests
1 parent 691720f commit af5c97d

9 files changed

Lines changed: 20 additions & 31 deletions

File tree

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@
6060
"js",
6161
"jsx",
6262
"json"
63-
]
63+
],
64+
"globals": {
65+
"ts-jest": {
66+
"tsConfigFile": "tsconfig.base.json"
67+
}
68+
}
6469
},
6570
"dependencies": {
6671
"closest-file-data": "^0.1.4",

scripts/tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function getDirectories(rootDir) {
1616
function createIntegrationMock() {
1717
const testsRoot = 'tests';
1818
const testCaseFolders = getDirectories(testsRoot).filter(function(testDir) {
19-
return !(testDir.startsWith('__') && testDir.endsWith('__'));
19+
return !/^(?:utils|__.+__)$/.test(testDir);
2020
});
2121

2222
testCaseFolders.forEach(directory => {

src/utils/get-ts-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function readCompilerOptions(
110110
// }
111111

112112
// we don't need any data, just its full path
113-
const tsConfigReader = { basename: TSCONFIG_FILENAME, read: () => null };
113+
const tsConfigReader = { basename: TSCONFIG_FILENAME, read: () => 0 };
114114

115115
function findTSConfigPath(
116116
jestConfig: jest.ProjectConfig,

tests/__tests__/tsconfig-comments.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ describe('parse tsconfig with comments', () => {
1212
beforeEach(() => {
1313
// Set up some mocked out file info before each test
1414
((path as any) as MockedPath).__setBaseDir('./tests/tsconfig-test');
15+
getTSConfig.cache.clear();
1516
});
1617

1718
it('the two config files should exist', () => {

tests/__tests__/tsconfig-default.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ describe('get default ts config', () => {
1515
getTSConfig.cache.clear();
1616
});
1717

18+
it('should bail when no default tsconfig.json found', () => {
19+
// there is no tsconfig file in that test module
20+
((path as any) as MockedPath).__setBaseDir('./tests/jestconfig-test');
21+
22+
expect(() => getTSConfig(jestConfig.jestconfigTest(null))).toThrowError(
23+
/unable to find ts configuration file/i,
24+
);
25+
});
26+
1827
it('should correctly read tsconfig.json', () => {
1928
const result = getTSConfig(jestConfig.tsconfigTest(null));
2029

@@ -97,6 +106,5 @@ describe('get default ts config', () => {
97106

98107
expect(getTSJestConfig({ globals: { 'ts-jest': {} } })).toEqual({});
99108
expect(getTSJestConfig({})).toEqual({});
100-
// expect(getTSJestConfig(null)).toEqual({});
101109
});
102110
});

tests/__tests__/tsconfig-string.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ describe('get ts config from string', () => {
99
beforeEach(() => {
1010
// Set up some mocked out file info before each test
1111
(path as any).__setBaseDir('./tests/tsconfig-test');
12+
getTSConfig.cache.clear();
1213
});
1314

1415
describe('new behaviour (tsConfigFile & tsConfig)', () => {

tests/tsconfig.json

Lines changed: 0 additions & 26 deletions
This file was deleted.
File renamed without changes.

tsconfig.build.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "./tsconfig.json",
2+
"extends": "./tsconfig.base.json",
33
"compilerOptions": {
44
"sourceMap": false,
55
"removeComments": true,

0 commit comments

Comments
 (0)