@@ -89,58 +89,49 @@ jobs:
8989
9090 - name : Install fast-check for fuzzing
9191 run : |
92- npm install fast-check@3.22.0 jest@29.7.0
92+ npm install fast-check@3.22.0
9393
9494 - name : Run fuzz tests
9595 run : |
9696 cat << 'EOF' > fuzz.test.mjs
97+ import { test } from 'node:test';
98+ import { strict as assert } from 'node:assert';
9799 import fc from 'fast-check';
98100 import * as utils from './dist/utils.js';
99101
100- describe('Fuzz Testing', () => {
101- test('detectPackageManager handles arbitrary strings', () => {
102- fc.assert(fc.property(fc.string(), (input) => {
103- try {
104- const result = utils.detectPackageManager(input);
105- expect(typeof result).toBe('string');
106- expect(['npm', 'yarn', 'pnpm', 'bun'].includes(result)).toBe(true);
107- } catch (error) {
108- expect(error).toBeInstanceOf(Error);
109- }
110- }));
111- });
112-
113- test('validateTemplateVariables handles arbitrary objects', () => {
114- fc.assert(fc.property(fc.object(), (input) => {
115- try {
116- const result = utils.validateTemplateVariables(input, []);
117- expect(typeof result).toBe('object');
118- } catch (error) {
119- expect(error).toBeInstanceOf(Error);
120- }
121- }));
122- });
123-
124- test('renderTemplate handles arbitrary template strings', () => {
125- fc.assert(fc.property(fc.string(), fc.object(), (template, vars) => {
126- try {
127- const result = utils.renderTemplate(template, vars);
128- expect(typeof result).toBe('string');
129- } catch (error) {
130- expect(error).toBeInstanceOf(Error);
131- }
132- }));
133- });
102+ test('detectPackageManager handles arbitrary strings', () => {
103+ fc.assert(fc.property(fc.string(), (input) => {
104+ try {
105+ const result = utils.detectPackageManager(input);
106+ assert.equal(typeof result, 'string');
107+ assert.ok(['npm', 'yarn', 'pnpm', 'bun'].includes(result));
108+ } catch (error) {
109+ assert.ok(error instanceof Error);
110+ }
111+ }));
112+ });
113+
114+ test('validateTemplateVariables handles arbitrary objects', () => {
115+ fc.assert(fc.property(fc.object(), (input) => {
116+ try {
117+ const result = utils.validateTemplateVariables(input, []);
118+ assert.equal(typeof result, 'object');
119+ } catch (error) {
120+ assert.ok(error instanceof Error);
121+ }
122+ }));
123+ });
124+
125+ test('renderTemplate handles arbitrary template strings', () => {
126+ fc.assert(fc.property(fc.string(), fc.object(), (template, vars) => {
127+ try {
128+ const result = utils.renderTemplate(template, vars);
129+ assert.equal(typeof result, 'string');
130+ } catch (error) {
131+ assert.ok(error instanceof Error);
132+ }
133+ }));
134134 });
135135 EOF
136136
137- cat << 'EOF' > jest.config.js
138- export default {
139- transform: {},
140- testMatch: ['**/*.test.mjs'],
141- testTimeout: 30000,
142- testEnvironment: 'node'
143- };
144- EOF
145-
146- npx jest fuzz.test.mjs
137+ node --test fuzz.test.mjs
0 commit comments