Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix jest esm tests #1797

Draft
wants to merge 5 commits into
base: test/use-esm
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions colorette.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
declare module 'colorette' {
const colorette: any;
export const options: {
enabled: boolean
}
export function black(text: string): string;
export function red(text: string): string;
export function green(text: string): string;
export function yellow(text: string): string;
export function blue(text: string): string;
export function magenta(text: string): string;
export function cyan(text: string): string;
export function white(text: string): string;
export function gray(text: string): string;

export function bgBlack(text: string): string;
export function bgRed(text: string): string;
export function bgGreen(text: string): string;
export function bgYellow(text: string): string;
export function bgBlue(text: string): string;
export function bgMagenta(text: string): string;
export function bgCyan(text: string): string;
export function bgWhite(text: string): string;

export function dim(text: string): string;
export function bold(text: string): string;
export function hidden(text: string): string;
export function italic(text: string): string;
export function underline(text: string): string;
export function strikethrough(text: string): string;
export function reset(text: string): string;
export function inverse(text: string): string;
export default colorette;
}
16 changes: 16 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ const jestConfig: JestConfigWithTsJest = {
preset: 'ts-jest/presets/default-esm',
extensionsToTreatAsEsm: ['.ts'],
testEnvironment: 'node',
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
transform: {
'^.+\\.[tj]s$': [
'ts-jest',
{
useESM: true,
tsconfig: {
esModuleInterop: true,
allowSyntheticDefaultImports: true
}
},
],
},
collectCoverageFrom: [
'packages/*/src/**/*.ts',
'!packages/**/__tests__/**/*',
Expand Down Expand Up @@ -34,6 +49,7 @@ const jestConfig: JestConfigWithTsJest = {
},
},
testMatch: ['**/__tests__/**/*.test.ts', '**/*.test.ts'],
setupFiles: ['<rootDir>/setup-jest.js'],
};

export default jestConfig;
Loading
Loading