Skip to content

Commit

Permalink
✅ Explicitely import from Vitest (#4863)
Browse files Browse the repository at this point in the history
Let's drop the automatic globals being pushed by Vitest and move towards
and explicit import of them!
  • Loading branch information
dubzzz authored Apr 7, 2024
1 parent fea62bd commit 154e195
Show file tree
Hide file tree
Showing 220 changed files with 527 additions and 340 deletions.
8 changes: 8 additions & 0 deletions .yarn/versions/8d100249.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
releases:
fast-check: patch

declined:
- "@fast-check/ava"
- "@fast-check/jest"
- "@fast-check/vitest"
- "@fast-check/worker"
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/AsyncScheduler.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import fc from '../../src/fast-check';
import { seed } from './seed';

Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/Bundle.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import { __commitHash } from 'fast-check';

describe(`Bundle`, () => {
Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/ComplexShrink.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../src/fast-check';
import { seed } from './seed';

Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/GenerateAllValues.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest';
import * as prand from 'pure-rand';
import * as fc from '../../src/fast-check';
import { seed } from './seed';
Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/GlobalParameters.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { afterEach, beforeEach, describe, it, expect } from 'vitest';
import * as fc from '../../src/fast-check';

describe('GlobalParameters', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/IgnoreEqualValues.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import { seed } from './seed';
import * as fc from '../../src/fast-check';

Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/ModelBased.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../src/fast-check';
import { seed } from './seed';

Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/NoRegression.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import fc from '../../src/fast-check';
import { asyncRunWithSanitizedStack, runWithSanitizedStack } from './__test-helpers__/StackSanitizer';
import {
Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/NoRegressionBigInt.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import fc from '../../src/fast-check';
import { runWithSanitizedStack } from './__test-helpers__/StackSanitizer';
//declare function BigInt(n: number | bigint | string): bigint;
Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/NoRegressionStack.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import fc from '../../src/fast-check';
import { runWithSanitizedStack } from './__test-helpers__/StackSanitizer';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../src/fast-check';
import { seed } from './seed';
import * as prand from 'pure-rand';
Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/Poisoning.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../src/fast-check';
import { seed } from './seed';
import { type } from 'os';
Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/PreConditionChecks.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../src/fast-check';
import { seed } from './seed';

Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/RandomEnough.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../src/fast-check';
import { seed } from './seed';

Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/RecursiveStructures.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../src/fast-check';
import { seed } from './seed';

Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/ReplayCommands.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../src/fast-check';
import * as prand from 'pure-rand';
import { seed } from './seed';
Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/ReplayFailures.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../src/fast-check';
import { seed } from './seed';

Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/Sampler.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../src/fast-check';
import { seed } from './seed';

Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/Shadows.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../src/fast-check';
import { seed } from './seed';

Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/SkipAllAfterTime.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../src/fast-check';
import { seed } from './seed';

Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/StateFullArbitraries.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../src/fast-check';
import { seed } from './seed';

Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/Timeout.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect, vi } from 'vitest';
import * as fc from '../../src/fast-check';
import { seed } from './seed';

Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/VerbosityChecks.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../src/fast-check';
import { seed } from './seed';

Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/WithProvidedExamples.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../src/fast-check';
import { seed } from './seed';

Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/arbitraries/Arbitrary.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { seed } from '../seed';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { seed } from '../seed';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { seed } from '../seed';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { seed } from '../seed';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { seed } from '../seed';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { seed } from '../seed';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { seed } from '../seed';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { seed } from '../seed';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { seed } from '../seed';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { seed } from '../seed';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { seed } from '../seed';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { seed } from '../seed';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { seed } from '../seed';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { seed } from '../seed';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { seed } from '../seed';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { seed } from '../seed';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { seed } from '../seed';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { seed } from '../seed';
import { URL } from 'url';
Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/documentation/Docs.md.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fs from 'fs';
import fc from '../../../src/fast-check';
import { globSync } from 'glob';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from '../../../src/fast-check';
import { FailureCommand, SuccessCommand } from './StepCommands';
import {
Expand Down
1 change: 1 addition & 0 deletions packages/fast-check/test/e2e/model/CounterCommands.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type * as fc from '../../../src/fast-check';
import { expect } from 'vitest';

type M1 = { count: number };
type R1 = unknown;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect } from 'vitest';
import * as prand from 'pure-rand';
import * as fc from 'fast-check';
import { assertNoPoisoning, restoreGlobals } from '@fast-check/poisoning';
Expand All @@ -11,9 +12,9 @@ import { sizeArb } from './SizeHelpers';
function poisoningAfterEach(nestedAfterEach: () => void) {
nestedAfterEach();
try {
assertNoPoisoning({ ignoredRootRegex: /^(__coverage__|console|expect|__vitest_[a-z]+__|__VITEST_[A-Z]+__)$/ });
assertNoPoisoning({ ignoredRootRegex: /^(__vitest_[a-z]+__|__VITEST_[A-Z]+__)$/ });
} catch (err) {
restoreGlobals({ ignoredRootRegex: /^(__coverage__|console|expect|__vitest_[a-z]+__|__VITEST_[A-Z]+__)$/ });
restoreGlobals({ ignoredRootRegex: /^(__vitest_[a-z]+__|__VITEST_[A-Z]+__)$/ });
throw err;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { vi } from 'vitest';
import type { MaybeMocked, MockWithArgs } from '../../__test-helpers__/Mocked';
import { Arbitrary } from '../../../../src/check/arbitrary/definition/Arbitrary';
import { Value } from '../../../../src/check/arbitrary/definition/Value';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { vi } from 'vitest';
import type { MaybeMocked } from '../../__test-helpers__/Mocked';
import { Random } from '../../../../src/random/generator/Random';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { expect } from 'vitest';
import { hash } from '../../../../src/utils/hash';
import { stringify } from '../../../../src/utils/stringify';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect, vi } from 'vitest';
import type { AdapterOutput } from '../../../../src/arbitrary/_internals/AdapterArbitrary';
import { adapter } from '../../../../src/arbitrary/_internals/AdapterArbitrary';
import { Value } from '../../../../src/check/arbitrary/definition/Value';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeEach, describe, it, expect, vi } from 'vitest';
import fc from 'fast-check';
import prand from 'pure-rand';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from 'fast-check';

import { arrayInt64 } from '../../../../src/arbitrary/_internals/ArrayInt64Arbitrary';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeEach, describe, it, expect, vi } from 'vitest';
import * as fc from 'fast-check';
import { BigIntArbitrary } from '../../../../src/arbitrary/_internals/BigIntArbitrary';
import { Value } from '../../../../src/check/arbitrary/definition/Value';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect, vi } from 'vitest';
import fc from 'fast-check';
import { CloneArbitrary } from '../../../../src/arbitrary/_internals/CloneArbitrary';
import { Arbitrary } from '../../../../src/check/arbitrary/definition/Arbitrary';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect, vi } from 'vitest';
import fc from 'fast-check';
import { ConstantArbitrary } from '../../../../src/arbitrary/_internals/ConstantArbitrary';
import { fakeRandom } from '../__test-helpers__/RandomHelpers';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeEach, describe, it, expect, vi } from 'vitest';
import * as fc from 'fast-check';
import type { _Constraints } from '../../../../src/arbitrary/_internals/FrequencyArbitrary';
import { FrequencyArbitrary } from '../../../../src/arbitrary/_internals/FrequencyArbitrary';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeEach, describe, it, expect, vi } from 'vitest';
import * as fc from 'fast-check';
import type { _Constraints } from '../../../../src/arbitrary/_internals/FrequencyArbitrary';
import { FrequencyArbitrary } from '../../../../src/arbitrary/_internals/FrequencyArbitrary';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import { GeneratorArbitrary } from '../../../../src/arbitrary/_internals/GeneratorArbitrary';
import { Value } from '../../../../src/check/arbitrary/definition/Value';
import type { Random } from '../../../../src/random/generator/Random';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeEach, describe, it, expect, vi } from 'vitest';
import type { MockInstance } from 'vitest';
import * as fc from 'fast-check';
import { IntegerArbitrary } from '../../../../src/arbitrary/_internals/IntegerArbitrary';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import { LazyArbitrary } from '../../../../src/arbitrary/_internals/LazyArbitrary';
import { Value } from '../../../../src/check/arbitrary/definition/Value';
import { Stream } from '../../../../src/stream/Stream';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeEach, describe, it, expect, vi } from 'vitest';
import fc from 'fast-check';
import {
assertProduceValuesShrinkableWithoutContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeEach, describe, it, expect, vi } from 'vitest';
import { SchedulerArbitrary } from '../../../../src/arbitrary/_internals/SchedulerArbitrary';
import { fakeRandom } from '../__test-helpers__/RandomHelpers';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeEach, describe, it, expect, vi } from 'vitest';
import * as fc from 'fast-check';
import { StreamArbitrary } from '../../../../src/arbitrary/_internals/StreamArbitrary';
import { Value } from '../../../../src/check/arbitrary/definition/Value';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeEach, describe, it, expect, vi } from 'vitest';
import * as fc from 'fast-check';
import { SubarrayArbitrary } from '../../../../src/arbitrary/_internals/SubarrayArbitrary';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect, vi } from 'vitest';
import { TupleArbitrary } from '../../../../src/arbitrary/_internals/TupleArbitrary';
import { Value } from '../../../../src/check/arbitrary/definition/Value';
import { FakeIntegerArbitrary, fakeArbitrary } from '../__test-helpers__/ArbitraryHelpers';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import { WithShrinkFromOtherArbitrary } from '../../../../src/arbitrary/_internals/WithShrinkFromOtherArbitrary';
import { Value } from '../../../../src/check/arbitrary/definition/Value';
import { fakeArbitrary } from '../__test-helpers__/ArbitraryHelpers';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import fc from 'fast-check';

