File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515 */
1616
1717const path = require ( "path" ) ;
18+ const { spawnSync } = require ( "child_process" ) ;
1819
1920const {
2021 FuzzTestBuilder,
@@ -151,6 +152,36 @@ describe("CLI", () => {
151152} ) ;
152153
153154describe ( "Jest" , ( ) => {
155+ it ( "keeps the canary stable across sequential Jest files" , ( ) => {
156+ const proc = spawnSync (
157+ "npx" ,
158+ [
159+ "jest" ,
160+ "--runInBand" ,
161+ "--no-colors" ,
162+ "--runTestsByPath" ,
163+ "context-a.fuzz.js" ,
164+ "context-b.fuzz.js" ,
165+ ] ,
166+ {
167+ cwd : bugDetectorDirectory ,
168+ env : { ...process . env } ,
169+ shell : true ,
170+ stdio : "pipe" ,
171+ windowsHide : true ,
172+ } ,
173+ ) ;
174+
175+ const output = proc . stdout . toString ( ) + proc . stderr . toString ( ) ;
176+ expect ( proc . status ?. toString ( ) ) . toBe ( JestRegressionExitCode ) ;
177+ expect ( output ) . toContain ( "context-a.fuzz.js" ) ;
178+ expect ( output ) . toContain ( "context-b.fuzz.js" ) ;
179+ expect ( output ) . not . toContain ( "accessed canary: jaz_zer_1" ) ;
180+ expect (
181+ ( output . match ( / a c c e s s e d c a n a r y : j a z _ z e r / g) ?? [ ] ) . length ,
182+ ) . toBeGreaterThanOrEqual ( 2 ) ;
183+ } ) ;
184+
154185 it ( "reports potential access" , ( ) => {
155186 const fuzzTest = fuzzTestBuilder
156187 . dryRun ( false )
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2026 Code Intelligence GmbH
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ const tests = require ( "./fuzz" ) ;
18+
19+ describe ( "context a" , ( ) => {
20+ it . fuzz ( "Accesses canary" , ( data ) => {
21+ tests . evalAccessesCanary ( data ) ;
22+ } ) ;
23+ } ) ;
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2026 Code Intelligence GmbH
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ const tests = require ( "./fuzz" ) ;
18+
19+ describe ( "context b" , ( ) => {
20+ it . fuzz ( "Accesses canary" , ( data ) => {
21+ tests . evalAccessesCanary ( data ) ;
22+ } ) ;
23+ } ) ;
You can’t perform that action at this time.
0 commit comments