Skip to content
Merged
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
5 changes: 3 additions & 2 deletions packages/jest-runner/testStateInterceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 24 additions & 0 deletions tests/jest_integration/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
8 changes: 4 additions & 4 deletions tests/jest_integration/jest_project/integration.fuzz.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});
});