diff --git a/.eslintignore b/.eslintignore index ba91e95c6..1120b8978 100644 --- a/.eslintignore +++ b/.eslintignore @@ -7,5 +7,6 @@ src/func/funcfiftlib.js **/grammar.ohm*.ts **/grammar.ohm*.js jest.setup.js +jest.globalSetup.js jest.teardown.js /docs diff --git a/jest.config.js b/jest.config.js index e4a63d203..5de3b6d80 100644 --- a/jest.config.js +++ b/jest.config.js @@ -3,7 +3,7 @@ module.exports = { testEnvironment: "node", testPathIgnorePatterns: ["/node_modules/", "/dist/"], maxWorkers: "50%", - globalSetup: "./jest.setup.js", + globalSetup: "./jest.globalSetup.js", setupFiles: ["./jest.setup.js"], globalTeardown: "./jest.teardown.js", snapshotSerializers: ["@tact-lang/ton-jest/serializers"], diff --git a/jest.globalSetup.js b/jest.globalSetup.js new file mode 100644 index 000000000..454fcbf08 --- /dev/null +++ b/jest.globalSetup.js @@ -0,0 +1,8 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires +const coverage = require("@tact-lang/coverage"); + +module.exports = async () => { + if (process.env.COVERAGE === "true") { + coverage.beginCoverage(); + } +}; diff --git a/jest.setup.js b/jest.setup.js index 6e699ace0..67a74f59a 100644 --- a/jest.setup.js +++ b/jest.setup.js @@ -1,13 +1,5 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires -const coverage = require("@tact-lang/coverage"); const fc = require("fast-check"); -module.exports = async () => { - if (process.env.COVERAGE === "true") { - coverage.beginCoverage(); - } -}; - function sanitizeObject( obj, options = { diff --git a/src/test/prettyPrint/expressions.spec.ts b/src/test/prettyPrint/expressions.spec.ts index 887f26d1e..56dd47146 100644 --- a/src/test/prettyPrint/expressions.spec.ts +++ b/src/test/prettyPrint/expressions.spec.ts @@ -11,6 +11,7 @@ import { randomAstNull, randomAstStaticCall, randomAstStructInstance, + randomAstStructFieldInitializer, } from "../utils/expression/randomAst"; describe("Pretty Print Expressions", () => { @@ -28,7 +29,12 @@ describe("Pretty Print Expressions", () => { ["AstNull", randomAstNull()], ["AstInitOf", randomAstInitOf(expression())], ["AstStaticCall", randomAstStaticCall(expression())], - ["AstStructInstance", randomAstStructInstance(expression())], + [ + "AstStructInstance", + randomAstStructInstance( + randomAstStructFieldInitializer(expression()), + ), + ], ]; cases.forEach(([caseName, astGenerator]) => { diff --git a/src/test/utils/expression/randomAst.ts b/src/test/utils/expression/randomAst.ts index 75bdc527d..244e13c0c 100644 --- a/src/test/utils/expression/randomAst.ts +++ b/src/test/utils/expression/randomAst.ts @@ -160,7 +160,7 @@ export function randomAstStaticCall( ); } -function randomAstStructFieldInitializer( +export function randomAstStructFieldInitializer( expression: fc.Arbitrary, ): fc.Arbitrary { return dummyAstNode( @@ -173,13 +173,13 @@ function randomAstStructFieldInitializer( } export function randomAstStructInstance( - expression: fc.Arbitrary, + structFieldInitializer: fc.Arbitrary, ): fc.Arbitrary { return dummyAstNode( fc.record({ kind: fc.constant("struct_instance"), type: randomAstId(), - args: fc.array(randomAstStructFieldInitializer(expression)), + args: fc.array(structFieldInitializer), }), ); }