diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 96000dd6ea..c535b294ab 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -7,5 +7,7 @@ on: jobs: unit: uses: ./.github/workflows/_unit.yml + fuzz: + uses: ./.github/workflows/_fuzz.yml e2e: uses: ./.github/workflows/_e2e.yml diff --git a/_develop/karma.fuzz.config.js b/_develop/karma.fuzz.config.js index 8682cce7ab..04f705dfc4 100644 --- a/_develop/karma.fuzz.config.js +++ b/_develop/karma.fuzz.config.js @@ -9,5 +9,11 @@ module.exports = config => { frameworks: ['jasmine'], reporters: ['progress'], browsers: ['jsdom'], + singleRun: true, + browserNoActivityTimeout: 120000, + browserDisconnectTimeout: 120000, + browserDisconnectTolerance: 3, + browserSocketTimeout: 120000, + captureTimeout: 120000, }); }; diff --git a/test/fuzz/editor.test.ts b/test/fuzz/editor.test.ts index f1924c0553..c7698496cf 100644 --- a/test/fuzz/editor.test.ts +++ b/test/fuzz/editor.test.ts @@ -1,5 +1,5 @@ import Delta, { AttributeMap, Op } from 'quill-delta'; -import { choose, randomInt } from './utils'; +import { choose, randomInt, runFuzz } from './utils'; import { AlignClass } from '../../formats/align'; import { FontClass } from '../../formats/font'; import { SizeClass } from '../../formats/size'; @@ -214,18 +214,18 @@ const generateChange = (doc: Delta, changeCount: number) => { describe('editor', () => { it('setContents()', () => { - for (let i = 0; i < 2000; i += 1) { + runFuzz(() => { const quill = new Quill(document.createElement('div')); const delta = generateDocument(); expect(delta.concat(new Delta().delete(1))).toEqual( quill.setContents(delta), ); - } + }); }); it('updateContents()', () => { - for (let i = 0; i < 100; i += 1) { + runFuzz(() => { const quill = new Quill(document.createElement('div')); const delta = generateDocument(); quill.setContents(delta); @@ -236,6 +236,6 @@ describe('editor', () => { const diff = quill.updateContents(change); expect(change).toEqual(diff); } - } + }); }); }); diff --git a/test/fuzz/utils.ts b/test/fuzz/utils.ts index 652580e2f3..fdc761e4d4 100644 --- a/test/fuzz/utils.ts +++ b/test/fuzz/utils.ts @@ -5,3 +5,10 @@ export function randomInt(max: number) { export function choose(choices: T[]): T { return choices[randomInt(choices.length)]; } + +export function runFuzz(testCase: () => void) { + const start = performance.now(); + do { + testCase(); + } while (performance.now() - start > 30 * 1000); +}