diff --git a/checks/raw/fuzzing.go b/checks/raw/fuzzing.go index 644d1724f85..e19a17aca27 100644 --- a/checks/raw/fuzzing.go +++ b/checks/raw/fuzzing.go @@ -98,23 +98,28 @@ var languageFuzzSpecs = map[clients.LanguageName]languageFuzzConfig{ // Fuzz patterns for JavaScript and TypeScript based on property-based testing. // // Based on the import of one of these packages: - // * https://fast-check.dev/ + // * https://github.com/dubzzz/fast-check/tree/main/packages/fast-check#readme + // * https://github.com/dubzzz/fast-check/tree/main/packages/ava#readme + // * https://github.com/dubzzz/fast-check/tree/main/packages/jest#readme + // * https://github.com/dubzzz/fast-check/tree/main/packages/vitest#readme // // This is not an exhaustive list. clients.JavaScript: { filePatterns: []string{"*.js"}, - // Look for direct imports of fast-check. - funcPattern: `(from\s+['"]fast-check['"]|require\(\s*['"]fast-check['"]\s*\))`, - Name: fuzzerPropertyBasedJavaScript, + // Look for direct imports of fast-check and its test runners integrations. + funcPattern: `(from\s+['"](fast-check|@fast-check/(ava|jest|vitest))['"]|` + + `require\(\s*['"](fast-check|@fast-check/(ava|jest|vitest))['"]\s*\))`, + Name: fuzzerPropertyBasedJavaScript, Desc: asPointer( "Property-based testing in JavaScript generates test instances randomly or exhaustively " + "and test that specific properties are satisfied."), }, clients.TypeScript: { filePatterns: []string{"*.ts"}, - // Look for direct imports of fast-check. - funcPattern: `(from\s+['"]fast-check['"]|require\(\s*['"]fast-check['"]\s*\))`, - Name: fuzzerPropertyBasedTypeScript, + // Look for direct imports of fast-check and its test runners integrations. + funcPattern: `(from\s+['"](fast-check|@fast-check/(ava|jest|vitest))['"]|` + + `require\(\s*['"](fast-check|@fast-check/(ava|jest|vitest))['"]\s*\))`, + Name: fuzzerPropertyBasedTypeScript, Desc: asPointer( "Property-based testing in TypeScript generates test instances randomly or exhaustively " + "and test that specific properties are satisfied."), diff --git a/checks/raw/fuzzing_test.go b/checks/raw/fuzzing_test.go index 976ce65f4a4..fc8651a3dc3 100644 --- a/checks/raw/fuzzing_test.go +++ b/checks/raw/fuzzing_test.go @@ -440,6 +440,30 @@ func Test_checkFuzzFunc(t *testing.T) { }, fileContent: "import fc from \"fast-check\";", }, + { + name: "JavaScript fast-check scoped via require", + want: true, + fileName: []string{"main.spec.js"}, + langs: []clients.Language{ + { + Name: clients.JavaScript, + NumLines: 50, + }, + }, + fileContent: "const { fc, testProp } = require('@fast-check/ava');", + }, + { + name: "JavaScript fast-check scoped via import", + want: true, + fileName: []string{"main.spec.js"}, + langs: []clients.Language{ + { + Name: clients.JavaScript, + NumLines: 50, + }, + }, + fileContent: "import { fc, test } from \"@fast-check/jest\";", + }, { name: "JavaScript with no property-based testing", want: false, @@ -477,6 +501,30 @@ func Test_checkFuzzFunc(t *testing.T) { }, fileContent: "import fc from \"fast-check\";", }, + { + name: "TypeScript fast-check scoped via require", + want: true, + fileName: []string{"main.spec.ts"}, + langs: []clients.Language{ + { + Name: clients.TypeScript, + NumLines: 50, + }, + }, + fileContent: "const { fc, testProp } = require('@fast-check/ava');", + }, + { + name: "TypeScript fast-check scoped via import", + want: true, + fileName: []string{"main.spec.ts"}, + langs: []clients.Language{ + { + Name: clients.TypeScript, + NumLines: 50, + }, + }, + fileContent: "import { fc, test } from \"@fast-check/vitest\";", + }, { name: "TypeScript with no property-based testing", want: false,