diff --git a/packages/jest-runner/testStateInterceptor.ts b/packages/jest-runner/testStateInterceptor.ts index 5fe79a320..2c292b8f4 100644 --- a/packages/jest-runner/testStateInterceptor.ts +++ b/packages/jest-runner/testStateInterceptor.ts @@ -59,11 +59,12 @@ export function interceptTestState( } else if (event.name === "test_start") { // In fuzzing mode, only execute the first encountered (not skipped) fuzz test // and mark all others as skipped. - if (jazzerConfig.mode === "fuzzing") { + if (jazzerConfig.mode === "fuzzing" && event.test.mode !== "skip") { if ( !firstFuzzTestEncountered && (!state.testNamePattern || - state.testNamePattern.test(testName(event.test))) + (state.testNamePattern.test(testName(event.test)) && + (!state.hasFocusedTests || event.test.mode === "only"))) ) { firstFuzzTestEncountered = true; } else { diff --git a/tests/jest_integration/integration.test.js b/tests/jest_integration/integration.test.js index 2e6f85626..8d5a26431 100644 --- a/tests/jest_integration/integration.test.js +++ b/tests/jest_integration/integration.test.js @@ -197,6 +197,30 @@ describe("Jest integration", () => { ); }); }); + + describe("run modes", () => { + it.concurrent("only", () => { + const fuzzTest = new FuzzTestBuilder() + .dir(projectDir) + .jestTestName("Run mode only and standard") + .jestTestFile("run-mode-only.fuzz.js") + .jestRunInFuzzingMode(true) + .runs(1) + .build() + .execute(); + expect(fuzzTest.stdout).toContain("only test called"); + }); + + it("skipped", () => { + const fuzzTest = fuzzTestBuilder + .jestTestName("Run mode skip and standard") + .runs(1) + .logTestOutput() + .build() + .execute(); + expect(fuzzTest.stdout).toContain("standard test called"); + }); + }); }); describe("Regression mode", () => { diff --git a/tests/jest_integration/jest_project/integration.fuzz.js b/tests/jest_integration/jest_project/integration.fuzz.js index a6d24d370..eea7766f3 100644 --- a/tests/jest_integration/jest_project/integration.fuzz.js +++ b/tests/jest_integration/jest_project/integration.fuzz.js @@ -95,12 +95,12 @@ describe("Jest Integration", () => { describe("Run mode", () => { describe("skip and standard", () => { - it.fuzz("standard test", (data) => { - console.log("standard test called"); - }); - it.skip.fuzz("skipped test", (data) => { throw new Error("Skipped test not skipped!"); }); + + it.fuzz("standard test", (data) => { + console.log("standard test called"); + }); }); });