import { anyArbitraryBuilder } from '../../../../../src/arbitrary/_internals/builders/AnyArbitraryBuilder';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeEach, describe, it, expect, vi } from 'vitest';
import { fakeArbitrary } from '../../__test-helpers__/ArbitraryHelpers';
import { buildPartialRecordArbitrary } from '../../../../../src/arbitrary/_internals/builders/PartialRecordArbitraryBuilder';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeEach, describe, it, expect, vi } from 'vitest';
import * as fc from 'fast-check';
import { typedIntArrayArbitraryArbitraryBuilder } from '../../../../../src/arbitrary/_internals/builders/TypedIntArrayArbitraryBuilder';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from 'fast-check';

import type { ArrayInt64 } from '../../../../../src/arbitrary/_internals/helpers/ArrayInt64';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from 'fast-check';
import {
biasNumericRange,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { beforeEach, describe, it, expect, vi } from 'vitest';
import { buildSchedulerFor } from '../../../../../src/arbitrary/_internals/helpers/BuildSchedulerFor';

import * as SchedulerImplemMock from '../../../../../src/arbitrary/_internals/implementations/SchedulerImplem';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from 'fast-check';
import { CustomEqualSet } from '../../../../../src/arbitrary/_internals/helpers/CustomEqualSet';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from 'fast-check';

import { float64raw, isStrictlySmaller } from '../../__test-helpers__/FloatingPointHelpers';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect } from 'vitest';
import * as fc from 'fast-check';

import {
Expand Down
Loading

0 comments on commit 154e195

Please sign in to comment.