Skip to content

Commit

Permalink
add test for importless case
Browse files Browse the repository at this point in the history
  • Loading branch information
akwodkiewicz committed May 15, 2024
1 parent cf7082e commit 291df58
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 1 deletion.
18 changes: 17 additions & 1 deletion e2e/__tests__/typescriptConfigFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import {tmpdir} from 'os';
import * as path from 'path';
import {cleanup, writeFiles} from '../Utils';
import runJest from '../runJest';
import runJest, {getConfig} from '../runJest';

const DIR = path.resolve(tmpdir(), 'typescript-config-file');

Expand Down Expand Up @@ -107,3 +107,19 @@ test('works with multiple typescript configs that import something', () => {
expect(exitCode).toBe(0);
expect(stdout).toBe('');
});

test("works with single typescript config that does not import anything with project's moduleResolution set to Node16", () => {
const {configs} = getConfig(
'typescript-config/modern-module-resolution',
[],
{
skipPkgJsonCheck: true,
},
);

expect(configs).toHaveLength(1);
expect(configs[0].displayName).toEqual({
color: 'white',
name: 'Config from modern ts file',
});
});
10 changes: 10 additions & 0 deletions e2e/typescript-config/modern-module-resolution/__tests__/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

test('dummy test', () => {
expect(1).toBe(1);
});
12 changes: 12 additions & 0 deletions e2e/typescript-config/modern-module-resolution/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

const config = {
displayName: 'Config from modern ts file',
testEnvironment: 'node',
};
export default config;
3 changes: 3 additions & 0 deletions e2e/typescript-config/modern-module-resolution/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
8 changes: 8 additions & 0 deletions e2e/typescript-config/modern-module-resolution/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "Node16",
"moduleResolution": "Node16",
"strict": true
}
}

0 comments on commit 291df58

Please sign in to comment.