Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed May 14, 2024
1 parent 265a35b commit cf7082e
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 0 deletions.
12 changes: 12 additions & 0 deletions e2e/__tests__/esmConfigFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,15 @@ test('reads config from ts file when package.json#type=module', () => {
name: 'Config from ts file',
});
});

test('reads config from ts file with modern resolution when package.json#type=module', () => {
const {configs} = getConfig('esm-config/ts-modern', [], {
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/esm-config/ts-modern/__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);
});
10 changes: 10 additions & 0 deletions e2e/esm-config/ts-modern/jest.config.ts
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.
*/

import config from './some-other-file.js';

export default () => config;
3 changes: 3 additions & 0 deletions e2e/esm-config/ts-modern/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
20 changes: 20 additions & 0 deletions e2e/esm-config/ts-modern/some-other-file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* 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.
*/

// allows to make sure that `ts-node` compiles the config file without a need to build Jest types
// integration tests of Jest types run in a separate CI job through `jest.config.ts.mjs`
type DummyConfig = {
displayName: string;
testEnvironment: string;
};

const config: DummyConfig = {
displayName: 'Config from modern ts file',
testEnvironment: 'node',
};

export default config;
8 changes: 8 additions & 0 deletions e2e/esm-config/ts-modern/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"target": "esnext",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true
}
}

0 comments on commit cf7082e

Please sign in to comment.