Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Used c12 for configuration loading * Rebuild * Removed cfgn dependency * Fixed tests
- Loading branch information
Showing
7 changed files
with
8,159 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const loadConfig = jest.fn(); |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,12 @@ | ||
import { resolve } from 'path'; | ||
import { loadConfig } from 'c12'; | ||
|
||
import { parseConfigurations, PossibleConfiguration } from 'cfgn'; | ||
export const parseJestConfig = async ( | ||
workingDirectory: string | ||
): Promise<unknown> => { | ||
const { config } = await loadConfig({ | ||
cwd: workingDirectory, | ||
name: 'jest', | ||
}); | ||
|
||
// These constants are taken from "jest-config" module, file "constants.js" | ||
const JEST_CONFIG_BASE_NAME = 'jest.config'; | ||
const JEST_CONFIG_EXT_ORDER = Object.freeze([ | ||
'.js', | ||
'.ts', | ||
'.mjs', | ||
'.cjs', | ||
'.json', | ||
]); | ||
|
||
export const parseJestConfig = (workingDirectory: string): Promise<unknown> => { | ||
const possibleJestConfigs: PossibleConfiguration[] = JEST_CONFIG_EXT_ORDER.map( | ||
(extension) => ({ | ||
path: resolve( | ||
workingDirectory, | ||
JEST_CONFIG_BASE_NAME.concat(extension) | ||
), | ||
}) | ||
); | ||
|
||
return parseConfigurations(possibleJestConfigs); | ||
return config; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters