forked from NomicFoundation/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix ts-jest flaky runs (NomicFoundation#1129)
we have been having random test failures both locally and CI, which present in failure to load TypeScript definitions ([recent one for example](https://github.com/NomicFoundation/slang/actions/runs/11456261626/job/31874008248)). This essentially comes down to cache bugs in `ts-jest`, which we can just avoid by asking it to skip type checking during test running. It is redundant since we already verify that using `infra check tsc`.
- Loading branch information
1 parent
a97b27d
commit c4c3e2b
Showing
22 changed files
with
78 additions
and
63 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
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,19 @@ | ||
import * as slang from "@slang-private/testlang-npm-package"; | ||
import { NonterminalKind, TerminalKind } from "@slang-private/testlang-npm-package/cst"; | ||
import { Parser } from "@slang-private/testlang-npm-package/parser"; | ||
|
||
test("use namespace imports of the API", () => { | ||
expect(slang.cst.NonterminalKind.SourceUnit).toEqual("SourceUnit"); | ||
expect(slang.cst.NonterminalKind.TreeNode).toEqual("TreeNode"); | ||
expect(slang.cst.TerminalKind.Identifier).toEqual("Identifier"); | ||
}); | ||
|
||
test("use nested imports of the API", () => { | ||
expect(NonterminalKind.SourceUnit).toEqual("SourceUnit"); | ||
expect(NonterminalKind.TreeNode).toEqual("TreeNode"); | ||
expect(TerminalKind.Identifier).toEqual("Identifier"); | ||
}); | ||
|
||
test("language exposes a root kind", () => { | ||
expect(Parser.rootKind()).toEqual(NonterminalKind.SourceUnit); | ||
}); |
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
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
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,11 +1,39 @@ | ||
import type { Config } from "jest"; | ||
|
||
const config: Config = { | ||
projects: [ | ||
// List all directories with package-level "jest.config.ts" files: | ||
"<rootDir>/crates/solidity/outputs/npm/tests/", | ||
"<rootDir>/crates/testlang/outputs/npm/tests/", | ||
export default { | ||
testMatch: ["<rootDir>/**/*.test.mts"], | ||
|
||
testPathIgnorePatterns: [".*/\\.hermit/", ".*/node_modules/", ".*/submodules/", ".*/target/"], | ||
|
||
moduleFileExtensions: [ | ||
/* Plain: */ ["js", "ts"], | ||
/* ESM: */ ["mjs", "mts"], | ||
/* CJS: */ ["cjs", "cts"], | ||
/* JSX: */ ["jsx", "tsx"], | ||
/* Other: */ ["json", "node", "wasm"], | ||
].flat(), | ||
|
||
extensionsToTreatAsEsm: [ | ||
// ".mjs" is already included. | ||
".mts", | ||
], | ||
}; | ||
|
||
export default config; | ||
cacheDirectory: "<rootDir>/target/jest/cache", | ||
|
||
slowTestThreshold: 5, | ||
|
||
clearMocks: true, | ||
resetMocks: true, | ||
|
||
resolver: "ts-jest-resolver", | ||
|
||
transform: { | ||
"^.+\\.m?[tj]sx?$": [ | ||
"ts-jest", | ||
{ | ||
isolatedModules: true, | ||
useESM: true, | ||
}, | ||
], | ||
}, | ||
} satisfies Config; |