Skip to content

Commit 6e55fac

Browse files
authored
Fix typedIntArrayArbitraryArbitraryBuilder
1 parent f2be5b8 commit 6e55fac

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

packages/fast-check/test/unit/arbitrary/_internals/builders/TypedIntArrayArbitraryBuilder.spec.ts

+27-11
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
1+
import { jest } from '@jest/globals';
12
import * as fc from 'fast-check';
2-
import { typedIntArrayArbitraryArbitraryBuilder } from '../../../../../src/arbitrary/_internals/builders/TypedIntArrayArbitraryBuilder';
33

4-
import { FakeIntegerArbitrary, fakeArbitrary, fakeArbitraryStaticValue } from '../../__test-helpers__/ArbitraryHelpers';
4+
jest.unstable_mockModule('./src/arbitrary/array', () => ({
5+
array: jest.fn(),
6+
}));
57

6-
import * as ArrayMock from '../../../../../src/arbitrary/array';
7-
import {
8+
const { typedIntArrayArbitraryArbitraryBuilder } = await import(
9+
'../../../../../src/arbitrary/_internals/builders/TypedIntArrayArbitraryBuilder'
10+
);
11+
12+
const { FakeIntegerArbitrary, fakeArbitrary, fakeArbitraryStaticValue } = await import(
13+
'../../__test-helpers__/ArbitraryHelpers'
14+
);
15+
const {
816
assertProduceCorrectValues,
917
assertProduceSameValueGivenSameSeed,
1018
assertProduceValuesShrinkableWithoutContext,
1119
assertShrinkProducesSameValueWithoutInitialContext,
12-
} from '../../__test-helpers__/ArbitraryAssertions';
20+
} = await import('../../__test-helpers__/ArbitraryAssertions');
1321

14-
function beforeEachHook() {
15-
jest.resetModules();
16-
jest.restoreAllMocks();
17-
fc.configureGlobal({ beforeEach: beforeEachHook });
18-
}
19-
beforeEach(beforeEachHook);
22+
const ArrayMock = await import('../../../../../src/arbitrary/array');
2023

2124
describe('typedIntArrayArbitraryArbitraryBuilder', () => {
25+
function beforeEachHook() {
26+
jest.resetAllMocks();
27+
}
28+
fc.configureGlobal({ beforeEach: beforeEachHook });
29+
beforeEach(beforeEachHook);
30+
2231
it('should default constraints for arbitraryBuilder to defaultMin/Max when not specified', () => {
2332
fc.assert(
2433
fc.property(
@@ -123,6 +132,13 @@ describe('typedIntArrayArbitraryArbitraryBuilder', () => {
123132
});
124133

125134
describe('typedIntArrayArbitraryArbitraryBuilder (integration)', () => {
135+
function beforeEachHook() {
136+
jest.resetAllMocks();
137+
jest.spyOn(ArrayMock, 'array').mockImplementation(jest.requireActual('./lib/cjs/arbitrary/array').array);
138+
}
139+
fc.configureGlobal({ beforeEach: beforeEachHook });
140+
beforeEach(beforeEachHook);
141+
126142
type Extra = { minLength?: number; maxLength?: number; min?: number; max?: number };
127143
const extraParameters: fc.Arbitrary<Extra> = fc
128144
.record(

0 commit comments

Comments
 (0)