From c43ae849a913f60c22b5adbdd9c22d819db7f2f8 Mon Sep 17 00:00:00 2001 From: ealush Date: Sat, 27 Jul 2024 02:56:03 +0300 Subject: [PATCH 01/16] update imports --- package.json | 4 +- packages/anyone/src/__tests__/all.test.ts | 22 +- packages/anyone/src/__tests__/any.test.ts | 26 +- packages/anyone/src/__tests__/none.test.ts | 26 +- packages/anyone/src/__tests__/one.test.ts | 26 +- .../src/__tests__/runAnyoneMethods.test.ts | 14 +- packages/anyone/src/exports/all.ts | 2 +- packages/anyone/src/exports/any.ts | 2 +- packages/anyone/src/exports/none.ts | 2 +- packages/anyone/src/exports/one.ts | 2 +- packages/anyone/tsconfig.json | 8 +- packages/context/tsconfig.json | 3 +- packages/n4s/src/__tests__/enforce.test.ts | 14 +- .../n4s/src/__tests__/enforceEager.test.ts | 2 +- .../n4s/src/exports/__tests__/compose.test.ts | 32 +- packages/n4s/src/exports/compose.ts | 14 +- packages/n4s/src/exports/compounds.ts | 14 +- packages/n4s/src/exports/date.ts | 2 +- packages/n4s/src/exports/email.ts | 2 +- packages/n4s/src/exports/isURL.ts | 2 +- packages/n4s/src/exports/schema.ts | 13 +- packages/n4s/src/lib/runLazyRule.ts | 8 +- packages/n4s/src/lib/transformResult.ts | 8 +- packages/n4s/src/n4s.ts | 4 +- .../plugins/compounds/__tests__/allOf.test.ts | 8 +- .../compounds/__tests__/noneOf.test.ts | 11 +- .../plugins/compounds/__tests__/oneOf.test.ts | 8 +- packages/n4s/src/plugins/compounds/allOf.ts | 10 +- packages/n4s/src/plugins/compounds/anyOf.ts | 10 +- packages/n4s/src/plugins/compounds/noneOf.ts | 10 +- packages/n4s/src/plugins/compounds/oneOf.ts | 8 +- .../schema/__tests__/isArrayOf.test.ts | 34 +- .../plugins/schema/__tests__/loose.test.ts | 6 +- .../plugins/schema/__tests__/optional.test.ts | 22 +- .../plugins/schema/__tests__/partial.test.ts | 40 +- .../schema/__tests__/shape&loose.test.ts | 4 +- .../plugins/schema/__tests__/shape.test.ts | 6 +- packages/n4s/src/plugins/schema/isArrayOf.ts | 14 +- packages/n4s/src/plugins/schema/loose.ts | 13 +- packages/n4s/src/plugins/schema/optional.ts | 8 +- .../n4s/src/plugins/schema/schemaTypes.ts | 2 +- packages/n4s/src/plugins/schema/shape.ts | 11 +- .../n4s/src/rules/__tests__/endsWith.test.ts | 4 +- .../n4s/src/rules/__tests__/equals.test.ts | 2 +- .../__tests__/greaterThanOrEquals.test.ts | 4 +- .../n4s/src/rules/__tests__/inside.test.ts | 6 +- .../n4s/src/rules/__tests__/isBetween.test.ts | 2 +- .../n4s/src/rules/__tests__/isBlank.test.ts | 2 +- .../n4s/src/rules/__tests__/isBoolean.test.ts | 2 +- .../n4s/src/rules/__tests__/isEven.test.ts | 2 +- .../n4s/src/rules/__tests__/isKeyOf.test.ts | 7 +- .../n4s/src/rules/__tests__/isNaN.test.ts | 2 +- .../src/rules/__tests__/isNegative.test.ts | 2 +- .../n4s/src/rules/__tests__/isNumber.test.ts | 2 +- .../n4s/src/rules/__tests__/isOdd.test.ts | 2 +- .../n4s/src/rules/__tests__/isTruthy.test.ts | 2 +- .../n4s/src/rules/__tests__/isValueOf.test.ts | 5 +- .../n4s/src/rules/__tests__/lessThan.test.ts | 4 +- .../rules/__tests__/lessThanOrEquals.test.ts | 4 +- .../__tests__/longerThanOrEquals.test.ts | 2 +- .../n4s/src/rules/__tests__/matches.test.ts | 2 +- .../src/rules/__tests__/ruleCondition.test.ts | 10 +- .../n4s/src/rules/__tests__/rules.test.ts | 2 +- .../src/rules/__tests__/shorterThan.test.ts | 2 +- .../__tests__/shorterThanOrEquals.test.ts | 2 +- .../src/rules/__tests__/startsWith.test.ts | 2 +- packages/n4s/src/rules/isBetween.ts | 6 +- packages/n4s/src/rules/isEven.ts | 2 +- packages/n4s/src/rules/isNegative.ts | 2 +- packages/n4s/src/rules/isOdd.ts | 2 +- packages/n4s/src/rules/lessThanOrEquals.ts | 4 +- packages/n4s/src/rules/longerThanOrEquals.ts | 4 +- packages/n4s/src/rules/ruleCondition.ts | 4 +- packages/n4s/src/rules/shorterThan.ts | 4 +- packages/n4s/src/rules/shorterThanOrEquals.ts | 4 +- .../runtime/__tests__/enforceContext.test.ts | 18 +- .../n4s/src/runtime/__tests__/message.test.ts | 16 +- packages/n4s/src/runtime/enforce.ts | 9 +- packages/n4s/src/runtime/enforceEager.ts | 6 +- packages/n4s/src/runtime/genEnforceLazy.ts | 19 +- packages/n4s/src/runtime/rules.ts | 48 +- packages/n4s/src/runtime/runtimeRules.ts | 4 +- packages/n4s/tsconfig.json | 53 +- packages/vast/tsconfig.json | 3 +- packages/vest-utils/src/Predicates.ts | 6 +- packages/vest-utils/src/SimpleStateMachine.ts | 4 +- packages/vest-utils/src/StringObject.ts | 4 +- .../src/__tests__/Predicates.test.ts | 20 +- .../src/__tests__/SimpleStateMachine.test.ts | 2 +- .../src/__tests__/StringObject.test.ts | 2 +- .../vest-utils/src/__tests__/asArray.test.ts | 2 +- packages/vest-utils/src/__tests__/bus.test.ts | 2 +- .../vest-utils/src/__tests__/callEach.test.ts | 2 +- .../vest-utils/src/__tests__/either.test.ts | 2 +- .../src/__tests__/greaterThan.test.ts | 4 +- .../vest-utils/src/__tests__/isArray.test.ts | 2 +- .../src/__tests__/isBoolean.test.ts | 2 +- .../vest-utils/src/__tests__/isNull.test.ts | 2 +- .../src/__tests__/isNumeric.test.ts | 2 +- .../src/__tests__/isPositive.test.ts | 2 +- .../src/__tests__/isPromise.test.ts | 2 +- .../vest-utils/src/__tests__/isString.test.ts | 2 +- .../src/__tests__/isUndefined.test.ts | 2 +- .../src/__tests__/lengthEquals.test.ts | 2 +- .../src/__tests__/longerThan.test.ts | 2 +- .../src/__tests__/nonnullish.test.ts | 2 +- .../src/__tests__/numberEquals.test.ts | 4 +- packages/vest-utils/src/__tests__/seq.test.ts | 2 +- .../vest-utils/src/__tests__/text.test.ts | 6 +- .../src/__tests__/tinyState.test.ts | 2 +- packages/vest-utils/src/bus.ts | 2 +- packages/vest-utils/src/cache.ts | 10 +- packages/vest-utils/src/callEach.ts | 2 +- packages/vest-utils/src/defaultTo.ts | 6 +- .../exports/__tests__/minifyObject.test.ts | 2 +- .../vest-utils/src/exports/minifyObject.ts | 14 +- packages/vest-utils/src/freezeAssign.ts | 2 +- packages/vest-utils/src/greaterThan.ts | 4 +- packages/vest-utils/src/invariant.ts | 6 +- packages/vest-utils/src/isArrayValue.ts | 2 +- packages/vest-utils/src/isEmpty.ts | 9 +- packages/vest-utils/src/isNull.ts | 2 +- packages/vest-utils/src/isNullish.ts | 8 +- packages/vest-utils/src/isNumeric.ts | 2 +- packages/vest-utils/src/isPositive.ts | 2 +- packages/vest-utils/src/isPromise.ts | 2 +- packages/vest-utils/src/isUndefined.ts | 2 +- packages/vest-utils/src/lengthEquals.ts | 6 +- packages/vest-utils/src/longerThan.ts | 4 +- packages/vest-utils/src/nonnullish.ts | 7 +- packages/vest-utils/src/numberEquals.ts | 6 +- .../vest-utils/src/optionalFunctionValue.ts | 4 +- packages/vest-utils/src/seq.ts | 2 +- packages/vest-utils/src/text.ts | 4 +- packages/vest-utils/src/tinyState.ts | 8 +- packages/vest-utils/src/valueIsObject.ts | 2 +- packages/vest-utils/src/vest-utils.ts | 82 +- packages/vest-utils/tsconfig.json | 44 +- .../__tests__/integration.async-tests.test.ts | 4 +- .../__tests__/integration.exclusive.test.ts | 2 +- .../integration.stateful-async.test.ts | 10 +- .../integration.stateful-tests.test.ts | 6 +- .../vest/src/__tests__/state_refill.test.ts | 2 +- packages/vest/src/core/Runtime.ts | 17 +- .../StateMachines/IsolateTestStateMachine.ts | 2 +- packages/vest/src/core/VestBus/VestBus.ts | 23 +- .../vest/src/core/context/SuiteContext.ts | 6 +- .../core/isolate/IsolateEach/IsolateEach.ts | 4 +- .../core/isolate/IsolateSuite/IsolateSuite.ts | 9 +- .../core/isolate/IsolateTest/IsolateTest.ts | 25 +- .../IsolateTest/IsolateTestReconciler.ts | 15 +- .../core/isolate/IsolateTest/TestWalker.ts | 8 +- .../src/core/isolate/IsolateTest/VestTest.ts | 25 +- .../__tests__/VestTestInspector.test.ts | 8 +- .../__tests__/hasRemainingTests.test.ts | 2 +- .../cancelOverriddenPendingTest.ts | 8 +- .../isolate/IsolateTest/isSameProfileTest.ts | 6 +- packages/vest/src/core/isolate/VestIsolate.ts | 2 +- .../vest/src/core/isolate/VestReconciler.ts | 2 +- packages/vest/src/core/test/TestTypes.ts | 2 +- .../core/test/__tests__/IsolateTest.test.ts | 6 +- .../vest/src/core/test/__tests__/key.test.ts | 2 +- .../vest/src/core/test/__tests__/memo.test.ts | 22 +- .../merging_of_previous_test_runs.test.ts | 10 +- .../core/test/__tests__/runAsyncTest.test.ts | 6 +- .../vest/src/core/test/__tests__/test.test.ts | 8 +- .../nonMatchingSeverityProfile.test.ts | 18 +- .../core/test/helpers/matchingFieldName.ts | 4 +- .../core/test/helpers/matchingGroupName.ts | 8 +- .../helpers/nonMatchingSeverityProfile.ts | 8 +- packages/vest/src/core/test/test.memo.ts | 18 +- packages/vest/src/core/test/test.ts | 30 +- .../core/test/testLevelFlowControl/runTest.ts | 16 +- .../testLevelFlowControl/verifyTestRun.ts | 17 +- packages/vest/src/exports/SuiteSerializer.ts | 6 +- .../exports/__tests__/SuiteSerializer.test.ts | 3 +- .../src/exports/__tests__/classnames.test.ts | 26 +- .../src/exports/__tests__/debounce.test.ts | 2 +- .../vest/src/exports/__tests__/parser.test.ts | 122 +-- .../src/exports/__tests__/promisify.test.ts | 8 +- packages/vest/src/exports/classnames.ts | 10 +- packages/vest/src/exports/debounce.ts | 4 +- packages/vest/src/exports/parser.ts | 6 +- packages/vest/src/exports/promisify.ts | 6 +- .../vest/src/hooks/__tests__/include.test.ts | 2 +- .../vest/src/hooks/__tests__/mode.test.ts | 4 +- .../vest/src/hooks/__tests__/warn.test.ts | 4 +- packages/vest/src/hooks/focused/focused.ts | 13 +- .../src/hooks/focused/useHasOnliedTests.ts | 10 +- .../vest/src/hooks/focused/useIsExcluded.ts | 14 +- packages/vest/src/hooks/include.ts | 21 +- .../vest/src/hooks/optional/OptionalTypes.ts | 2 +- .../hooks/optional/__tests__/optional.test.ts | 4 +- packages/vest/src/hooks/optional/mode.ts | 8 +- .../src/hooks/optional/omitOptionalFields.ts | 15 +- packages/vest/src/hooks/optional/optional.ts | 14 +- packages/vest/src/hooks/warn.ts | 6 +- .../src/isolates/__tests__/omitWhen.test.ts | 2 +- .../src/isolates/__tests__/skipWhen.test.ts | 2 +- packages/vest/src/isolates/each.ts | 8 +- packages/vest/src/isolates/group.ts | 7 +- packages/vest/src/isolates/omitWhen.ts | 16 +- packages/vest/src/isolates/skipWhen.ts | 16 +- packages/vest/src/suite/SuiteTypes.ts | 11 +- packages/vest/src/suite/SuiteWalker.ts | 12 +- .../vest/src/suite/__tests__/create.test.ts | 6 +- .../vest/src/suite/__tests__/remove.test.ts | 2 +- .../src/suite/__tests__/resetField.test.ts | 2 +- .../src/suite/__tests__/staticSuite.test.ts | 4 +- .../src/suite/__tests__/subscribe.test.ts | 2 +- .../__tests__/suiteSelectorsOnSuite.test.ts | 18 +- packages/vest/src/suite/createSuite.ts | 33 +- packages/vest/src/suite/getTypedMethods.ts | 33 +- packages/vest/src/suite/runCallbacks.ts | 6 +- .../validateParams/validateSuiteParams.ts | 8 +- .../vest/src/suiteResult/SuiteResultTypes.ts | 8 +- .../vest/src/suiteResult/SummaryFailure.ts | 12 +- .../__tests__/useProduceSuiteSummary.test.ts | 2 +- .../src/suiteResult/done/deferDoneCallback.ts | 12 +- .../done/shouldSkipDoneRegistration.ts | 6 +- .../__tests__/collectFailureMessages.test.ts | 6 +- .../selectors/__tests__/getFailures.test.ts | 2 +- .../__tests__/getFailuresByGroup.test.ts | 12 +- .../__tests__/hasFailuresByGroup.test.ts | 6 +- .../__tests__/hasFailuresByTestObject.test.ts | 10 +- .../selectors/__tests__/isValid.test.ts | 20 +- .../__tests__/isValidByGroup.test.ts | 32 +- .../__tests__/summaryFailures.test.ts | 2 +- .../suiteResult/selectors/collectFailures.ts | 10 +- .../selectors/hasFailuresByTestObjects.ts | 18 +- .../selectors/shouldAddValidProperty.ts | 27 +- .../suiteResult/selectors/suiteSelectors.ts | 11 +- .../selectors/useProduceSuiteSummary.ts | 12 +- packages/vest/src/suiteResult/suiteResult.ts | 13 +- .../vest/src/suiteResult/suiteRunResult.ts | 11 +- packages/vest/src/testUtils/TVestMock.ts | 2 +- packages/vest/src/testUtils/suiteDummy.ts | 14 +- packages/vest/src/testUtils/vestMocks.ts | 10 +- packages/vest/src/vest.ts | 32 +- packages/vest/tsconfig.json | 106 +- packages/vestjs-runtime/src/Bus.ts | 2 +- .../vestjs-runtime/src/Isolate/Isolate.ts | 11 +- .../src/Isolate/IsolateInspector.ts | 6 +- .../src/Isolate/IsolateMutator.ts | 2 +- .../src/Isolate/IsolateSelectors.ts | 10 +- .../src/Isolate/__tests__/Isolate.test.ts | 8 +- .../__tests__/IsolateInspector.test.ts | 4 +- .../Isolate/__tests__/IsolateMutator.test.ts | 4 +- .../Isolate/__tests__/asyncIsolate.test.ts | 16 +- packages/vestjs-runtime/src/IsolateWalker.ts | 4 +- packages/vestjs-runtime/src/Reconciler.ts | 16 +- packages/vestjs-runtime/src/VestRuntime.ts | 13 +- .../src/__tests__/IsolateWalker.test.ts | 4 +- .../src/exports/IsolateSerializer.ts | 15 +- .../__tests__/IsolateSerializer.test.ts | 23 +- .../vestjs-runtime/src/exports/test-utils.ts | 4 +- packages/vestjs-runtime/src/vestjs-runtime.ts | 20 +- packages/vestjs-runtime/tsconfig.json | 16 +- tsconfig.json | 1 - vitest.config.ts | 21 + vx/config/jest/jest.config.js | 14 +- vx/config/rollup/rollup.config.cjs | 18 +- vx/scripts/genTsConfig.js | 9 +- yarn.lock | 936 +++++++++++++++++- 264 files changed, 2171 insertions(+), 1354 deletions(-) create mode 100644 vitest.config.ts diff --git a/package.json b/package.json index 8ae24f7aa..314ee3981 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "devDependencies": { "@faker-js/faker": "^8.4.1", "@types/jest": "^29.5.12", - "@types/lodash": "^4.17.5", + "@types/lodash": "^4.17.7", "@typescript-eslint/eslint-plugin": "^6.21.0", "@typescript-eslint/parser": "^6.21.0", "eslint": "^8.57.0", @@ -38,6 +38,8 @@ "tsc": "^2.0.4", "tslib": "^2.6.3", "typescript": "^4.9.5", + "vite-tsconfig-paths": "^4.3.2", + "vitest": "^2.0.4", "vx": "workspace:*", "wait": "^0.4.2" }, diff --git a/packages/anyone/src/__tests__/all.test.ts b/packages/anyone/src/__tests__/all.test.ts index b8ff286fd..29007135d 100644 --- a/packages/anyone/src/__tests__/all.test.ts +++ b/packages/anyone/src/__tests__/all.test.ts @@ -1,8 +1,8 @@ import { sample, random } from 'lodash'; -import { TRUTHY_VALUES, FALSY_VALUES } from './anyoneTestValues'; +import all from '../exports/all'; -import all from 'all'; +import { TRUTHY_VALUES, FALSY_VALUES } from './anyoneTestValues'; describe('methods/all', () => { describe('When only falsy values', () => { @@ -10,9 +10,9 @@ describe('methods/all', () => { expect( all( ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) - ) - ) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), + ), + ), ).toBe(false); }); }); @@ -22,9 +22,9 @@ describe('methods/all', () => { expect( all( ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES) - ) - ) + i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES), + ), + ), ).toBe(true); }); }); @@ -34,12 +34,12 @@ describe('methods/all', () => { expect( all.apply(null, [ ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), ), ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES) + i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES), ), - ]) + ]), ).toBe(false); }); }); diff --git a/packages/anyone/src/__tests__/any.test.ts b/packages/anyone/src/__tests__/any.test.ts index 2a3de7fc2..4d3084130 100644 --- a/packages/anyone/src/__tests__/any.test.ts +++ b/packages/anyone/src/__tests__/any.test.ts @@ -1,8 +1,8 @@ import { sample, random } from 'lodash'; -import { TRUTHY_VALUES, FALSY_VALUES } from './anyoneTestValues'; +import any from '../exports/any'; -import any from 'any'; +import { TRUTHY_VALUES, FALSY_VALUES } from './anyoneTestValues'; describe('methods/any', () => { describe('When only falsy values', () => { @@ -10,9 +10,9 @@ describe('methods/any', () => { expect( any( ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) - ) - ) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), + ), + ), ).toBe(false); }); }); @@ -22,9 +22,9 @@ describe('methods/any', () => { expect( any( ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES) - ) - ) + i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES), + ), + ), ).toBe(true); }); }); @@ -34,10 +34,10 @@ describe('methods/any', () => { expect( any.apply(null, [ ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), ), sample(TRUTHY_VALUES), - ]) + ]), ).toBe(true); }); }); @@ -47,12 +47,12 @@ describe('methods/any', () => { expect( any.apply(null, [ ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), ), ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES) + i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES), ), - ]) + ]), ).toBe(true); }); }); diff --git a/packages/anyone/src/__tests__/none.test.ts b/packages/anyone/src/__tests__/none.test.ts index 86aad6105..e75819457 100644 --- a/packages/anyone/src/__tests__/none.test.ts +++ b/packages/anyone/src/__tests__/none.test.ts @@ -1,8 +1,8 @@ import { sample, random } from 'lodash'; -import { TRUTHY_VALUES, FALSY_VALUES } from './anyoneTestValues'; +import none from '../exports/none'; -import none from 'none'; +import { TRUTHY_VALUES, FALSY_VALUES } from './anyoneTestValues'; describe('methods/none', () => { describe('When only falsy values', () => { @@ -10,9 +10,9 @@ describe('methods/none', () => { expect( none( ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) - ) - ) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), + ), + ), ).toBe(true); }); }); @@ -22,9 +22,9 @@ describe('methods/none', () => { expect( none( ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES) - ) - ) + i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES), + ), + ), ).toBe(false); }); }); @@ -34,10 +34,10 @@ describe('methods/none', () => { expect( none.apply(null, [ ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), ), sample(TRUTHY_VALUES), - ]) + ]), ).toBe(false); }); }); @@ -47,12 +47,12 @@ describe('methods/none', () => { expect( none.apply(null, [ ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), ), ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES) + i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES), ), - ]) + ]), ).toBe(false); }); }); diff --git a/packages/anyone/src/__tests__/one.test.ts b/packages/anyone/src/__tests__/one.test.ts index a8367619c..50349cbf3 100644 --- a/packages/anyone/src/__tests__/one.test.ts +++ b/packages/anyone/src/__tests__/one.test.ts @@ -1,8 +1,8 @@ import { sample, random } from 'lodash'; -import { TRUTHY_VALUES, FALSY_VALUES } from './anyoneTestValues'; +import one from '../exports/one'; -import one from 'one'; +import { TRUTHY_VALUES, FALSY_VALUES } from './anyoneTestValues'; describe('methods/one', () => { describe('When only falsy values', () => { @@ -10,9 +10,9 @@ describe('methods/one', () => { expect( one( ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) - ) - ) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), + ), + ), ).toBe(false); }); }); @@ -22,9 +22,9 @@ describe('methods/one', () => { expect( one( ...Array.from({ length: random(2, 10) }, (_, i) => - i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES) - ) - ) + i % 2 === 0 ? sample(TRUTHY_VALUES) : sample(TRUTHY_VALUES), + ), + ), ).toBe(false); }); }); @@ -34,10 +34,10 @@ describe('methods/one', () => { expect( one( ...Array.from({ length: random(1, 10) }, (_, i) => - i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES) + i % 2 === 0 ? sample(FALSY_VALUES) : sample(FALSY_VALUES), ), - sample(TRUTHY_VALUES) - ) + sample(TRUTHY_VALUES), + ), ).toBe(true); }); }); @@ -47,8 +47,8 @@ describe('methods/one', () => { expect( one( ...Array.from({ length: random(2, 10) }, () => sample(TRUTHY_VALUES)), - ...Array.from({ length: random(1, 10) }, () => sample(FALSY_VALUES)) - ) + ...Array.from({ length: random(1, 10) }, () => sample(FALSY_VALUES)), + ), ).toBe(false); }); }); diff --git a/packages/anyone/src/__tests__/runAnyoneMethods.test.ts b/packages/anyone/src/__tests__/runAnyoneMethods.test.ts index c255744b7..d6576dbc3 100644 --- a/packages/anyone/src/__tests__/runAnyoneMethods.test.ts +++ b/packages/anyone/src/__tests__/runAnyoneMethods.test.ts @@ -1,30 +1,30 @@ -import { FALSY_VALUES, TRUTHY_VALUES } from './anyoneTestValues'; +import run from '../runner/runAnyoneMethods'; -import run from 'runAnyoneMethods'; +import { FALSY_VALUES, TRUTHY_VALUES } from './anyoneTestValues'; describe('lib/run', () => { describe('When value is falsy', () => { it.each([FALSY_VALUES])('Should return `false` ("%s")', value => - expect(run(value)).toBe(false) + expect(run(value)).toBe(false), ); }); describe('When value is truthy', () => { it.each([TRUTHY_VALUES])('Should return `true` ("%s")', value => - expect(run(value)).toBe(true) + expect(run(value)).toBe(true), ); }); describe('When value is a function', () => { describe('When value is falsy', () => { it.each([FALSY_VALUES])('Should return `false` ("%s")', value => - expect(run(() => value)).toBe(false) + expect(run(() => value)).toBe(false), ); }); describe('When value is truthy', () => { it.each([TRUTHY_VALUES])('Should return `true` ("%s")', value => - expect(run(() => value)).toBe(true) + expect(run(() => value)).toBe(true), ); }); }); @@ -34,7 +34,7 @@ describe('lib/run', () => { expect( run(() => { throw new Error(); - }) + }), ).toBe(false); }); }); diff --git a/packages/anyone/src/exports/all.ts b/packages/anyone/src/exports/all.ts index c824b6361..055d73ebc 100644 --- a/packages/anyone/src/exports/all.ts +++ b/packages/anyone/src/exports/all.ts @@ -1,4 +1,4 @@ -import run from 'runAnyoneMethods'; +import run from '../runner/runAnyoneMethods'; /** * Checks that at all passed arguments evaluate to a truthy value. diff --git a/packages/anyone/src/exports/any.ts b/packages/anyone/src/exports/any.ts index 4dce0930f..097c62cc4 100644 --- a/packages/anyone/src/exports/any.ts +++ b/packages/anyone/src/exports/any.ts @@ -1,4 +1,4 @@ -import run from 'runAnyoneMethods'; +import run from '@/runner/runAnyoneMethods'; /** * Checks that at least one passed argument evaluates to a truthy value. diff --git a/packages/anyone/src/exports/none.ts b/packages/anyone/src/exports/none.ts index 22bda5ffc..56ffd34be 100644 --- a/packages/anyone/src/exports/none.ts +++ b/packages/anyone/src/exports/none.ts @@ -1,6 +1,6 @@ import { bindNot } from 'vest-utils'; -import run from 'runAnyoneMethods'; +import run from '../runner/runAnyoneMethods'; /** * Checks that at none of the passed arguments evaluate to a truthy value. diff --git a/packages/anyone/src/exports/one.ts b/packages/anyone/src/exports/one.ts index 8179f4a52..f67c657a7 100644 --- a/packages/anyone/src/exports/one.ts +++ b/packages/anyone/src/exports/one.ts @@ -1,4 +1,4 @@ -import run from 'runAnyoneMethods'; +import run from '@/runner/runAnyoneMethods'; /** * Checks that at only one passed argument evaluates to a truthy value. diff --git a/packages/anyone/tsconfig.json b/packages/anyone/tsconfig.json index 01b6669fd..fca81718b 100644 --- a/packages/anyone/tsconfig.json +++ b/packages/anyone/tsconfig.json @@ -7,12 +7,8 @@ "declarationMap": true, "outDir": "./dist", "paths": { - "anyone": ["./src/anyone.ts"], - "runAnyoneMethods": ["./src/runner/runAnyoneMethods.ts"], - "one": ["./src/exports/one.ts"], - "none": ["./src/exports/none.ts"], - "any": ["./src/exports/any.ts"], - "all": ["./src/exports/all.ts"] + "@exports/*": ["src/exports/*"], + "@/*": ["src/*"] } } } diff --git a/packages/context/tsconfig.json b/packages/context/tsconfig.json index d73e69dc1..fca81718b 100644 --- a/packages/context/tsconfig.json +++ b/packages/context/tsconfig.json @@ -7,7 +7,8 @@ "declarationMap": true, "outDir": "./dist", "paths": { - "context": ["./src/context.ts"] + "@exports/*": ["src/exports/*"], + "@/*": ["src/*"] } } } diff --git a/packages/n4s/src/__tests__/enforce.test.ts b/packages/n4s/src/__tests__/enforce.test.ts index bf2877501..08d069ba0 100644 --- a/packages/n4s/src/__tests__/enforce.test.ts +++ b/packages/n4s/src/__tests__/enforce.test.ts @@ -1,6 +1,6 @@ import { TEnforceMock } from '../../testUtils/TEnforceMock'; -import * as ruleReturn from 'ruleReturn'; +import * as ruleReturn from '@/lib/ruleReturn'; const _proxy = global.Proxy; let enforce: TEnforceMock; @@ -45,10 +45,10 @@ describe(`enforce`, () => { it('should throw message string when rule fails', () => { expect(() => enforce(':(').startsWithUnderscore()).toThrow( - ':( does not start with underscore' + ':( does not start with underscore', ); expect(() => - enforce(':(').isString().startsWithUnderscore().isNumber() + enforce(':(').isString().startsWithUnderscore().isNumber(), ).toThrow(':( does not start with underscore'); }); }); @@ -76,7 +76,7 @@ describe(`enforce`, () => { expect(enforce.isArray().run([])).toEqual(ruleReturn.passing()); expect(enforce.greaterThan(5).run(6)).toEqual(ruleReturn.passing()); expect(enforce.greaterThan(5).lessThan(7).run(6)).toEqual( - ruleReturn.passing() + ruleReturn.passing(), ); }); @@ -85,7 +85,7 @@ describe(`enforce`, () => { expect(enforce.isArray().run({})).toEqual(ruleReturn.failing()); expect(enforce.greaterThan(6).run(5)).toEqual(ruleReturn.failing()); expect(enforce.greaterThan(7).lessThan(5).run(6)).toEqual( - ruleReturn.failing() + ruleReturn.failing(), ); }); }); @@ -105,14 +105,14 @@ describe(`enforce`, () => { it('Should return true when valid', () => { expect(enforce.isEmail().test('example@gmail.com')).toBe(true); expect(enforce.isEmail().isString().test('example@gmail.com')).toBe( - true + true, ); }); it('Should return false when invalid', () => { expect(enforce.isEmail().test('example!gmail.com')).toBe(false); expect(enforce.isEmail().isString().test('example!gmail.com')).toBe( - false + false, ); }); }); diff --git a/packages/n4s/src/__tests__/enforceEager.test.ts b/packages/n4s/src/__tests__/enforceEager.test.ts index dcbb3feb6..bf7f9984e 100644 --- a/packages/n4s/src/__tests__/enforceEager.test.ts +++ b/packages/n4s/src/__tests__/enforceEager.test.ts @@ -1,4 +1,4 @@ -import enforceEager from 'enforceEager'; +import enforceEager from '../runtime/enforceEager'; describe(`enforce eager`, () => { it('should throw when rule fails', () => { diff --git a/packages/n4s/src/exports/__tests__/compose.test.ts b/packages/n4s/src/exports/__tests__/compose.test.ts index 5abe6d821..3e161ad0b 100644 --- a/packages/n4s/src/exports/__tests__/compose.test.ts +++ b/packages/n4s/src/exports/__tests__/compose.test.ts @@ -1,8 +1,8 @@ -import compose from 'compose'; +import * as ruleReturn from '@/lib/ruleReturn'; +import compose from '@exports/compose'; import { enforce } from 'n4s'; -import * as ruleReturn from 'ruleReturn'; -import 'schema'; -import 'compounds'; +import '@exports/schema'; +import '@exports/compounds'; describe('compose', () => { it('Should create "and" relationship between composed rules', () => { @@ -19,17 +19,17 @@ describe('compose', () => { enforce.isNumeric(), enforce.isString(), enforce.greaterThan(3), - enforce.lessThan(5) + enforce.lessThan(5), ); expect(NumericStringBetweenThreeAndFive.run('4')).toEqual( - ruleReturn.passing() + ruleReturn.passing(), ); expect(NumericStringBetweenThreeAndFive.run('3')).toEqual( - ruleReturn.failing() + ruleReturn.failing(), ); expect(NumericStringBetweenThreeAndFive.run(5)).toEqual( - ruleReturn.failing() + ruleReturn.failing(), ); expect(NumericStringBetweenThreeAndFive.test('4')).toBe(true); expect(NumericStringBetweenThreeAndFive.test('3')).toBe(false); @@ -42,7 +42,7 @@ describe('compose', () => { first: enforce.isString().isNotEmpty(), last: enforce.isString().isNotEmpty(), middle: enforce.optional(enforce.isString().isNotEmpty()), - }) + }), ); expect( @@ -55,7 +55,7 @@ describe('compose', () => { first: 'John', last: 'Doe', }, - }) + }), ).toEqual(ruleReturn.passing()); expect( @@ -69,7 +69,7 @@ describe('compose', () => { last: 'Doe', middle: '', }, - }) + }), ).toEqual(ruleReturn.failing()); }); it('Should allow composing compositions', () => { @@ -80,13 +80,13 @@ describe('compose', () => { last: enforce.isString().isNotEmpty(), middle: enforce.optional(enforce.isString().isNotEmpty()), }), - }) + }), ); const Entity = compose( enforce.loose({ id: enforce.isNumeric(), - }) + }), ); const User = compose(Name, Entity); @@ -99,7 +99,7 @@ describe('compose', () => { middle: 'M', last: 'Doe', }, - }) + }), ).toEqual(ruleReturn.passing()); User({ id: '1', @@ -117,7 +117,7 @@ describe('compose', () => { name: { first: 'John', }, - }) + }), ).toEqual(ruleReturn.failing()); expect(() => @@ -126,7 +126,7 @@ describe('compose', () => { first: 'John', }, id: '__', - }) + }), ).toThrow(); }); }); diff --git a/packages/n4s/src/exports/compose.ts b/packages/n4s/src/exports/compose.ts index b608080f5..5df43f5b6 100644 --- a/packages/n4s/src/exports/compose.ts +++ b/packages/n4s/src/exports/compose.ts @@ -1,9 +1,9 @@ import { ctx } from 'n4s'; import { invariant, StringObject, assign, mapFirst } from 'vest-utils'; -import type { ComposeResult, LazyRuleRunners } from 'genEnforceLazy'; -import { defaultToPassing, RuleDetailedResult } from 'ruleReturn'; -import runLazyRule from 'runLazyRule'; +import { defaultToPassing, RuleDetailedResult } from '../lib/ruleReturn'; +import runLazyRule from '../lib/runLazyRule'; +import { ComposeResult, LazyRuleRunners } from '../runtime/genEnforceLazy'; /* eslint-disable max-lines-per-function */ @@ -19,7 +19,7 @@ export default function compose( { run, test: (value: any) => run(value).pass, - } + }, ); function run(value: any): RuleDetailedResult { @@ -29,7 +29,7 @@ export default function compose( composites, ( composite: LazyRuleRunners, - breakout: (conditional: boolean, res: RuleDetailedResult) => void + breakout: (conditional: boolean, res: RuleDetailedResult) => void, ) => { /* HACK: Just a small white lie. ~~HELP WANTED~~. The ideal is that instead of `LazyRuleRunners` We would simply use `Lazy` to begin with. @@ -40,8 +40,8 @@ export default function compose( const res = runLazyRule(composite, value); breakout(!res.pass, res); - } - ) + }, + ), ); }); } diff --git a/packages/n4s/src/exports/compounds.ts b/packages/n4s/src/exports/compounds.ts index 46e96ea5c..a6137b3c6 100644 --- a/packages/n4s/src/exports/compounds.ts +++ b/packages/n4s/src/exports/compounds.ts @@ -1,12 +1,12 @@ import { enforce } from 'n4s'; -import { allOf } from 'allOf'; -import { anyOf } from 'anyOf'; -import { EnforceCustomMatcher } from 'enforceUtilityTypes'; -import { Lazy } from 'genEnforceLazy'; -import { noneOf } from 'noneOf'; -import { oneOf } from 'oneOf'; -import { RuleDetailedResult } from 'ruleReturn'; +import { EnforceCustomMatcher } from '@/lib/enforceUtilityTypes'; +import { RuleDetailedResult } from '@/lib/ruleReturn'; +import { allOf } from '@/plugins/compounds/allOf'; +import { anyOf } from '@/plugins/compounds/anyOf'; +import { noneOf } from '@/plugins/compounds/noneOf'; +import { oneOf } from '@/plugins/compounds/oneOf'; +import { Lazy } from '@/runtime/genEnforceLazy'; enforce.extend({ allOf, anyOf, noneOf, oneOf }); diff --git a/packages/n4s/src/exports/date.ts b/packages/n4s/src/exports/date.ts index c2f2216ec..e90356e67 100644 --- a/packages/n4s/src/exports/date.ts +++ b/packages/n4s/src/exports/date.ts @@ -4,7 +4,7 @@ import isBefore from 'validator/es/lib/isBefore'; import isDate from 'validator/es/lib/isDate'; import isISO8601 from 'validator/es/lib/isISO8601'; -import { EnforceCustomMatcher } from 'enforceUtilityTypes'; +import { EnforceCustomMatcher } from '../lib/enforceUtilityTypes'; enforce.extend({ isAfter, isBefore, isDate, isISO8601 }); diff --git a/packages/n4s/src/exports/email.ts b/packages/n4s/src/exports/email.ts index 22d71f412..6395dadbf 100644 --- a/packages/n4s/src/exports/email.ts +++ b/packages/n4s/src/exports/email.ts @@ -1,7 +1,7 @@ import { enforce } from 'n4s'; import isEmail from 'validator/es/lib/isEmail'; -import { EnforceCustomMatcher } from 'enforceUtilityTypes'; +import { EnforceCustomMatcher } from '@/lib/enforceUtilityTypes'; enforce.extend({ isEmail }); diff --git a/packages/n4s/src/exports/isURL.ts b/packages/n4s/src/exports/isURL.ts index 3d76b4bd7..1e6ce3392 100644 --- a/packages/n4s/src/exports/isURL.ts +++ b/packages/n4s/src/exports/isURL.ts @@ -1,7 +1,7 @@ import { enforce } from 'n4s'; import isURL from 'validator/es/lib/isURL'; -import { EnforceCustomMatcher } from 'enforceUtilityTypes'; +import { EnforceCustomMatcher } from '@/lib/enforceUtilityTypes'; enforce.extend({ isURL }); diff --git a/packages/n4s/src/exports/schema.ts b/packages/n4s/src/exports/schema.ts index 2a026d8a7..7fc0add5e 100644 --- a/packages/n4s/src/exports/schema.ts +++ b/packages/n4s/src/exports/schema.ts @@ -1,13 +1,10 @@ import { enforce } from 'n4s'; - -import { EnforceCustomMatcher } from 'enforceUtilityTypes'; -import { isArrayOf } from 'isArrayOf'; -import { loose } from 'loose'; -import { optional } from 'optional'; -import { shape } from 'shape'; - -export { partial } from 'partial'; +import { EnforceCustomMatcher } from '../lib/enforceUtilityTypes'; +import { isArrayOf } from '../plugins/schema/isArrayOf'; +import { loose } from '../plugins/schema/loose'; +import { optional } from '../plugins/schema/optional'; +import { shape } from '../plugins/schema/shape'; enforce.extend({ isArrayOf, loose, optional, shape }); diff --git a/packages/n4s/src/lib/runLazyRule.ts b/packages/n4s/src/lib/runLazyRule.ts index d53fde05b..bd7cb9433 100644 --- a/packages/n4s/src/lib/runLazyRule.ts +++ b/packages/n4s/src/lib/runLazyRule.ts @@ -1,10 +1,10 @@ -import type { LazyRuleRunners } from 'genEnforceLazy'; -import type { RuleDetailedResult } from 'ruleReturn'; -import * as ruleReturn from 'ruleReturn'; +import type { RuleDetailedResult } from '@/lib/ruleReturn'; +import * as ruleReturn from '@/lib/ruleReturn'; +import type { LazyRuleRunners } from '@/runtime/genEnforceLazy'; export default function runLazyRule( lazyRule: LazyRuleRunners, - currentValue: any + currentValue: any, ): RuleDetailedResult { try { return lazyRule.run(currentValue); diff --git a/packages/n4s/src/lib/transformResult.ts b/packages/n4s/src/lib/transformResult.ts index 1627f07b6..50cfce967 100644 --- a/packages/n4s/src/lib/transformResult.ts +++ b/packages/n4s/src/lib/transformResult.ts @@ -1,7 +1,7 @@ import { invariant, optionalFunctionValue, isBoolean } from 'vest-utils'; -import ruleReturn, { RuleReturn, RuleDetailedResult } from 'ruleReturn'; -import type { RuleValue, Args } from 'runtimeRules'; +import ruleReturn, { RuleReturn, RuleDetailedResult } from '@/lib/ruleReturn'; +import type { RuleValue, Args } from '@/runtime/runtimeRules'; /** * Transform the result of a rule into a standard format @@ -20,7 +20,7 @@ export function transformResult( } return ruleReturn( result.pass, - optionalFunctionValue(result.message, ruleName, value, ...args) + optionalFunctionValue(result.message, ruleName, value, ...args), ); } @@ -28,6 +28,6 @@ function validateResult(result: RuleReturn): void { // if result is boolean, or if result.pass is boolean invariant( isBoolean(result) || (result && isBoolean(result.pass)), - 'Incorrect return value for rule: ' + JSON.stringify(result) + 'Incorrect return value for rule: ' + JSON.stringify(result), ); } diff --git a/packages/n4s/src/n4s.ts b/packages/n4s/src/n4s.ts index daed01571..c5fe5e755 100644 --- a/packages/n4s/src/n4s.ts +++ b/packages/n4s/src/n4s.ts @@ -1,5 +1,5 @@ -export { enforce } from 'enforce'; -export { ctx } from 'enforceContext'; +export { enforce } from '@/runtime/enforce'; +export { ctx } from '@/runtime/enforceContext'; /* eslint-disable @typescript-eslint/no-namespace, @typescript-eslint/no-empty-interface, @typescript-eslint/no-unused-vars */ declare global { diff --git a/packages/n4s/src/plugins/compounds/__tests__/allOf.test.ts b/packages/n4s/src/plugins/compounds/__tests__/allOf.test.ts index 58edc636f..650c414f2 100644 --- a/packages/n4s/src/plugins/compounds/__tests__/allOf.test.ts +++ b/packages/n4s/src/plugins/compounds/__tests__/allOf.test.ts @@ -1,5 +1,5 @@ -import { enforce } from 'enforce'; -import * as ruleReturn from 'ruleReturn'; +import { enforce } from '@/runtime/enforce'; +import * as ruleReturn from '@/lib/ruleReturn'; import 'compounds'; describe('allOf', () => { @@ -7,7 +7,9 @@ describe('allOf', () => { describe('When all rules are satisfied', () => { it('Should return a passing result', () => { expect( - enforce.allOf(enforce.isArray(), enforce.longerThan(2)).run([1, 2, 3]) + enforce + .allOf(enforce.isArray(), enforce.longerThan(2)) + .run([1, 2, 3]), ).toEqual(ruleReturn.passing()); }); }); diff --git a/packages/n4s/src/plugins/compounds/__tests__/noneOf.test.ts b/packages/n4s/src/plugins/compounds/__tests__/noneOf.test.ts index 1de8a0fb1..c7889a59b 100644 --- a/packages/n4s/src/plugins/compounds/__tests__/noneOf.test.ts +++ b/packages/n4s/src/plugins/compounds/__tests__/noneOf.test.ts @@ -1,5 +1,6 @@ -import { enforce } from 'enforce'; -import * as ruleReturn from 'ruleReturn'; +import * as ruleReturn from '@/lib/ruleReturn'; +import { enforce } from '@/runtime/enforce'; + import 'compounds'; describe('noneOf', () => { @@ -7,7 +8,7 @@ describe('noneOf', () => { describe('When none of the rules are satisfied', () => { it('Should return a passing result', () => { expect( - enforce.noneOf(enforce.isArray(), enforce.longerThan(2)).run('x') + enforce.noneOf(enforce.isArray(), enforce.longerThan(2)).run('x'), ).toEqual(ruleReturn.passing()); }); }); @@ -15,7 +16,7 @@ describe('noneOf', () => { describe('When some of the rules are satisfied', () => { it('Should return a failing result', () => { expect( - enforce.noneOf(enforce.isArray(), enforce.longerThan(2)).run([2]) + enforce.noneOf(enforce.isArray(), enforce.longerThan(2)).run([2]), ).toEqual(ruleReturn.failing()); }); }); @@ -23,7 +24,7 @@ describe('noneOf', () => { describe('When all of the rules are satisfied', () => { it('Should return a failing result', () => { expect( - enforce.noneOf(enforce.isArray(), enforce.longerThan(2)).run([2, 3]) + enforce.noneOf(enforce.isArray(), enforce.longerThan(2)).run([2, 3]), ).toEqual(ruleReturn.failing()); }); }); diff --git a/packages/n4s/src/plugins/compounds/__tests__/oneOf.test.ts b/packages/n4s/src/plugins/compounds/__tests__/oneOf.test.ts index 980639937..2278d1cb9 100644 --- a/packages/n4s/src/plugins/compounds/__tests__/oneOf.test.ts +++ b/packages/n4s/src/plugins/compounds/__tests__/oneOf.test.ts @@ -1,5 +1,5 @@ -import { enforce } from 'enforce'; -import * as ruleReturn from 'ruleReturn'; +import { enforce } from '@/runtime/enforce'; +import * as ruleReturn from '@/lib/ruleReturn'; import 'schema'; import 'compounds'; @@ -7,7 +7,7 @@ import 'compounds'; describe('enforce.oneOf', () => { it('Should fail when multiple enforcements are met', () => { expect( - enforce.oneOf(enforce.isNumber(), enforce.greaterThan(2)).run(3) + enforce.oneOf(enforce.isNumber(), enforce.greaterThan(2)).run(3), ).toEqual(ruleReturn.failing()); }); @@ -18,7 +18,7 @@ describe('enforce.oneOf', () => { first: 'John', last: 'Doe', }, - }) + }), ).toEqual(ruleReturn.passing()); expect(User.run({ id: 11 })).toEqual(ruleReturn.passing()); }); diff --git a/packages/n4s/src/plugins/compounds/allOf.ts b/packages/n4s/src/plugins/compounds/allOf.ts index a56c006b4..a9968a9ce 100644 --- a/packages/n4s/src/plugins/compounds/allOf.ts +++ b/packages/n4s/src/plugins/compounds/allOf.ts @@ -1,15 +1,15 @@ import { mapFirst } from 'vest-utils'; -import type { Lazy } from 'genEnforceLazy'; -import * as ruleReturn from 'ruleReturn'; -import type { RuleDetailedResult } from 'ruleReturn'; -import runLazyRule from 'runLazyRule'; +import * as ruleReturn from '@/lib/ruleReturn'; +import type { RuleDetailedResult } from '@/lib/ruleReturn'; +import runLazyRule from '@/lib/runLazyRule'; +import { Lazy } from '@/runtime/genEnforceLazy'; export function allOf(value: unknown, ...rules: Lazy[]): RuleDetailedResult { return ruleReturn.defaultToPassing( mapFirst(rules, (rule, breakout) => { const res = runLazyRule(rule, value); breakout(!res.pass, res); - }) + }), ); } diff --git a/packages/n4s/src/plugins/compounds/anyOf.ts b/packages/n4s/src/plugins/compounds/anyOf.ts index 24c8ea037..9ee06d685 100644 --- a/packages/n4s/src/plugins/compounds/anyOf.ts +++ b/packages/n4s/src/plugins/compounds/anyOf.ts @@ -1,15 +1,15 @@ import { mapFirst } from 'vest-utils'; -import type { Lazy } from 'genEnforceLazy'; -import * as ruleReturn from 'ruleReturn'; -import type { RuleDetailedResult } from 'ruleReturn'; -import runLazyRule from 'runLazyRule'; +import type { Lazy } from '@/runtime/genEnforceLazy'; +import * as ruleReturn from '@/lib/ruleReturn'; +import type { RuleDetailedResult } from '@/lib/ruleReturn'; +import runLazyRule from '@/lib/runLazyRule'; export function anyOf(value: unknown, ...rules: Lazy[]): RuleDetailedResult { return ruleReturn.defaultToFailing( mapFirst(rules, (rule, breakout) => { const res = runLazyRule(rule, value); breakout(res.pass, res); - }) + }), ); } diff --git a/packages/n4s/src/plugins/compounds/noneOf.ts b/packages/n4s/src/plugins/compounds/noneOf.ts index fc2fc05b2..cc7c59cde 100644 --- a/packages/n4s/src/plugins/compounds/noneOf.ts +++ b/packages/n4s/src/plugins/compounds/noneOf.ts @@ -1,9 +1,9 @@ import { mapFirst } from 'vest-utils'; -import type { Lazy } from 'genEnforceLazy'; -import type { RuleDetailedResult } from 'ruleReturn'; -import * as ruleReturn from 'ruleReturn'; -import runLazyRule from 'runLazyRule'; +import type { Lazy } from '@/runtime/genEnforceLazy'; +import type { RuleDetailedResult } from '@/lib/ruleReturn'; +import * as ruleReturn from '@/lib/ruleReturn'; +import runLazyRule from '@/lib/runLazyRule'; export function noneOf(value: unknown, ...rules: Lazy[]): RuleDetailedResult { return ruleReturn.defaultToPassing( @@ -11,6 +11,6 @@ export function noneOf(value: unknown, ...rules: Lazy[]): RuleDetailedResult { const res = runLazyRule(rule, value); breakout(res.pass, ruleReturn.failing()); - }) + }), ); } diff --git a/packages/n4s/src/plugins/compounds/oneOf.ts b/packages/n4s/src/plugins/compounds/oneOf.ts index bc71c7ad7..d7ecbac78 100644 --- a/packages/n4s/src/plugins/compounds/oneOf.ts +++ b/packages/n4s/src/plugins/compounds/oneOf.ts @@ -1,9 +1,9 @@ import { greaterThan } from 'vest-utils'; -import { equals } from 'equals'; -import type { Lazy } from 'genEnforceLazy'; -import ruleReturn, { RuleDetailedResult } from 'ruleReturn'; -import runLazyRule from 'runLazyRule'; +import ruleReturn, { RuleDetailedResult } from '@/lib/ruleReturn'; +import runLazyRule from '@/lib/runLazyRule'; +import { equals } from '@/rules/equals'; +import type { Lazy } from '@/runtime/genEnforceLazy'; const REQUIRED_COUNT = 1; diff --git a/packages/n4s/src/plugins/schema/__tests__/isArrayOf.test.ts b/packages/n4s/src/plugins/schema/__tests__/isArrayOf.test.ts index cbcb99061..89342565d 100644 --- a/packages/n4s/src/plugins/schema/__tests__/isArrayOf.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/isArrayOf.test.ts @@ -1,25 +1,25 @@ -import { enforce } from 'enforce'; +import { enforce } from '@/runtime/enforce'; import 'schema'; import 'compounds'; -import * as ruleReturn from 'ruleReturn'; +import * as ruleReturn from '@/lib/ruleReturn'; describe('enforce.isArrayOf', () => { describe('lazy interface', () => { it('Should return a passing return for an empty array', () => { expect(enforce.isArrayOf(enforce.isString()).run([])).toEqual( - ruleReturn.passing() + ruleReturn.passing(), ); }); it('Should return a passing return for valid arrays', () => { expect( - enforce.isArrayOf(enforce.isString()).run(['a', 'b', 'c']) + enforce.isArrayOf(enforce.isString()).run(['a', 'b', 'c']), ).toEqual(ruleReturn.passing()); expect( enforce .isArrayOf(enforce.anyOf(enforce.isString(), enforce.isNumber())) - .run([1, 'b', 'c']) + .run([1, 'b', 'c']), ).toEqual(ruleReturn.passing()); expect( @@ -28,24 +28,24 @@ describe('enforce.isArrayOf', () => { enforce.shape({ id: enforce.isNumber(), username: enforce.isString(), - }) + }), ) .run([ { id: 1, username: 'b' }, { id: 2, username: 'c' }, - ]) + ]), ).toEqual(ruleReturn.passing()); }); it('Should return a failing return for invalid arrays', () => { expect(enforce.isArrayOf(enforce.isString()).run([1, 2, 3])).toEqual( - ruleReturn.failing() + ruleReturn.failing(), ); expect( enforce .isArrayOf(enforce.allOf(enforce.isString(), enforce.isNumber())) - .run([1, 2, 3]) + .run([1, 2, 3]), ).toEqual(ruleReturn.failing()); expect( @@ -54,13 +54,13 @@ describe('enforce.isArrayOf', () => { enforce.shape({ id: enforce.isNumber(), username: enforce.isString(), - }) + }), ) .run([ { id: '1', username: 'b' }, { id: '2', username: 'c' }, { id: '3', username: 'd' }, - ]) + ]), ).toEqual(ruleReturn.failing()); }); }); @@ -74,7 +74,7 @@ describe('enforce.isArrayOf', () => { enforce(['a', 'b', 'c']).isArrayOf(enforce.isString()); enforce([1, 'b', 'c']).isArrayOf( - enforce.anyOf(enforce.isString(), enforce.isNumber()) + enforce.anyOf(enforce.isString(), enforce.isNumber()), ); enforce([ @@ -84,7 +84,7 @@ describe('enforce.isArrayOf', () => { enforce.shape({ id: enforce.isNumber(), username: enforce.isString(), - }) + }), ); }); @@ -93,8 +93,8 @@ describe('enforce.isArrayOf', () => { expect(() => enforce([1, 2, 3]).isArrayOf( - enforce.allOf(enforce.isString(), enforce.isNumber()) - ) + enforce.allOf(enforce.isString(), enforce.isNumber()), + ), ).toThrow(); expect(() => @@ -106,8 +106,8 @@ describe('enforce.isArrayOf', () => { enforce.shape({ id: enforce.isNumber(), username: enforce.isString(), - }) - ) + }), + ), ).toThrow(); }); }); diff --git a/packages/n4s/src/plugins/schema/__tests__/loose.test.ts b/packages/n4s/src/plugins/schema/__tests__/loose.test.ts index 2f1590c83..8d545873f 100644 --- a/packages/n4s/src/plugins/schema/__tests__/loose.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/loose.test.ts @@ -1,5 +1,5 @@ -import { enforce } from 'enforce'; -import * as ruleReturn from 'ruleReturn'; +import { enforce } from '@/runtime/enforce'; +import * as ruleReturn from '@/lib/ruleReturn'; import 'schema'; describe('enforce.loose for loose matching', () => { @@ -8,7 +8,7 @@ describe('enforce.loose for loose matching', () => { expect( enforce .loose({ username: enforce.isString(), age: enforce.isNumber() }) - .run({ username: 'ealush', age: 31, foo: 'bar' }) + .run({ username: 'ealush', age: 31, foo: 'bar' }), ).toEqual(ruleReturn.passing()); }); }); diff --git a/packages/n4s/src/plugins/schema/__tests__/optional.test.ts b/packages/n4s/src/plugins/schema/__tests__/optional.test.ts index 674f68e13..608fe7bf3 100644 --- a/packages/n4s/src/plugins/schema/__tests__/optional.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/optional.test.ts @@ -1,5 +1,5 @@ -import { enforce } from 'enforce'; -import * as ruleReturn from 'ruleReturn'; +import { enforce } from '@/runtime/enforce'; +import * as ruleReturn from '@/lib/ruleReturn'; import 'schema'; import 'compounds'; @@ -7,10 +7,10 @@ describe('enforce.optional', () => { describe('lazy interface', () => { it('Should return a passing result for nullable values', () => { expect(enforce.optional(enforce.isNumber()).run(null)).toEqual( - ruleReturn.passing() + ruleReturn.passing(), ); expect(enforce.optional(enforce.isArray()).run(undefined)).toEqual( - ruleReturn.passing() + ruleReturn.passing(), ); expect( @@ -23,16 +23,16 @@ describe('enforce.optional', () => { .run({ firstName: 'John', lastName: 'Doe', - }) + }), ).toEqual(ruleReturn.passing()); }); it('Should return passing result for non-nullable values that satisfy the tests', () => { expect(enforce.optional(enforce.isNumber()).run(2)).toEqual( - ruleReturn.passing() + ruleReturn.passing(), ); expect(enforce.optional(enforce.isArray()).run([1, 2])).toEqual( - ruleReturn.passing() + ruleReturn.passing(), ); expect( enforce @@ -45,16 +45,16 @@ describe('enforce.optional', () => { firstName: 'John', middleName: 'H.', lastName: 'Doe', - }) + }), ).toEqual(ruleReturn.passing()); }); it('Should return a failing result for non-nullable values that do not satisfy the tests', () => { expect(enforce.optional(enforce.isNumber()).run('2')).toEqual( - ruleReturn.failing() + ruleReturn.failing(), ); expect(enforce.optional(enforce.isArray()).run('2')).toEqual( - ruleReturn.failing() + ruleReturn.failing(), ); expect( enforce @@ -67,7 +67,7 @@ describe('enforce.optional', () => { firstName: 'John', middleName: 'H.', lastName: 'Doe', - }) + }), ).toEqual(ruleReturn.failing()); }); }); diff --git a/packages/n4s/src/plugins/schema/__tests__/partial.test.ts b/packages/n4s/src/plugins/schema/__tests__/partial.test.ts index d42d06e5e..522e9bed2 100644 --- a/packages/n4s/src/plugins/schema/__tests__/partial.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/partial.test.ts @@ -1,8 +1,8 @@ -import { enforce } from 'enforce'; -import * as ruleReturn from 'ruleReturn'; -import { partial } from 'schema'; +import * as ruleReturn from '@/lib/ruleReturn'; +import { enforce } from '@/runtime/enforce'; import 'compounds'; +import { partial } from '../partial'; describe('partial', () => { describe('Lazy Interface', () => { @@ -11,7 +11,7 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ); partial({}); @@ -21,7 +21,7 @@ describe('partial', () => { rules.run({ username: null, id: null, - }) + }), ).toEqual(ruleReturn.passing()); }); @@ -30,11 +30,11 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ); expect(rules.run({ username: 'foobar', id: 1 })).toEqual( - ruleReturn.passing() + ruleReturn.passing(), ); }); @@ -43,7 +43,7 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ); expect(rules.run({ username: 'foobar' })).toEqual(ruleReturn.passing()); @@ -54,11 +54,11 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ); expect(rules.run({ username: 'foo', id: '1' })).toEqual( - ruleReturn.failing() + ruleReturn.failing(), ); }); }); @@ -69,7 +69,7 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ); enforce({ @@ -79,7 +79,7 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ); }); @@ -88,7 +88,7 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ); }); @@ -97,7 +97,7 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ); }); @@ -107,8 +107,8 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) - ) + }), + ), ).toThrow(); }); }); @@ -120,9 +120,9 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ) - .run({ username: 'foobar', id: '1', foo: 'bar' }) + .run({ username: 'foobar', id: '1', foo: 'bar' }), ).toEqual(ruleReturn.failing()); expect( @@ -131,9 +131,9 @@ describe('partial', () => { partial({ username: enforce.isString().longerThan(3), id: enforce.isNumeric(), - }) + }), ) - .run({ username: 'foobar', id: '1', foo: 'bar' }) + .run({ username: 'foobar', id: '1', foo: 'bar' }), ).toEqual(ruleReturn.passing()); }); }); diff --git a/packages/n4s/src/plugins/schema/__tests__/shape&loose.test.ts b/packages/n4s/src/plugins/schema/__tests__/shape&loose.test.ts index caff29e3e..1f7509ece 100644 --- a/packages/n4s/src/plugins/schema/__tests__/shape&loose.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/shape&loose.test.ts @@ -1,5 +1,5 @@ -import { enforce } from 'enforce'; -import * as ruleReturn from 'ruleReturn'; +import { enforce } from '@/runtime/enforce'; +import * as ruleReturn from '@/lib/ruleReturn'; import 'schema'; import 'compounds'; diff --git a/packages/n4s/src/plugins/schema/__tests__/shape.test.ts b/packages/n4s/src/plugins/schema/__tests__/shape.test.ts index b3dd49298..95da0562b 100644 --- a/packages/n4s/src/plugins/schema/__tests__/shape.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/shape.test.ts @@ -1,5 +1,5 @@ -import { enforce } from 'enforce'; -import * as ruleReturn from 'ruleReturn'; +import { enforce } from '@/runtime/enforce'; +import * as ruleReturn from '@/lib/ruleReturn'; import 'schema'; import 'compounds'; @@ -9,7 +9,7 @@ describe('enforce.shape exact matching', () => { expect( enforce .shape({ username: enforce.isString(), age: enforce.isNumber() }) - .run({ username: 'ealush', age: 31, foo: 'bar' }) + .run({ username: 'ealush', age: 31, foo: 'bar' }), ).toEqual(ruleReturn.failing()); }); }); diff --git a/packages/n4s/src/plugins/schema/isArrayOf.ts b/packages/n4s/src/plugins/schema/isArrayOf.ts index 78e4bd7d7..9630dd535 100644 --- a/packages/n4s/src/plugins/schema/isArrayOf.ts +++ b/packages/n4s/src/plugins/schema/isArrayOf.ts @@ -1,23 +1,23 @@ import { ctx } from 'n4s'; import { mapFirst } from 'vest-utils'; -import type { LazyRuleRunners } from 'genEnforceLazy'; -import type { RuleDetailedResult } from 'ruleReturn'; -import * as ruleReturn from 'ruleReturn'; -import runLazyRule from 'runLazyRule'; +import type { LazyRuleRunners } from '@/runtime/genEnforceLazy'; +import type { RuleDetailedResult } from '@/lib/ruleReturn'; +import * as ruleReturn from '@/lib/ruleReturn'; +import runLazyRule from '@/lib/runLazyRule'; export function isArrayOf( inputArray: any[], - currentRule: LazyRuleRunners + currentRule: LazyRuleRunners, ): RuleDetailedResult { return ruleReturn.defaultToPassing( mapFirst(inputArray, (currentValue, breakout, index) => { const res = ctx.run( { value: currentValue, set: true, meta: { index } }, - () => runLazyRule(currentRule, currentValue) + () => runLazyRule(currentRule, currentValue), ); breakout(!res.pass, res); - }) + }), ); } diff --git a/packages/n4s/src/plugins/schema/loose.ts b/packages/n4s/src/plugins/schema/loose.ts index b94e872a2..c05040e8d 100644 --- a/packages/n4s/src/plugins/schema/loose.ts +++ b/packages/n4s/src/plugins/schema/loose.ts @@ -1,20 +1,21 @@ import { ctx } from 'n4s'; -import type { RuleDetailedResult } from 'ruleReturn'; -import * as ruleReturn from 'ruleReturn'; -import runLazyRule from 'runLazyRule'; -import type { ShapeObject } from 'schemaTypes'; +import { ShapeObject } from './schemaTypes'; + +import type { RuleDetailedResult } from '@/lib/ruleReturn'; +import * as ruleReturn from '@/lib/ruleReturn'; +import runLazyRule from '@/lib/runLazyRule'; export function loose( inputObject: Record, - shapeObject: ShapeObject + shapeObject: ShapeObject, ): RuleDetailedResult { for (const key in shapeObject) { const currentValue = inputObject[key]; const currentRule = shapeObject[key]; const res = ctx.run({ value: currentValue, set: true, meta: { key } }, () => - runLazyRule(currentRule, currentValue) + runLazyRule(currentRule, currentValue), ); if (!res.pass) { diff --git a/packages/n4s/src/plugins/schema/optional.ts b/packages/n4s/src/plugins/schema/optional.ts index 662f4c682..6eb3ca3ae 100644 --- a/packages/n4s/src/plugins/schema/optional.ts +++ b/packages/n4s/src/plugins/schema/optional.ts @@ -1,9 +1,9 @@ import { isNullish } from 'vest-utils'; -import type { Lazy } from 'genEnforceLazy'; -import type { RuleDetailedResult } from 'ruleReturn'; -import * as ruleReturn from 'ruleReturn'; -import runLazyRule from 'runLazyRule'; +import type { Lazy } from '@/runtime/genEnforceLazy'; +import type { RuleDetailedResult } from '@/lib/ruleReturn'; +import * as ruleReturn from '@/lib/ruleReturn'; +import runLazyRule from '@/lib/runLazyRule'; export function optional(value: any, ruleChain: Lazy): RuleDetailedResult { if (isNullish(value)) { diff --git a/packages/n4s/src/plugins/schema/schemaTypes.ts b/packages/n4s/src/plugins/schema/schemaTypes.ts index cb9ac39d7..3d1bb451b 100644 --- a/packages/n4s/src/plugins/schema/schemaTypes.ts +++ b/packages/n4s/src/plugins/schema/schemaTypes.ts @@ -1,4 +1,4 @@ -import { LazyRuleRunners } from 'genEnforceLazy'; +import { LazyRuleRunners } from '@/runtime/genEnforceLazy'; export interface ShapeObject extends Record, diff --git a/packages/n4s/src/plugins/schema/shape.ts b/packages/n4s/src/plugins/schema/shape.ts index e7c64adc0..ea46f075b 100644 --- a/packages/n4s/src/plugins/schema/shape.ts +++ b/packages/n4s/src/plugins/schema/shape.ts @@ -1,13 +1,14 @@ import { hasOwnProperty } from 'vest-utils'; -import { loose } from 'loose'; -import type { RuleDetailedResult } from 'ruleReturn'; -import * as ruleReturn from 'ruleReturn'; -import type { ShapeObject } from 'schemaTypes'; +import { loose } from './loose'; +import { ShapeObject } from './schemaTypes'; + +import type { RuleDetailedResult } from '@/lib/ruleReturn'; +import * as ruleReturn from '@/lib/ruleReturn'; export function shape( inputObject: Record, - shapeObject: ShapeObject + shapeObject: ShapeObject, ): RuleDetailedResult { const baseRes = loose(inputObject, shapeObject); if (!baseRes.pass) { diff --git a/packages/n4s/src/rules/__tests__/endsWith.test.ts b/packages/n4s/src/rules/__tests__/endsWith.test.ts index e341bbbd5..a0a489d69 100644 --- a/packages/n4s/src/rules/__tests__/endsWith.test.ts +++ b/packages/n4s/src/rules/__tests__/endsWith.test.ts @@ -1,4 +1,4 @@ -import { endsWith } from 'endsWith'; +import { endsWith } from '../endsWith'; describe('Tests isArray rule', () => { const word = 'meow'; @@ -9,7 +9,7 @@ describe('Tests isArray rule', () => { it('Should return true for a suffix', () => { expect(endsWith(word, word.substring(word.length / 2, word.length))).toBe( - true + true, ); }); diff --git a/packages/n4s/src/rules/__tests__/equals.test.ts b/packages/n4s/src/rules/__tests__/equals.test.ts index 95966f4d5..0f7d9a3e9 100644 --- a/packages/n4s/src/rules/__tests__/equals.test.ts +++ b/packages/n4s/src/rules/__tests__/equals.test.ts @@ -1,7 +1,7 @@ import { faker } from '@faker-js/faker'; import { sample } from 'lodash'; -import { equals } from 'equals'; +import { equals } from '../equals'; const VALUES = [ faker.lorem.word(), diff --git a/packages/n4s/src/rules/__tests__/greaterThanOrEquals.test.ts b/packages/n4s/src/rules/__tests__/greaterThanOrEquals.test.ts index 60cab3a08..3844dba2a 100644 --- a/packages/n4s/src/rules/__tests__/greaterThanOrEquals.test.ts +++ b/packages/n4s/src/rules/__tests__/greaterThanOrEquals.test.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { greaterThanOrEquals } from 'greaterThanOrEquals'; +import { greaterThanOrEquals } from '@/rules/greaterThanOrEquals'; describe('Tests greaterThanOrEquals rule', () => { describe('Arguments are numbers', () => { @@ -55,7 +55,7 @@ describe('Tests greaterThanOrEquals rule', () => { // @ts-expect-error - Testing invalid input expect(greaterThanOrEquals(element, 0)).toBe(false); }); - } + }, ); }); }); diff --git a/packages/n4s/src/rules/__tests__/inside.test.ts b/packages/n4s/src/rules/__tests__/inside.test.ts index e855cbbfd..60339b1b0 100644 --- a/packages/n4s/src/rules/__tests__/inside.test.ts +++ b/packages/n4s/src/rules/__tests__/inside.test.ts @@ -1,4 +1,4 @@ -import { inside } from 'inside'; +import { inside } from '../inside'; describe('Inside rule', () => { it('Should correctly find a string inside an array', () => { @@ -9,7 +9,7 @@ describe('Inside rule', () => { it('Should fail to find a string inside an array in which it does not exist', () => { expect(inside('going to', ["I'm", 'gonna', 'pop', 'some', 'tags'])).toBe( - false + false, ); }); @@ -35,7 +35,7 @@ describe('Inside rule', () => { it('Should fail to find array elements in another array in which they do not exist', () => { expect(inside(['no', 'treble'], ['all', 'about', 'the', 'bass'])).toBe( - false + false, ); }); diff --git a/packages/n4s/src/rules/__tests__/isBetween.test.ts b/packages/n4s/src/rules/__tests__/isBetween.test.ts index 45f56838d..17ab902ac 100644 --- a/packages/n4s/src/rules/__tests__/isBetween.test.ts +++ b/packages/n4s/src/rules/__tests__/isBetween.test.ts @@ -1,4 +1,4 @@ -import { isBetween } from 'isBetween'; +import { isBetween } from '../isBetween'; describe('Tests isBetween rule', () => { it('Should return true for 5 between 0 and 10', () => { diff --git a/packages/n4s/src/rules/__tests__/isBlank.test.ts b/packages/n4s/src/rules/__tests__/isBlank.test.ts index fd166d4a5..3e9e5405d 100644 --- a/packages/n4s/src/rules/__tests__/isBlank.test.ts +++ b/packages/n4s/src/rules/__tests__/isBlank.test.ts @@ -1,4 +1,4 @@ -import { isBlank, isNotBlank } from 'isBlank'; +import { isBlank, isNotBlank } from '../isBlank'; describe('isBlank', () => { it('Should return true for a string of white spaces', () => { diff --git a/packages/n4s/src/rules/__tests__/isBoolean.test.ts b/packages/n4s/src/rules/__tests__/isBoolean.test.ts index 565da2793..467a307c4 100644 --- a/packages/n4s/src/rules/__tests__/isBoolean.test.ts +++ b/packages/n4s/src/rules/__tests__/isBoolean.test.ts @@ -1,4 +1,4 @@ -import { enforce } from 'enforce'; +import { enforce } from '@/runtime/enforce'; describe('isBoolean', () => { it('Should pass for a boolean value', () => { diff --git a/packages/n4s/src/rules/__tests__/isEven.test.ts b/packages/n4s/src/rules/__tests__/isEven.test.ts index c96438f06..b96df8f09 100644 --- a/packages/n4s/src/rules/__tests__/isEven.test.ts +++ b/packages/n4s/src/rules/__tests__/isEven.test.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { isEven } from 'isEven'; +import { isEven } from '../isEven'; describe('Tests isEven rule', () => { describe('When value is an even number', () => { diff --git a/packages/n4s/src/rules/__tests__/isKeyOf.test.ts b/packages/n4s/src/rules/__tests__/isKeyOf.test.ts index 011a9b8f7..557764c95 100644 --- a/packages/n4s/src/rules/__tests__/isKeyOf.test.ts +++ b/packages/n4s/src/rules/__tests__/isKeyOf.test.ts @@ -1,5 +1,6 @@ -import { enforce } from 'enforce'; -import { isKeyOf, isNotKeyOf } from 'isKeyOf'; +import { isKeyOf, isNotKeyOf } from '../isKeyOf'; + +import { enforce } from '@/runtime/enforce'; const FRUITES = { apples: 5, @@ -38,7 +39,7 @@ describe('Tests isKeyOf rule', () => { 'Should throw when %s is an object', v => { expect(() => enforce(DUMMY_KEY).isKeyOf({ v })).toThrow(); - } + }, ); }); }); diff --git a/packages/n4s/src/rules/__tests__/isNaN.test.ts b/packages/n4s/src/rules/__tests__/isNaN.test.ts index 4b384c4da..99960cced 100644 --- a/packages/n4s/src/rules/__tests__/isNaN.test.ts +++ b/packages/n4s/src/rules/__tests__/isNaN.test.ts @@ -1,4 +1,4 @@ -import * as NaNRule from 'isNaN'; +import * as NaNRule from '../isNaN'; describe('Tests isNaN rule', () => { it('Should return true for `NaN` value', () => { diff --git a/packages/n4s/src/rules/__tests__/isNegative.test.ts b/packages/n4s/src/rules/__tests__/isNegative.test.ts index 192cbd5e5..c876a6c4a 100644 --- a/packages/n4s/src/rules/__tests__/isNegative.test.ts +++ b/packages/n4s/src/rules/__tests__/isNegative.test.ts @@ -1,4 +1,4 @@ -import { isNegative } from 'isNegative'; +import { isNegative } from '../isNegative'; describe('Tests isNegative rule', () => { it('Should return false for zero', () => { diff --git a/packages/n4s/src/rules/__tests__/isNumber.test.ts b/packages/n4s/src/rules/__tests__/isNumber.test.ts index e9dd869db..d2d7a6f85 100644 --- a/packages/n4s/src/rules/__tests__/isNumber.test.ts +++ b/packages/n4s/src/rules/__tests__/isNumber.test.ts @@ -1,4 +1,4 @@ -import { isNumber } from 'isNumber'; +import { isNumber } from '../isNumber'; describe('Tests isNumber rule', () => { it('Should return true for a number', () => { diff --git a/packages/n4s/src/rules/__tests__/isOdd.test.ts b/packages/n4s/src/rules/__tests__/isOdd.test.ts index a4cf24efb..d7e2a0982 100644 --- a/packages/n4s/src/rules/__tests__/isOdd.test.ts +++ b/packages/n4s/src/rules/__tests__/isOdd.test.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { isOdd } from 'isOdd'; +import { isOdd } from '../isOdd'; describe('Tests isOdd rule', () => { describe('When value is an odd number', () => { diff --git a/packages/n4s/src/rules/__tests__/isTruthy.test.ts b/packages/n4s/src/rules/__tests__/isTruthy.test.ts index 41c6d478a..7d3ec23e8 100644 --- a/packages/n4s/src/rules/__tests__/isTruthy.test.ts +++ b/packages/n4s/src/rules/__tests__/isTruthy.test.ts @@ -1,4 +1,4 @@ -import { isTruthy } from 'isTruthy'; +import { isTruthy } from '../isTruthy'; describe('Tests isTruthy rule', () => { const values = [ diff --git a/packages/n4s/src/rules/__tests__/isValueOf.test.ts b/packages/n4s/src/rules/__tests__/isValueOf.test.ts index 57515b63e..c9d624f50 100644 --- a/packages/n4s/src/rules/__tests__/isValueOf.test.ts +++ b/packages/n4s/src/rules/__tests__/isValueOf.test.ts @@ -1,5 +1,6 @@ -import { enforce } from 'enforce'; -import { isValueOf, isNotValueOf } from 'isValueOf'; +import { isValueOf, isNotValueOf } from '../isValueOf'; + +import { enforce } from '@/runtime/enforce'; const testObject = { a: 'Bravo', diff --git a/packages/n4s/src/rules/__tests__/lessThan.test.ts b/packages/n4s/src/rules/__tests__/lessThan.test.ts index a79f53b7c..31d9bd4e8 100644 --- a/packages/n4s/src/rules/__tests__/lessThan.test.ts +++ b/packages/n4s/src/rules/__tests__/lessThan.test.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { lessThan } from 'lessThan'; +import { lessThan } from '@/rules/lessThan'; describe('Tests lessThan rule', () => { describe('Arguments are numbers', () => { @@ -59,7 +59,7 @@ describe('Tests lessThan rule', () => { // @ts-expect-error - Testing invalid input expect(lessThan(element, 0)).toBe(false); }); - } + }, ); }); }); diff --git a/packages/n4s/src/rules/__tests__/lessThanOrEquals.test.ts b/packages/n4s/src/rules/__tests__/lessThanOrEquals.test.ts index 8cddf08e7..a3805a4f7 100644 --- a/packages/n4s/src/rules/__tests__/lessThanOrEquals.test.ts +++ b/packages/n4s/src/rules/__tests__/lessThanOrEquals.test.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { lessThanOrEquals } from 'lessThanOrEquals'; +import { lessThanOrEquals } from '@/rules/lessThanOrEquals'; describe('Tests lessThanOrEquals rule', () => { describe('Arguments are numbers', () => { @@ -59,7 +59,7 @@ describe('Tests lessThanOrEquals rule', () => { // @ts-expect-error - Testing invalid input expect(lessThanOrEquals(element, 0)).toBe(false); }); - } + }, ); }); }); diff --git a/packages/n4s/src/rules/__tests__/longerThanOrEquals.test.ts b/packages/n4s/src/rules/__tests__/longerThanOrEquals.test.ts index 132297d37..9f85bba13 100644 --- a/packages/n4s/src/rules/__tests__/longerThanOrEquals.test.ts +++ b/packages/n4s/src/rules/__tests__/longerThanOrEquals.test.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { longerThanOrEquals } from 'longerThanOrEquals'; +import { longerThanOrEquals } from '../longerThanOrEquals'; describe('Tests longerThanOrEquals rule', () => { const length = 10; diff --git a/packages/n4s/src/rules/__tests__/matches.test.ts b/packages/n4s/src/rules/__tests__/matches.test.ts index 48464e318..b9a3c5e1a 100644 --- a/packages/n4s/src/rules/__tests__/matches.test.ts +++ b/packages/n4s/src/rules/__tests__/matches.test.ts @@ -1,4 +1,4 @@ -import { matches } from 'matches'; +import { matches } from '../matches'; const URL = /(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.(?=.*[a-z]){1,24}\b([-a-zA-Z0-9@:%_+.~#?&//=()]*)/, diff --git a/packages/n4s/src/rules/__tests__/ruleCondition.test.ts b/packages/n4s/src/rules/__tests__/ruleCondition.test.ts index b34635cc3..29af80c74 100644 --- a/packages/n4s/src/rules/__tests__/ruleCondition.test.ts +++ b/packages/n4s/src/rules/__tests__/ruleCondition.test.ts @@ -1,5 +1,5 @@ import { enforce } from 'n4s'; -import ruleReturn, { failing, passing } from 'ruleReturn'; +import ruleReturn, { failing, passing } from '@/lib/ruleReturn'; describe('enforce.condition', () => { it('Should pass down enforced value to condition as the first argument', () => { @@ -17,7 +17,7 @@ describe('enforce.condition', () => { expect(enforce.condition(() => false).run(1)).toEqual(failing()); expect(enforce.condition(() => failing()).run(1)).toEqual(failing()); expect( - enforce.condition(() => ruleReturn(false, 'failure message')).run(1) + enforce.condition(() => ruleReturn(false, 'failure message')).run(1), ).toEqual(ruleReturn(false, 'failure message')); }); @@ -25,7 +25,7 @@ describe('enforce.condition', () => { expect(enforce.condition(() => true).run(1)).toEqual(passing()); expect(enforce.condition(() => passing()).run(1)).toEqual(passing()); expect( - enforce.condition(() => ruleReturn(true, 'success message')).run(1) + enforce.condition(() => ruleReturn(true, 'success message')).run(1), ).toEqual(passing()); }); }); @@ -37,7 +37,7 @@ describe('enforce.condition', () => { expect(() => enforce(1).condition(() => failing())).toThrow(); expect(() => - enforce(1).condition(() => ruleReturn(false, 'failure message')) + enforce(1).condition(() => ruleReturn(false, 'failure message')), ).toThrow(); }); @@ -47,7 +47,7 @@ describe('enforce.condition', () => { expect(() => enforce(1).condition(() => passing())).not.toThrow(); expect(() => - enforce(1).condition(() => ruleReturn(true, 'success message')) + enforce(1).condition(() => ruleReturn(true, 'success message')), ).not.toThrow(); }); }); diff --git a/packages/n4s/src/rules/__tests__/rules.test.ts b/packages/n4s/src/rules/__tests__/rules.test.ts index e2cdab9a7..015e37ca4 100644 --- a/packages/n4s/src/rules/__tests__/rules.test.ts +++ b/packages/n4s/src/rules/__tests__/rules.test.ts @@ -1,4 +1,4 @@ -import rules from 'rules'; +import rules from '@/runtime/rules'; describe('Tests enforce rules API', () => { it('Should expose all enforce rules', () => { diff --git a/packages/n4s/src/rules/__tests__/shorterThan.test.ts b/packages/n4s/src/rules/__tests__/shorterThan.test.ts index 59e9faff8..247f6254a 100644 --- a/packages/n4s/src/rules/__tests__/shorterThan.test.ts +++ b/packages/n4s/src/rules/__tests__/shorterThan.test.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { shorterThan } from 'shorterThan'; +import { shorterThan } from '../shorterThan'; describe('Tests shorterThan rule', () => { const length = 10; diff --git a/packages/n4s/src/rules/__tests__/shorterThanOrEquals.test.ts b/packages/n4s/src/rules/__tests__/shorterThanOrEquals.test.ts index 17fa41a34..c78431372 100644 --- a/packages/n4s/src/rules/__tests__/shorterThanOrEquals.test.ts +++ b/packages/n4s/src/rules/__tests__/shorterThanOrEquals.test.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { shorterThanOrEquals } from 'shorterThanOrEquals'; +import { shorterThanOrEquals } from '../shorterThanOrEquals'; describe('Tests shorterThanOrEquals rule', () => { const length = 10; diff --git a/packages/n4s/src/rules/__tests__/startsWith.test.ts b/packages/n4s/src/rules/__tests__/startsWith.test.ts index 7e9714053..f0e908355 100644 --- a/packages/n4s/src/rules/__tests__/startsWith.test.ts +++ b/packages/n4s/src/rules/__tests__/startsWith.test.ts @@ -1,4 +1,4 @@ -import { startsWith } from 'startsWith'; +import { startsWith } from '../startsWith'; describe('Tests isArray rule', () => { const word = 'meow'; diff --git a/packages/n4s/src/rules/isBetween.ts b/packages/n4s/src/rules/isBetween.ts index d3b75bfb8..c74a8655f 100644 --- a/packages/n4s/src/rules/isBetween.ts +++ b/packages/n4s/src/rules/isBetween.ts @@ -1,12 +1,12 @@ import { bindNot } from 'vest-utils'; -import { greaterThanOrEquals as gte } from 'greaterThanOrEquals'; -import { lessThanOrEquals as lte } from 'lessThanOrEquals'; +import { greaterThanOrEquals as gte } from '@/rules/greaterThanOrEquals'; +import { lessThanOrEquals as lte } from '@/rules/lessThanOrEquals'; export function isBetween( value: number | string, min: number | string, - max: number | string + max: number | string, ): boolean { return gte(value, min) && lte(value, max); } diff --git a/packages/n4s/src/rules/isEven.ts b/packages/n4s/src/rules/isEven.ts index 2757a7729..78ae73368 100644 --- a/packages/n4s/src/rules/isEven.ts +++ b/packages/n4s/src/rules/isEven.ts @@ -1,6 +1,6 @@ import { isNumeric } from 'vest-utils'; -import type { RuleValue } from 'runtimeRules'; +import type { RuleValue } from '@/runtime/runtimeRules'; /** * Validates that a given value is an even number diff --git a/packages/n4s/src/rules/isNegative.ts b/packages/n4s/src/rules/isNegative.ts index a513e2a40..b146668e8 100644 --- a/packages/n4s/src/rules/isNegative.ts +++ b/packages/n4s/src/rules/isNegative.ts @@ -1,4 +1,4 @@ -import { lessThan } from 'lessThan'; +import { lessThan } from '@/rules/lessThan'; export function isNegative(value: number | string): boolean { return lessThan(value, 0); diff --git a/packages/n4s/src/rules/isOdd.ts b/packages/n4s/src/rules/isOdd.ts index 5f90b7855..e0a5c147c 100644 --- a/packages/n4s/src/rules/isOdd.ts +++ b/packages/n4s/src/rules/isOdd.ts @@ -1,6 +1,6 @@ import { isNumeric } from 'vest-utils'; -import type { RuleValue } from 'runtimeRules'; +import type { RuleValue } from '@/runtime/runtimeRules'; /** * Validates that a given value is an odd number */ diff --git a/packages/n4s/src/rules/lessThanOrEquals.ts b/packages/n4s/src/rules/lessThanOrEquals.ts index c48771105..46e71bb24 100644 --- a/packages/n4s/src/rules/lessThanOrEquals.ts +++ b/packages/n4s/src/rules/lessThanOrEquals.ts @@ -1,10 +1,10 @@ import { numberEquals } from 'vest-utils'; -import { lessThan } from 'lessThan'; +import { lessThan } from '@/rules/lessThan'; export function lessThanOrEquals( value: string | number, - lte: string | number + lte: string | number, ): boolean { return numberEquals(value, lte) || lessThan(value, lte); } diff --git a/packages/n4s/src/rules/longerThanOrEquals.ts b/packages/n4s/src/rules/longerThanOrEquals.ts index 7a1e8dec3..911dcece3 100644 --- a/packages/n4s/src/rules/longerThanOrEquals.ts +++ b/packages/n4s/src/rules/longerThanOrEquals.ts @@ -1,8 +1,8 @@ -import { greaterThanOrEquals } from 'greaterThanOrEquals'; +import { greaterThanOrEquals } from '@/rules/greaterThanOrEquals'; export function longerThanOrEquals( value: string | unknown[], - arg1: string | number + arg1: string | number, ): boolean { return greaterThanOrEquals(value.length, arg1); } diff --git a/packages/n4s/src/rules/ruleCondition.ts b/packages/n4s/src/rules/ruleCondition.ts index 7cf682df4..6830ab23a 100644 --- a/packages/n4s/src/rules/ruleCondition.ts +++ b/packages/n4s/src/rules/ruleCondition.ts @@ -1,8 +1,8 @@ -import type { RuleReturn } from 'ruleReturn'; +import type { RuleReturn } from '@/lib/ruleReturn'; export function condition( value: any, - callback: (value: any) => RuleReturn + callback: (value: any) => RuleReturn, ): RuleReturn { try { return callback(value); diff --git a/packages/n4s/src/rules/shorterThan.ts b/packages/n4s/src/rules/shorterThan.ts index 6e1169ca1..1ee82f178 100644 --- a/packages/n4s/src/rules/shorterThan.ts +++ b/packages/n4s/src/rules/shorterThan.ts @@ -1,8 +1,8 @@ -import { lessThan } from 'lessThan'; +import { lessThan } from '@/rules/lessThan'; export function shorterThan( value: string | unknown[], - arg1: string | number + arg1: string | number, ): boolean { return lessThan(value.length, arg1); } diff --git a/packages/n4s/src/rules/shorterThanOrEquals.ts b/packages/n4s/src/rules/shorterThanOrEquals.ts index 93a89ad90..a68b791d0 100644 --- a/packages/n4s/src/rules/shorterThanOrEquals.ts +++ b/packages/n4s/src/rules/shorterThanOrEquals.ts @@ -1,8 +1,8 @@ -import { lessThanOrEquals } from 'lessThanOrEquals'; +import { lessThanOrEquals } from '@/rules/lessThanOrEquals'; export function shorterThanOrEquals( value: string | unknown[], - arg1: string | number + arg1: string | number, ): boolean { return lessThanOrEquals(value.length, arg1); } diff --git a/packages/n4s/src/runtime/__tests__/enforceContext.test.ts b/packages/n4s/src/runtime/__tests__/enforceContext.test.ts index 0eeb5a608..a31f80d6c 100644 --- a/packages/n4s/src/runtime/__tests__/enforceContext.test.ts +++ b/packages/n4s/src/runtime/__tests__/enforceContext.test.ts @@ -1,5 +1,5 @@ -import { enforce } from 'enforce'; -import * as ruleReturn from 'ruleReturn'; +import { enforce } from '@/runtime/enforce'; +import * as ruleReturn from '@/lib/ruleReturn'; import 'schema'; import 'compounds'; @@ -56,12 +56,12 @@ describe('enforce.context', () => { // first.parent() === name expect(keepContext.mock.calls[0][0].parent()).toEqual( - keepContext.mock.calls[1][0] + keepContext.mock.calls[1][0], ); // siblings[0].parent() === siblings expect(keepContext.mock.calls[2][0].parent()).toEqual( - keepContext.mock.calls[3][0] + keepContext.mock.calls[3][0], ); }); @@ -85,7 +85,7 @@ describe('enforce.context', () => { .someCustomRule(); expect( - keepContext.mock.calls[0][0].parent().parent().parent() + keepContext.mock.calls[0][0].parent().parent().parent(), ).toBeNull(); expect(keepContext.mock.calls[1][0].parent().parent()).toBeNull(); expect(keepContext.mock.calls[4][0].parent()).toBeNull(); @@ -152,7 +152,7 @@ describe('enforce.context', () => { describe('enforce.isArrayOf', () => { it('passes the current value into the context', () => { enforce(['Elle', 'Tester', 'Sophie']).isArrayOf( - enforce.isString().someCustomRule() + enforce.isString().someCustomRule(), ); expect(keepContext.mock.calls[0][0].value).toBe('Elle'); @@ -162,7 +162,7 @@ describe('enforce.context', () => { it('passes the current index into the context meta field', () => { enforce(['Elle', 'Tester', 'Sophie']).isArrayOf( - enforce.isString().someCustomRule() + enforce.isString().someCustomRule(), ); expect(keepContext.mock.calls[0][0].meta).toEqual({ index: 0 }); expect(keepContext.mock.calls[1][0].meta).toEqual({ index: 1 }); @@ -180,9 +180,9 @@ describe('enforce.context', () => { }).shape({ username: enforce.isString(), friends: enforce.isArrayOf( - enforce.isString().isFriendTheSameAsUser() + enforce.isString().isFriendTheSameAsUser(), ), - }) + }), ).toThrow(); }); diff --git a/packages/n4s/src/runtime/__tests__/message.test.ts b/packages/n4s/src/runtime/__tests__/message.test.ts index 8c9ca70b0..6d1fc3925 100644 --- a/packages/n4s/src/runtime/__tests__/message.test.ts +++ b/packages/n4s/src/runtime/__tests__/message.test.ts @@ -1,30 +1,30 @@ -import { enforce } from 'enforce'; -import ruleReturn from 'ruleReturn'; +import { enforce } from '@/runtime/enforce'; +import ruleReturn from '@/lib/ruleReturn'; describe('enforce..message()', () => { it('Should set the failure message in builtin rules', () => { expect( - enforce.equals(false).message('oof. Expected true to be false').run(true) + enforce.equals(false).message('oof. Expected true to be false').run(true), ).toEqual(ruleReturn(false, 'oof. Expected true to be false')); expect( enforce .equals(false) .message(() => 'oof. Expected true to be false') - .run(true) + .run(true), ).toEqual(ruleReturn(false, 'oof. Expected true to be false')); }); it('Should set the failure message in custom rules', () => { expect( - enforce.ruleWithFailureMessage().message('oof. Failed again!').run(true) + enforce.ruleWithFailureMessage().message('oof. Failed again!').run(true), ).toEqual(ruleReturn(false, 'oof. Failed again!')); expect( enforce .ruleWithFailureMessage() .message(() => 'oof. Failed again!') - .run(true) + .run(true), ).toEqual(ruleReturn(false, 'oof. Failed again!')); }); @@ -33,7 +33,7 @@ describe('enforce..message()', () => { const msg = jest.fn(() => 'some message'); const arg = {}; expect(enforce.equals(false).message(msg).run(arg)).toEqual( - ruleReturn(false, 'some message') + ruleReturn(false, 'some message'), ); expect(msg).toHaveBeenCalledWith(arg, undefined); }); @@ -42,7 +42,7 @@ describe('enforce..message()', () => { const msg = jest.fn(() => 'some message'); const arg = {}; expect( - enforce.ruleWithFailureMessage(false).message(msg).run(arg) + enforce.ruleWithFailureMessage(false).message(msg).run(arg), ).toEqual(ruleReturn(false, 'some message')); expect(msg).toHaveBeenCalledWith(arg, 'This should not be seen!'); }); diff --git a/packages/n4s/src/runtime/enforce.ts b/packages/n4s/src/runtime/enforce.ts index 352a815df..ab76a71ca 100644 --- a/packages/n4s/src/runtime/enforce.ts +++ b/packages/n4s/src/runtime/enforce.ts @@ -1,9 +1,10 @@ import { assign } from 'vest-utils'; -import { ctx, EnforceContext } from 'enforceContext'; -import enforceEager, { EnforceEager } from 'enforceEager'; -import genEnforceLazy, { LazyRules } from 'genEnforceLazy'; -import { Rule, baseRules, getRule } from 'runtimeRules'; +import enforceEager, { EnforceEager } from './enforceEager'; + +import { ctx, EnforceContext } from '@/runtime/enforceContext'; +import genEnforceLazy, { LazyRules } from '@/runtime/genEnforceLazy'; +import { Rule, baseRules, getRule } from '@/runtime/runtimeRules'; /** * Enforce is quite complicated, I want to explain it in detail. * It is dynamic in nature, so a lot of proxy objects are involved. diff --git a/packages/n4s/src/runtime/enforceEager.ts b/packages/n4s/src/runtime/enforceEager.ts index b66194a93..ac1be31b9 100644 --- a/packages/n4s/src/runtime/enforceEager.ts +++ b/packages/n4s/src/runtime/enforceEager.ts @@ -1,8 +1,8 @@ import { invariant, StringObject, isNullish, Maybe } from 'vest-utils'; -import { ctx } from 'enforceContext'; -import { getRule, RuleValue, Args, RuleBase } from 'runtimeRules'; -import { transformResult } from 'transformResult'; +import { transformResult } from '@/lib/transformResult'; +import { ctx } from '@/runtime/enforceContext'; +import { getRule, RuleValue, Args, RuleBase } from '@/runtime/runtimeRules'; type IRules = n4s.IRules & EnforceEagerReturn>; type TModifiers = { diff --git a/packages/n4s/src/runtime/genEnforceLazy.ts b/packages/n4s/src/runtime/genEnforceLazy.ts index c0aedc535..41fa633f2 100644 --- a/packages/n4s/src/runtime/genEnforceLazy.ts +++ b/packages/n4s/src/runtime/genEnforceLazy.ts @@ -1,3 +1,4 @@ +import { ctx } from '@/runtime/enforceContext'; import { mapFirst, optionalFunctionValue, @@ -7,10 +8,12 @@ import { DynamicValue, } from 'vest-utils'; -import { ctx } from 'enforceContext'; -import ruleReturn, { defaultToPassing, RuleDetailedResult } from 'ruleReturn'; -import { RuleValue, Args, getRule } from 'runtimeRules'; -import { transformResult } from 'transformResult'; +import ruleReturn, { + defaultToPassing, + RuleDetailedResult, +} from '@/lib/ruleReturn'; +import { transformResult } from '@/lib/transformResult'; +import { RuleValue, Args, getRule } from '@/runtime/runtimeRules'; // eslint-disable-next-line max-lines-per-function export default function genEnforceLazy(key: string) { @@ -26,7 +29,7 @@ export default function genEnforceLazy(key: string) { const rule = getRule(ruleName); registeredRules.push((value: RuleValue) => - transformResult(rule(value, ...args), ruleName, value, ...args) + transformResult(rule(value, ...args), ruleName, value, ...args), ); let proxy = { @@ -40,10 +43,10 @@ export default function genEnforceLazy(key: string) { ruleReturn( !!res.pass, optionalFunctionValue(lazyMessage, value, res.message) ?? - res.message - ) + res.message, + ), ); - }) + }), ); }, test: (value: RuleValue): boolean => proxy.run(value).pass, diff --git a/packages/n4s/src/runtime/rules.ts b/packages/n4s/src/runtime/rules.ts index e01138786..f7f5379bf 100644 --- a/packages/n4s/src/runtime/rules.ts +++ b/packages/n4s/src/runtime/rules.ts @@ -20,30 +20,30 @@ import { isNotEmpty, } from 'vest-utils'; -import { endsWith, doesNotEndWith } from 'endsWith'; -import { equals, notEquals } from 'equals'; -import { greaterThanOrEquals } from 'greaterThanOrEquals'; -import { inside, notInside } from 'inside'; -import { isBetween, isNotBetween } from 'isBetween'; -import { isBlank, isNotBlank } from 'isBlank'; -import { isBoolean, isNotBoolean } from 'isBoolean'; -import { isEven } from 'isEven'; -import { isKeyOf, isNotKeyOf } from 'isKeyOf'; -import { isNaN, isNotNaN } from 'isNaN'; -import { isNegative } from 'isNegative'; -import { isNumber, isNotNumber } from 'isNumber'; -import { isOdd } from 'isOdd'; -import { isString, isNotString } from 'isString'; -import { isTruthy, isFalsy } from 'isTruthy'; -import { isValueOf, isNotValueOf } from 'isValueOf'; -import { lessThan } from 'lessThan'; -import { lessThanOrEquals } from 'lessThanOrEquals'; -import { longerThanOrEquals } from 'longerThanOrEquals'; -import { matches, notMatches } from 'matches'; -import { condition } from 'ruleCondition'; -import { shorterThan } from 'shorterThan'; -import { shorterThanOrEquals } from 'shorterThanOrEquals'; -import { startsWith, doesNotStartWith } from 'startsWith'; +import { endsWith, doesNotEndWith } from '@/rules/endsWith'; +import { equals, notEquals } from '@/rules/equals'; +import { greaterThanOrEquals } from '@/rules/greaterThanOrEquals'; +import { inside, notInside } from '@/rules/inside'; +import { isBetween, isNotBetween } from '@/rules/isBetween'; +import { isBlank, isNotBlank } from '@/rules/isBlank'; +import { isBoolean, isNotBoolean } from '@/rules/isBoolean'; +import { isEven } from '@/rules/isEven'; +import { isKeyOf, isNotKeyOf } from '@/rules/isKeyOf'; +import { isNaN, isNotNaN } from '@/rules/isNaN'; +import { isNegative } from '@/rules/isNegative'; +import { isNumber, isNotNumber } from '@/rules/isNumber'; +import { isOdd } from '@/rules/isOdd'; +import { isString, isNotString } from '@/rules/isString'; +import { isTruthy, isFalsy } from '@/rules/isTruthy'; +import { isValueOf, isNotValueOf } from '@/rules/isValueOf'; +import { lessThan } from '@/rules/lessThan'; +import { lessThanOrEquals } from '@/rules/lessThanOrEquals'; +import { longerThanOrEquals } from '@/rules/longerThanOrEquals'; +import { matches, notMatches } from '@/rules/matches'; +import { condition } from '@/rules/ruleCondition'; +import { shorterThan } from '@/rules/shorterThan'; +import { shorterThanOrEquals } from '@/rules/shorterThanOrEquals'; +import { startsWith, doesNotStartWith } from '@/rules/startsWith'; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, max-lines-per-function export default function rules() { diff --git a/packages/n4s/src/runtime/runtimeRules.ts b/packages/n4s/src/runtime/runtimeRules.ts index e437fffab..02f65fa54 100644 --- a/packages/n4s/src/runtime/runtimeRules.ts +++ b/packages/n4s/src/runtime/runtimeRules.ts @@ -1,7 +1,7 @@ import type { DropFirst } from 'vest-utils'; -import type { RuleReturn } from 'ruleReturn'; -import rules from 'rules'; +import type { RuleReturn } from '@/lib/ruleReturn'; +import rules from '@/runtime/rules'; export type Args = any[]; diff --git a/packages/n4s/tsconfig.json b/packages/n4s/tsconfig.json index 06f650e9d..fca81718b 100644 --- a/packages/n4s/tsconfig.json +++ b/packages/n4s/tsconfig.json @@ -7,57 +7,8 @@ "declarationMap": true, "outDir": "./dist", "paths": { - "n4s": ["./src/n4s.ts"], - "runtimeRules": ["./src/runtime/runtimeRules.ts"], - "rules": ["./src/runtime/rules.ts"], - "genEnforceLazy": ["./src/runtime/genEnforceLazy.ts"], - "enforceEager": ["./src/runtime/enforceEager.ts"], - "enforceContext": ["./src/runtime/enforceContext.ts"], - "enforce": ["./src/runtime/enforce.ts"], - "startsWith": ["./src/rules/startsWith.ts"], - "shorterThanOrEquals": ["./src/rules/shorterThanOrEquals.ts"], - "shorterThan": ["./src/rules/shorterThan.ts"], - "ruleCondition": ["./src/rules/ruleCondition.ts"], - "matches": ["./src/rules/matches.ts"], - "longerThanOrEquals": ["./src/rules/longerThanOrEquals.ts"], - "lessThanOrEquals": ["./src/rules/lessThanOrEquals.ts"], - "lessThan": ["./src/rules/lessThan.ts"], - "isValueOf": ["./src/rules/isValueOf.ts"], - "isTruthy": ["./src/rules/isTruthy.ts"], - "isString": ["./src/rules/isString.ts"], - "isOdd": ["./src/rules/isOdd.ts"], - "isNumber": ["./src/rules/isNumber.ts"], - "isNegative": ["./src/rules/isNegative.ts"], - "isNaN": ["./src/rules/isNaN.ts"], - "isKeyOf": ["./src/rules/isKeyOf.ts"], - "isEven": ["./src/rules/isEven.ts"], - "isBoolean": ["./src/rules/isBoolean.ts"], - "isBlank": ["./src/rules/isBlank.ts"], - "isBetween": ["./src/rules/isBetween.ts"], - "inside": ["./src/rules/inside.ts"], - "greaterThanOrEquals": ["./src/rules/greaterThanOrEquals.ts"], - "equals": ["./src/rules/equals.ts"], - "endsWith": ["./src/rules/endsWith.ts"], - "shape": ["./src/plugins/schema/shape.ts"], - "schemaTypes": ["./src/plugins/schema/schemaTypes.ts"], - "partial": ["./src/plugins/schema/partial.ts"], - "optional": ["./src/plugins/schema/optional.ts"], - "loose": ["./src/plugins/schema/loose.ts"], - "isArrayOf": ["./src/plugins/schema/isArrayOf.ts"], - "oneOf": ["./src/plugins/compounds/oneOf.ts"], - "noneOf": ["./src/plugins/compounds/noneOf.ts"], - "anyOf": ["./src/plugins/compounds/anyOf.ts"], - "allOf": ["./src/plugins/compounds/allOf.ts"], - "transformResult": ["./src/lib/transformResult.ts"], - "runLazyRule": ["./src/lib/runLazyRule.ts"], - "ruleReturn": ["./src/lib/ruleReturn.ts"], - "enforceUtilityTypes": ["./src/lib/enforceUtilityTypes.ts"], - "schema": ["./src/exports/schema.ts"], - "isURL": ["./src/exports/isURL.ts"], - "email": ["./src/exports/email.ts"], - "date": ["./src/exports/date.ts"], - "compounds": ["./src/exports/compounds.ts"], - "compose": ["./src/exports/compose.ts"] + "@exports/*": ["src/exports/*"], + "@/*": ["src/*"] } } } diff --git a/packages/vast/tsconfig.json b/packages/vast/tsconfig.json index 9f048eb70..fca81718b 100644 --- a/packages/vast/tsconfig.json +++ b/packages/vast/tsconfig.json @@ -7,7 +7,8 @@ "declarationMap": true, "outDir": "./dist", "paths": { - "vast": ["./src/vast.ts"] + "@exports/*": ["src/exports/*"], + "@/*": ["src/*"] } } } diff --git a/packages/vest-utils/src/Predicates.ts b/packages/vest-utils/src/Predicates.ts index 45b3a89a1..4cec47ee5 100644 --- a/packages/vest-utils/src/Predicates.ts +++ b/packages/vest-utils/src/Predicates.ts @@ -1,6 +1,6 @@ -import { isEmpty } from 'isEmpty'; -import optionalFunctionValue from 'optionalFunctionValue'; -import { Predicate } from 'utilityTypes'; +import { isEmpty } from '@/isEmpty'; +import optionalFunctionValue from '@/optionalFunctionValue'; +import { Predicate } from '@/utilityTypes'; export function all(...p: Predicate[]): (value: T) => boolean { return (value: T) => diff --git a/packages/vest-utils/src/SimpleStateMachine.ts b/packages/vest-utils/src/SimpleStateMachine.ts index 9f07939d6..cbe571020 100644 --- a/packages/vest-utils/src/SimpleStateMachine.ts +++ b/packages/vest-utils/src/SimpleStateMachine.ts @@ -1,4 +1,4 @@ -import { CB } from 'utilityTypes'; +import { CB } from './utilityTypes'; const STATE_WILD_CARD = '*'; type TStateWildCard = typeof STATE_WILD_CARD; @@ -20,7 +20,7 @@ export type TStateMachineApi = { }; export function StateMachine( - machine: TStateMachine + machine: TStateMachine, ): TStateMachineApi { let state = machine.initial; diff --git a/packages/vest-utils/src/StringObject.ts b/packages/vest-utils/src/StringObject.ts index 0970472bd..2a774a536 100644 --- a/packages/vest-utils/src/StringObject.ts +++ b/packages/vest-utils/src/StringObject.ts @@ -1,5 +1,5 @@ -import optionalFunctionValue from 'optionalFunctionValue'; -import type { Stringable } from 'utilityTypes'; +import optionalFunctionValue from '@/optionalFunctionValue'; +import type { Stringable } from '@/utilityTypes'; // eslint-disable-next-line @typescript-eslint/ban-types export function StringObject(value?: Stringable): String { diff --git a/packages/vest-utils/src/__tests__/Predicates.test.ts b/packages/vest-utils/src/__tests__/Predicates.test.ts index 7b2b23d3f..b4ad5fa33 100644 --- a/packages/vest-utils/src/__tests__/Predicates.test.ts +++ b/packages/vest-utils/src/__tests__/Predicates.test.ts @@ -1,4 +1,4 @@ -import { all, any } from 'Predicates'; +import { all, any } from '../Predicates'; describe('Predicates', () => { describe('all', () => { @@ -9,7 +9,7 @@ describe('Predicates', () => { it('Should return true if all predicates return true', () => { const predicate = all( value => value > 0, - value => value < 10 + value => value < 10, ); expect(predicate(5)).toBe(true); @@ -18,7 +18,7 @@ describe('Predicates', () => { it('Should return false if any predicate returns false', () => { const predicate = all( value => value > 0, - value => value < 10 + value => value < 10, ); expect(predicate(15)).toBe(false); @@ -35,7 +35,7 @@ describe('Predicates', () => { value => value > 0, value => value < 10, // @ts-ignore - Testing invalid input - 'not a function' + 'not a function', ); expect(predicate(15)).toBe(false); @@ -71,21 +71,21 @@ describe('Predicates', () => { expect( any( value => value > 0, - value => value === 10 - )(5) + value => value === 10, + )(5), ).toBe(true); expect( any( value => value === 10, - value => value > 0 - )(5) + value => value > 0, + )(5), ).toBe(true); }); it('Should return true if all predicates return true', () => { const predicate = any( value => value > 0, - value => value === 10 + value => value === 10, ); expect(predicate(10)).toBe(true); @@ -94,7 +94,7 @@ describe('Predicates', () => { it('Should return false if all predicates return false', () => { const predicate = any( value => value > 0, - value => value === 10 + value => value === 10, ); expect(predicate(-5)).toBe(false); diff --git a/packages/vest-utils/src/__tests__/SimpleStateMachine.test.ts b/packages/vest-utils/src/__tests__/SimpleStateMachine.test.ts index 276903c7b..c19220d2e 100644 --- a/packages/vest-utils/src/__tests__/SimpleStateMachine.test.ts +++ b/packages/vest-utils/src/__tests__/SimpleStateMachine.test.ts @@ -1,4 +1,4 @@ -import { StateMachine } from 'SimpleStateMachine'; +import { StateMachine } from '../SimpleStateMachine'; describe('SimpleStateMachine', () => { test('sample', () => { diff --git a/packages/vest-utils/src/__tests__/StringObject.test.ts b/packages/vest-utils/src/__tests__/StringObject.test.ts index 3bc262cb6..a9641ae98 100644 --- a/packages/vest-utils/src/__tests__/StringObject.test.ts +++ b/packages/vest-utils/src/__tests__/StringObject.test.ts @@ -1,4 +1,4 @@ -import { StringObject } from 'StringObject'; +import { StringObject } from '../StringObject'; describe('StringObject', () => { test('returns an instance of String', () => { diff --git a/packages/vest-utils/src/__tests__/asArray.test.ts b/packages/vest-utils/src/__tests__/asArray.test.ts index 837ffa26d..61dad7d2f 100644 --- a/packages/vest-utils/src/__tests__/asArray.test.ts +++ b/packages/vest-utils/src/__tests__/asArray.test.ts @@ -1,4 +1,4 @@ -import asArray from 'asArray'; +import asArray from '@/asArray'; describe('asArray', () => { it('should return an array', () => { diff --git a/packages/vest-utils/src/__tests__/bus.test.ts b/packages/vest-utils/src/__tests__/bus.test.ts index 48d3980d7..55e878ade 100644 --- a/packages/vest-utils/src/__tests__/bus.test.ts +++ b/packages/vest-utils/src/__tests__/bus.test.ts @@ -1,4 +1,4 @@ -import { createBus } from 'bus'; +import { createBus } from '@/bus'; describe('bus', () => { it('should be a function', () => { diff --git a/packages/vest-utils/src/__tests__/callEach.test.ts b/packages/vest-utils/src/__tests__/callEach.test.ts index c4eb7e916..4b432e1ba 100644 --- a/packages/vest-utils/src/__tests__/callEach.test.ts +++ b/packages/vest-utils/src/__tests__/callEach.test.ts @@ -1,4 +1,4 @@ -import callEach from 'callEach'; +import callEach from '@/callEach'; describe('callEach', () => { it('should call all functions in the array', () => { diff --git a/packages/vest-utils/src/__tests__/either.test.ts b/packages/vest-utils/src/__tests__/either.test.ts index dbabe589b..a892886c5 100644 --- a/packages/vest-utils/src/__tests__/either.test.ts +++ b/packages/vest-utils/src/__tests__/either.test.ts @@ -1,4 +1,4 @@ -import either from 'either'; +import either from '@/either'; describe('either', () => { it('returns true if one argument is truthy and the other is falsy', () => { diff --git a/packages/vest-utils/src/__tests__/greaterThan.test.ts b/packages/vest-utils/src/__tests__/greaterThan.test.ts index 8badeedb8..06545ab23 100644 --- a/packages/vest-utils/src/__tests__/greaterThan.test.ts +++ b/packages/vest-utils/src/__tests__/greaterThan.test.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { greaterThan } from 'greaterThan'; +import { greaterThan } from '@/greaterThan'; describe('Tests greaterThan rule', () => { describe('Arguments are numbers', () => { @@ -62,7 +62,7 @@ describe('Tests greaterThan rule', () => { // @ts-expect-error - testing invalid input expect(greaterThan(element, 0)).toBe(false); }); - } + }, ); }); }); diff --git a/packages/vest-utils/src/__tests__/isArray.test.ts b/packages/vest-utils/src/__tests__/isArray.test.ts index 4897f856b..a30c76cc9 100644 --- a/packages/vest-utils/src/__tests__/isArray.test.ts +++ b/packages/vest-utils/src/__tests__/isArray.test.ts @@ -1,4 +1,4 @@ -import { isArray } from 'isArrayValue'; +import { isArray } from '@/isArrayValue'; describe('Tests isArray rule', () => { it('Should return true for an empty array', () => { diff --git a/packages/vest-utils/src/__tests__/isBoolean.test.ts b/packages/vest-utils/src/__tests__/isBoolean.test.ts index 41e541c65..a29aac055 100644 --- a/packages/vest-utils/src/__tests__/isBoolean.test.ts +++ b/packages/vest-utils/src/__tests__/isBoolean.test.ts @@ -1,4 +1,4 @@ -import isBoolean from 'isBooleanValue'; +import isBoolean from '@/isBooleanValue'; describe('isBoolean', () => { it('Should pass for a boolean value', () => { diff --git a/packages/vest-utils/src/__tests__/isNull.test.ts b/packages/vest-utils/src/__tests__/isNull.test.ts index 7e0b09455..f80d1b2dd 100644 --- a/packages/vest-utils/src/__tests__/isNull.test.ts +++ b/packages/vest-utils/src/__tests__/isNull.test.ts @@ -1,4 +1,4 @@ -import { isNull } from 'isNull'; +import { isNull } from '@/isNull'; describe('Tests isNull rule', () => { it('Should return true for `null` value', () => { diff --git a/packages/vest-utils/src/__tests__/isNumeric.test.ts b/packages/vest-utils/src/__tests__/isNumeric.test.ts index f6f908064..5f9776166 100644 --- a/packages/vest-utils/src/__tests__/isNumeric.test.ts +++ b/packages/vest-utils/src/__tests__/isNumeric.test.ts @@ -1,4 +1,4 @@ -import { isNumeric } from 'isNumeric'; +import { isNumeric } from '@/isNumeric'; const NUMERICS = ['-10', '0', 0xff, '0xFF', '8e5', '3.1415', +10, '0144']; diff --git a/packages/vest-utils/src/__tests__/isPositive.test.ts b/packages/vest-utils/src/__tests__/isPositive.test.ts index f6cb36fc3..b075d3d95 100644 --- a/packages/vest-utils/src/__tests__/isPositive.test.ts +++ b/packages/vest-utils/src/__tests__/isPositive.test.ts @@ -1,4 +1,4 @@ -import { isPositive } from 'isPositive'; +import { isPositive } from '@/isPositive'; describe('Test isPositive rule', () => { it('Should return false for zero', () => { diff --git a/packages/vest-utils/src/__tests__/isPromise.test.ts b/packages/vest-utils/src/__tests__/isPromise.test.ts index 848da2fa6..867ea0f39 100644 --- a/packages/vest-utils/src/__tests__/isPromise.test.ts +++ b/packages/vest-utils/src/__tests__/isPromise.test.ts @@ -1,4 +1,4 @@ -import isPromise from 'isPromise'; +import isPromise from '@/isPromise'; describe('isPromise', () => { it('should return true for a Promise', () => { diff --git a/packages/vest-utils/src/__tests__/isString.test.ts b/packages/vest-utils/src/__tests__/isString.test.ts index 68475b2c9..b8524c8c9 100644 --- a/packages/vest-utils/src/__tests__/isString.test.ts +++ b/packages/vest-utils/src/__tests__/isString.test.ts @@ -1,4 +1,4 @@ -import isStringValue from 'isStringValue'; +import isStringValue from '@/isStringValue'; describe('Tests isString rule', () => { it('Should return false for non-string values', () => { diff --git a/packages/vest-utils/src/__tests__/isUndefined.test.ts b/packages/vest-utils/src/__tests__/isUndefined.test.ts index fda820080..df947e94b 100644 --- a/packages/vest-utils/src/__tests__/isUndefined.test.ts +++ b/packages/vest-utils/src/__tests__/isUndefined.test.ts @@ -1,4 +1,4 @@ -import { isUndefined } from 'isUndefined'; +import { isUndefined } from '@/isUndefined'; describe('Tests isUndefined rule', () => { it('Should return true for `undefined` value', () => { diff --git a/packages/vest-utils/src/__tests__/lengthEquals.test.ts b/packages/vest-utils/src/__tests__/lengthEquals.test.ts index 4127820ae..327c19719 100644 --- a/packages/vest-utils/src/__tests__/lengthEquals.test.ts +++ b/packages/vest-utils/src/__tests__/lengthEquals.test.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { lengthEquals } from 'lengthEquals'; +import { lengthEquals } from '@/lengthEquals'; describe('Tests lengthEquals rule', () => { const length = 10; diff --git a/packages/vest-utils/src/__tests__/longerThan.test.ts b/packages/vest-utils/src/__tests__/longerThan.test.ts index f0fe31f2e..83c91784b 100644 --- a/packages/vest-utils/src/__tests__/longerThan.test.ts +++ b/packages/vest-utils/src/__tests__/longerThan.test.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { longerThan } from 'longerThan'; +import { longerThan } from '@/longerThan'; describe('Tests longerThan rule', () => { const length = 10; diff --git a/packages/vest-utils/src/__tests__/nonnullish.test.ts b/packages/vest-utils/src/__tests__/nonnullish.test.ts index c1d5c0b96..611b0bfe6 100644 --- a/packages/vest-utils/src/__tests__/nonnullish.test.ts +++ b/packages/vest-utils/src/__tests__/nonnullish.test.ts @@ -1,4 +1,4 @@ -import { nonnullish } from 'nonnullish'; +import { nonnullish } from '../nonnullish'; describe('nonnullish', () => { it('should return the value if it is not null or undefined', () => { diff --git a/packages/vest-utils/src/__tests__/numberEquals.test.ts b/packages/vest-utils/src/__tests__/numberEquals.test.ts index 9dda865d2..70207fee2 100644 --- a/packages/vest-utils/src/__tests__/numberEquals.test.ts +++ b/packages/vest-utils/src/__tests__/numberEquals.test.ts @@ -1,6 +1,6 @@ import { faker } from '@faker-js/faker'; -import { numberEquals } from 'numberEquals'; +import { numberEquals } from '@/numberEquals'; describe('Tests numberEquals rule', () => { describe('Arguments are numbers', () => { @@ -61,7 +61,7 @@ describe('Tests numberEquals rule', () => { // @ts-expect-error - testing invalid input expect(numberEquals(element, 0)).toBe(false); }); - } + }, ); }); }); diff --git a/packages/vest-utils/src/__tests__/seq.test.ts b/packages/vest-utils/src/__tests__/seq.test.ts index 6aa8d9de1..559d39ae2 100644 --- a/packages/vest-utils/src/__tests__/seq.test.ts +++ b/packages/vest-utils/src/__tests__/seq.test.ts @@ -1,4 +1,4 @@ -import seq, { genSeq } from 'seq'; +import seq, { genSeq } from '@/seq'; describe('lib:seq', () => { it('Should return a new id on each run', () => { diff --git a/packages/vest-utils/src/__tests__/text.test.ts b/packages/vest-utils/src/__tests__/text.test.ts index 0da573924..6c3ee2db4 100644 --- a/packages/vest-utils/src/__tests__/text.test.ts +++ b/packages/vest-utils/src/__tests__/text.test.ts @@ -1,14 +1,14 @@ -import { text } from 'text'; +import { text } from '@/text'; describe('text', () => { describe('named substitutions (object)', () => { describe('When all substitutions exist', () => { it('Should replace delimited placeholders', () => { expect(text('this {t} an example', { t: 'was' })).toBe( - 'this was an example' + 'this was an example', ); expect(text('this {t1} {t2} example', { t1: 'was', t2: 'one' })).toBe( - 'this was one example' + 'this was one example', ); }); }); diff --git a/packages/vest-utils/src/__tests__/tinyState.test.ts b/packages/vest-utils/src/__tests__/tinyState.test.ts index 3b0e29bf1..8a0b25ac0 100644 --- a/packages/vest-utils/src/__tests__/tinyState.test.ts +++ b/packages/vest-utils/src/__tests__/tinyState.test.ts @@ -1,4 +1,4 @@ -import { createTinyState } from 'tinyState'; +import { createTinyState } from '../tinyState'; describe('tinyTest', () => { it('Should be a function', () => { diff --git a/packages/vest-utils/src/bus.ts b/packages/vest-utils/src/bus.ts index 875e37007..b0b29ebec 100644 --- a/packages/vest-utils/src/bus.ts +++ b/packages/vest-utils/src/bus.ts @@ -1,4 +1,4 @@ -import type { CB } from 'utilityTypes'; +import type { CB } from '@/utilityTypes'; const EVENT_WILDCARD = '*'; diff --git a/packages/vest-utils/src/cache.ts b/packages/vest-utils/src/cache.ts index 0b750e1ea..f57df2d88 100644 --- a/packages/vest-utils/src/cache.ts +++ b/packages/vest-utils/src/cache.ts @@ -1,6 +1,6 @@ -import { lengthEquals } from 'lengthEquals'; -import { longerThan } from 'longerThan'; -import { Nullable } from 'utilityTypes'; +import { lengthEquals } from '@/lengthEquals'; +import { longerThan } from '@/longerThan'; +import { Nullable } from '@/utilityTypes'; /** * Creates a cache function @@ -10,7 +10,7 @@ export default function createCache(maxSize = 1): CacheApi { const cache = ( deps: unknown[], - cacheAction: (...args: unknown[]) => T + cacheAction: (...args: unknown[]) => T, ): T => { const cacheHit = cache.get(deps); // cache hit is not null @@ -40,7 +40,7 @@ export default function createCache(maxSize = 1): CacheApi { return cacheStorage.findIndex( ([cachedDeps]) => lengthEquals(deps, cachedDeps.length) && - deps.every((dep, i) => dep === cachedDeps[i]) + deps.every((dep, i) => dep === cachedDeps[i]), ); } } diff --git a/packages/vest-utils/src/callEach.ts b/packages/vest-utils/src/callEach.ts index c776187b3..922133de9 100644 --- a/packages/vest-utils/src/callEach.ts +++ b/packages/vest-utils/src/callEach.ts @@ -1,4 +1,4 @@ -import type { CB } from 'utilityTypes'; +import type { CB } from '@/utilityTypes'; export default function callEach(arr: CB[]): void { return arr.forEach(fn => fn()); diff --git a/packages/vest-utils/src/defaultTo.ts b/packages/vest-utils/src/defaultTo.ts index 08c04def4..a2f8b8006 100644 --- a/packages/vest-utils/src/defaultTo.ts +++ b/packages/vest-utils/src/defaultTo.ts @@ -1,9 +1,9 @@ -import optionalFunctionValue from 'optionalFunctionValue'; -import { DynamicValue, Nullish } from 'utilityTypes'; +import optionalFunctionValue from '@/optionalFunctionValue'; +import { DynamicValue, Nullish } from '@/utilityTypes'; export default function defaultTo( value: DynamicValue>, - defaultValue: DynamicValue + defaultValue: DynamicValue, ): T { return optionalFunctionValue(value) ?? optionalFunctionValue(defaultValue); } diff --git a/packages/vest-utils/src/exports/__tests__/minifyObject.test.ts b/packages/vest-utils/src/exports/__tests__/minifyObject.test.ts index 06ff16d96..c19b00d1a 100644 --- a/packages/vest-utils/src/exports/__tests__/minifyObject.test.ts +++ b/packages/vest-utils/src/exports/__tests__/minifyObject.test.ts @@ -1,4 +1,4 @@ -import { expandObject, minifyObject } from 'minifyObject'; +import { expandObject, minifyObject } from '../minifyObject'; describe('minifyObject', () => { it('should be a function', () => { diff --git a/packages/vest-utils/src/exports/minifyObject.ts b/packages/vest-utils/src/exports/minifyObject.ts index 3883cf6c1..f13271696 100644 --- a/packages/vest-utils/src/exports/minifyObject.ts +++ b/packages/vest-utils/src/exports/minifyObject.ts @@ -1,9 +1,11 @@ -import { isArray } from 'isArrayValue'; -import { isEmpty } from 'isEmpty'; -import isFunction from 'isFunction'; -import { isNullish } from 'isNullish'; -import isStringValue from 'isStringValue'; -import { isObject } from 'valueIsObject'; +import { + isArray, + isEmpty, + isNullish, + isObject, + isFunction, + isStringValue, +} from 'vest-utils'; // Basic key generator that generates keys like a, b, c, ... aa, ab, ac, ... function genMinifiedKey() { diff --git a/packages/vest-utils/src/freezeAssign.ts b/packages/vest-utils/src/freezeAssign.ts index c01b1243d..c7d3dc963 100644 --- a/packages/vest-utils/src/freezeAssign.ts +++ b/packages/vest-utils/src/freezeAssign.ts @@ -1,4 +1,4 @@ -import assign from 'assign'; +import assign from '@/assign'; export function freezeAssign(...args: Partial[]): T { return Object.freeze(assign(...(args as [Partial]))); diff --git a/packages/vest-utils/src/greaterThan.ts b/packages/vest-utils/src/greaterThan.ts index 04dc56707..4cad26921 100644 --- a/packages/vest-utils/src/greaterThan.ts +++ b/packages/vest-utils/src/greaterThan.ts @@ -1,8 +1,8 @@ -import { isNumeric } from 'isNumeric'; +import { isNumeric } from '@/isNumeric'; export function greaterThan( value: number | string, - gt: number | string + gt: number | string, ): boolean { return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt); } diff --git a/packages/vest-utils/src/invariant.ts b/packages/vest-utils/src/invariant.ts index acbe2b792..398ea4839 100644 --- a/packages/vest-utils/src/invariant.ts +++ b/packages/vest-utils/src/invariant.ts @@ -1,10 +1,10 @@ -import optionalFunctionValue from 'optionalFunctionValue'; -import type { Stringable } from 'utilityTypes'; +import optionalFunctionValue from '@/optionalFunctionValue'; +import type { Stringable } from '@/utilityTypes'; export default function invariant( condition: any, // eslint-disable-next-line @typescript-eslint/ban-types - message?: String | Stringable + message?: String | Stringable, ): asserts condition { if (condition) { return; diff --git a/packages/vest-utils/src/isArrayValue.ts b/packages/vest-utils/src/isArrayValue.ts index 256cb361f..1d2c69e4a 100644 --- a/packages/vest-utils/src/isArrayValue.ts +++ b/packages/vest-utils/src/isArrayValue.ts @@ -1,4 +1,4 @@ -import bindNot from 'bindNot'; +import bindNot from '@/bindNot'; // The module is named "isArrayValue" since it // is conflicting with a nested npm dependency. diff --git a/packages/vest-utils/src/isEmpty.ts b/packages/vest-utils/src/isEmpty.ts index 07233e26c..f71705978 100644 --- a/packages/vest-utils/src/isEmpty.ts +++ b/packages/vest-utils/src/isEmpty.ts @@ -1,7 +1,8 @@ -import bindNot from 'bindNot'; -import hasOwnProperty from 'hasOwnProperty'; -import { lengthEquals } from 'lengthEquals'; -import { isObject } from 'valueIsObject'; +import hasOwnProperty from './hasOwnProperty'; +import { isObject } from './valueIsObject'; + +import bindNot from '@/bindNot'; +import { lengthEquals } from '@/lengthEquals'; export function isEmpty(value: unknown): boolean { if (!value) { diff --git a/packages/vest-utils/src/isNull.ts b/packages/vest-utils/src/isNull.ts index 495982ff3..ec1a6ce42 100644 --- a/packages/vest-utils/src/isNull.ts +++ b/packages/vest-utils/src/isNull.ts @@ -1,4 +1,4 @@ -import bindNot from 'bindNot'; +import bindNot from '@/bindNot'; export function isNull(value: unknown): value is null { return value === null; diff --git a/packages/vest-utils/src/isNullish.ts b/packages/vest-utils/src/isNullish.ts index 171d25e8a..2505a8b53 100644 --- a/packages/vest-utils/src/isNullish.ts +++ b/packages/vest-utils/src/isNullish.ts @@ -1,7 +1,7 @@ -import bindNot from 'bindNot'; -import { isNull } from 'isNull'; -import { isUndefined } from 'isUndefined'; -import { Nullish } from 'utilityTypes'; +import bindNot from '@/bindNot'; +import { isNull } from '@/isNull'; +import { isUndefined } from '@/isUndefined'; +import { Nullish } from '@/utilityTypes'; export function isNullish(value: any): value is Nullish { return isNull(value) || isUndefined(value); diff --git a/packages/vest-utils/src/isNumeric.ts b/packages/vest-utils/src/isNumeric.ts index 60c0233ef..d69c57950 100644 --- a/packages/vest-utils/src/isNumeric.ts +++ b/packages/vest-utils/src/isNumeric.ts @@ -1,4 +1,4 @@ -import bindNot from 'bindNot'; +import bindNot from '@/bindNot'; export function isNumeric(value: string | number): boolean { const str = String(value); diff --git a/packages/vest-utils/src/isPositive.ts b/packages/vest-utils/src/isPositive.ts index 59d2c8768..a5181f239 100644 --- a/packages/vest-utils/src/isPositive.ts +++ b/packages/vest-utils/src/isPositive.ts @@ -1,4 +1,4 @@ -import { greaterThan } from 'greaterThan'; +import { greaterThan } from '@/greaterThan'; export function isPositive(value: number | string): boolean { return greaterThan(value, 0); diff --git a/packages/vest-utils/src/isPromise.ts b/packages/vest-utils/src/isPromise.ts index 33dbbb581..0fdbe2522 100644 --- a/packages/vest-utils/src/isPromise.ts +++ b/packages/vest-utils/src/isPromise.ts @@ -1,4 +1,4 @@ -import isFunction from 'isFunction'; +import isFunction from '@/isFunction'; export default function isPromise(value: any): value is Promise { return !!value && isFunction(value.then); diff --git a/packages/vest-utils/src/isUndefined.ts b/packages/vest-utils/src/isUndefined.ts index b3fdf9786..948ce4d4e 100644 --- a/packages/vest-utils/src/isUndefined.ts +++ b/packages/vest-utils/src/isUndefined.ts @@ -1,4 +1,4 @@ -import bindNot from 'bindNot'; +import bindNot from '@/bindNot'; export function isUndefined(value?: unknown): value is undefined { return value === undefined; diff --git a/packages/vest-utils/src/lengthEquals.ts b/packages/vest-utils/src/lengthEquals.ts index b3a73dd76..6408c2681 100644 --- a/packages/vest-utils/src/lengthEquals.ts +++ b/packages/vest-utils/src/lengthEquals.ts @@ -1,9 +1,9 @@ -import bindNot from 'bindNot'; -import { numberEquals } from 'numberEquals'; +import bindNot from '@/bindNot'; +import { numberEquals } from '@/numberEquals'; export function lengthEquals( value: string | unknown[], - arg1: string | number + arg1: string | number, ): boolean { return numberEquals(value.length, arg1); } diff --git a/packages/vest-utils/src/longerThan.ts b/packages/vest-utils/src/longerThan.ts index 1bbeef245..04917e0a7 100644 --- a/packages/vest-utils/src/longerThan.ts +++ b/packages/vest-utils/src/longerThan.ts @@ -1,8 +1,8 @@ -import { greaterThan } from 'greaterThan'; +import { greaterThan } from '@/greaterThan'; export function longerThan( value: string | unknown[], - arg1: string | number + arg1: string | number, ): boolean { return greaterThan(value.length, arg1); } diff --git a/packages/vest-utils/src/nonnullish.ts b/packages/vest-utils/src/nonnullish.ts index f59b49413..a8bf9b765 100644 --- a/packages/vest-utils/src/nonnullish.ts +++ b/packages/vest-utils/src/nonnullish.ts @@ -1,7 +1,6 @@ -import invariant from 'invariant'; - -import { isNullish } from 'isNullish'; -import { Nullish } from 'utilityTypes'; +import invariant from '@/invariant'; +import { isNullish } from '@/isNullish'; +import { Nullish } from '@/utilityTypes'; export function nonnullish(value: Nullish, error?: string): T { invariant(!isNullish(value), error); diff --git a/packages/vest-utils/src/numberEquals.ts b/packages/vest-utils/src/numberEquals.ts index c2951b386..687220d8f 100644 --- a/packages/vest-utils/src/numberEquals.ts +++ b/packages/vest-utils/src/numberEquals.ts @@ -1,9 +1,9 @@ -import bindNot from 'bindNot'; -import { isNumeric } from 'isNumeric'; +import bindNot from '@/bindNot'; +import { isNumeric } from '@/isNumeric'; export function numberEquals( value: string | number, - eq: string | number + eq: string | number, ): boolean { return isNumeric(value) && isNumeric(eq) && Number(value) === Number(eq); } diff --git a/packages/vest-utils/src/optionalFunctionValue.ts b/packages/vest-utils/src/optionalFunctionValue.ts index 71da983c5..965c5e79b 100644 --- a/packages/vest-utils/src/optionalFunctionValue.ts +++ b/packages/vest-utils/src/optionalFunctionValue.ts @@ -1,5 +1,5 @@ -import isFunction from 'isFunction'; -import { DynamicValue } from 'utilityTypes'; +import isFunction from '@/isFunction'; +import { DynamicValue } from '@/utilityTypes'; export default function optionalFunctionValue( value: DynamicValue, diff --git a/packages/vest-utils/src/seq.ts b/packages/vest-utils/src/seq.ts index be34a4b68..1534cabe2 100644 --- a/packages/vest-utils/src/seq.ts +++ b/packages/vest-utils/src/seq.ts @@ -2,7 +2,7 @@ * @returns a unique numeric id. */ -import { CB } from 'utilityTypes'; +import { CB } from '@/utilityTypes'; const seq = genSeq(); diff --git a/packages/vest-utils/src/text.ts b/packages/vest-utils/src/text.ts index a2df01fa1..d670f44f6 100644 --- a/packages/vest-utils/src/text.ts +++ b/packages/vest-utils/src/text.ts @@ -1,5 +1,5 @@ -import { isEmpty } from 'isEmpty'; -import { isObject } from 'valueIsObject'; +import { isEmpty } from '@/isEmpty'; +import { isObject } from '@/valueIsObject'; const regexp = /{(.*?)}/g; diff --git a/packages/vest-utils/src/tinyState.ts b/packages/vest-utils/src/tinyState.ts index 8a6f7ee9f..9eb317131 100644 --- a/packages/vest-utils/src/tinyState.ts +++ b/packages/vest-utils/src/tinyState.ts @@ -1,8 +1,8 @@ -import optionalFunctionValue from 'optionalFunctionValue'; -import { DynamicValue } from 'utilityTypes'; +import optionalFunctionValue from './optionalFunctionValue'; +import { DynamicValue } from './utilityTypes'; export function createTinyState( - initialValue: SetValueInput + initialValue: SetValueInput, ): TinyState { let value: S; @@ -22,7 +22,7 @@ export function createTinyState( export type TinyState = () => [ value: S, setValue: (next: SetValueInput) => void, - resetValue: () => void + resetValue: () => void, ]; type SetValueInput = DynamicValue; diff --git a/packages/vest-utils/src/valueIsObject.ts b/packages/vest-utils/src/valueIsObject.ts index f1e99a27c..e5d9a2db1 100644 --- a/packages/vest-utils/src/valueIsObject.ts +++ b/packages/vest-utils/src/valueIsObject.ts @@ -1,4 +1,4 @@ -import { isNullish } from 'isNullish'; +import { isNullish } from '@/isNullish'; export function isObject(v: any): v is Record { return typeof v === 'object' && !isNullish(v); diff --git a/packages/vest-utils/src/vest-utils.ts b/packages/vest-utils/src/vest-utils.ts index 1037e62f0..65e0031fe 100644 --- a/packages/vest-utils/src/vest-utils.ts +++ b/packages/vest-utils/src/vest-utils.ts @@ -1,47 +1,47 @@ -export { default as cache, CacheApi } from 'cache'; -export { BusType } from 'bus'; -export { TinyState } from 'tinyState'; -export { isNullish, isNotNullish } from 'isNullish'; -export { default as asArray } from 'asArray'; -export { default as callEach } from 'callEach'; -export { default as hasOwnProperty } from 'hasOwnProperty'; -export { default as isPromise } from 'isPromise'; -export { default as optionalFunctionValue } from 'optionalFunctionValue'; -export { default as assign } from 'assign'; -export { default as defaultTo } from 'defaultTo'; -export { default as invariant } from 'invariant'; -export { default as isStringValue } from 'isStringValue'; -export { default as bindNot } from 'bindNot'; -export { default as either } from 'either'; -export { default as isBoolean } from 'isBooleanValue'; -export { default as deferThrow } from 'deferThrow'; -export * as bus from 'bus'; -export { default as seq, genSeq } from 'seq'; -export { default as isFunction } from 'isFunction'; -export { default as mapFirst } from 'mapFirst'; -export { greaterThan } from 'greaterThan'; -export { longerThan } from 'longerThan'; -export { isNumeric, isNotNumeric } from 'isNumeric'; -export { isObject } from 'valueIsObject'; -export { lengthEquals, lengthNotEquals } from 'lengthEquals'; -export { numberEquals, numberNotEquals } from 'numberEquals'; -export { isNull, isNotNull } from 'isNull'; -export { isUndefined, isNotUndefined } from 'isUndefined'; -export { isArray, isNotArray } from 'isArrayValue'; -export { isEmpty, isNotEmpty } from 'isEmpty'; -export { isPositive } from 'isPositive'; -export { text } from 'text'; +export { default as cache, CacheApi } from './cache'; +export { BusType } from './bus'; +export { TinyState } from './tinyState'; +export { isNullish, isNotNullish } from './isNullish'; +export { default as asArray } from './asArray'; +export { default as callEach } from './callEach'; +export { default as hasOwnProperty } from './hasOwnProperty'; +export { default as isPromise } from './isPromise'; +export { default as optionalFunctionValue } from './optionalFunctionValue'; +export { default as assign } from './assign'; +export { default as defaultTo } from './defaultTo'; +export { default as invariant } from './invariant'; +export { default as isStringValue } from './isStringValue'; +export { default as bindNot } from './bindNot'; +export { default as either } from './either'; +export { default as isBoolean } from './isBooleanValue'; +export { default as deferThrow } from './deferThrow'; +export * as bus from './bus'; +export { default as seq, genSeq } from './seq'; +export { default as isFunction } from './isFunction'; +export { default as mapFirst } from './mapFirst'; +export { greaterThan } from './greaterThan'; +export { longerThan } from './longerThan'; +export { isNumeric, isNotNumeric } from './isNumeric'; +export { isObject } from './valueIsObject'; +export { lengthEquals, lengthNotEquals } from './lengthEquals'; +export { numberEquals, numberNotEquals } from './numberEquals'; +export { isNull, isNotNull } from './isNull'; +export { isUndefined, isNotUndefined } from './isUndefined'; +export { isArray, isNotArray } from './isArrayValue'; +export { isEmpty, isNotEmpty } from './isEmpty'; +export { isPositive } from './isPositive'; +export { text } from './text'; export { TStateMachine, StateMachine, TStateMachineApi, -} from 'SimpleStateMachine'; -export { nonnullish } from 'nonnullish'; -export * as tinyState from 'tinyState'; -export { StringObject } from 'StringObject'; -export { noop } from 'noop'; -export * as Predicates from 'Predicates'; -export { freezeAssign } from 'freezeAssign'; +} from './SimpleStateMachine'; +export { nonnullish } from './nonnullish'; +export * as tinyState from './tinyState'; +export { StringObject } from './StringObject'; +export { noop } from './noop'; +export * as Predicates from './Predicates'; +export { freezeAssign } from './freezeAssign'; export type { DropFirst, @@ -55,4 +55,4 @@ export type { DynamicValue, BlankValue, Predicate, -} from 'utilityTypes'; +} from './utilityTypes'; diff --git a/packages/vest-utils/tsconfig.json b/packages/vest-utils/tsconfig.json index dd8b8f85a..fca81718b 100644 --- a/packages/vest-utils/tsconfig.json +++ b/packages/vest-utils/tsconfig.json @@ -7,48 +7,8 @@ "declarationMap": true, "outDir": "./dist", "paths": { - "vest-utils": ["./src/vest-utils.ts"], - "valueIsObject": ["./src/valueIsObject.ts"], - "utilityTypes": ["./src/utilityTypes.ts"], - "tinyState": ["./src/tinyState.ts"], - "text": ["./src/text.ts"], - "seq": ["./src/seq.ts"], - "optionalFunctionValue": ["./src/optionalFunctionValue.ts"], - "numberEquals": ["./src/numberEquals.ts"], - "noop": ["./src/noop.ts"], - "nonnullish": ["./src/nonnullish.ts"], - "mapFirst": ["./src/mapFirst.ts"], - "longerThan": ["./src/longerThan.ts"], - "lengthEquals": ["./src/lengthEquals.ts"], - "isUndefined": ["./src/isUndefined.ts"], - "isStringValue": ["./src/isStringValue.ts"], - "isPromise": ["./src/isPromise.ts"], - "isPositive": ["./src/isPositive.ts"], - "isNumeric": ["./src/isNumeric.ts"], - "isNullish": ["./src/isNullish.ts"], - "isNull": ["./src/isNull.ts"], - "isFunction": ["./src/isFunction.ts"], - "isEmpty": ["./src/isEmpty.ts"], - "isBooleanValue": ["./src/isBooleanValue.ts"], - "isArrayValue": ["./src/isArrayValue.ts"], - "invariant": ["./src/invariant.ts"], - "hasOwnProperty": ["./src/hasOwnProperty.ts"], - "greaterThan": ["./src/greaterThan.ts"], - "globals.d": ["./src/globals.d.ts"], - "freezeAssign": ["./src/freezeAssign.ts"], - "either": ["./src/either.ts"], - "deferThrow": ["./src/deferThrow.ts"], - "defaultTo": ["./src/defaultTo.ts"], - "callEach": ["./src/callEach.ts"], - "cache": ["./src/cache.ts"], - "bus": ["./src/bus.ts"], - "bindNot": ["./src/bindNot.ts"], - "assign": ["./src/assign.ts"], - "asArray": ["./src/asArray.ts"], - "StringObject": ["./src/StringObject.ts"], - "SimpleStateMachine": ["./src/SimpleStateMachine.ts"], - "Predicates": ["./src/Predicates.ts"], - "minifyObject": ["./src/exports/minifyObject.ts"] + "@exports/*": ["src/exports/*"], + "@/*": ["src/*"] } } } diff --git a/packages/vest/src/__tests__/integration.async-tests.test.ts b/packages/vest/src/__tests__/integration.async-tests.test.ts index 748a0d180..89bc5725a 100644 --- a/packages/vest/src/__tests__/integration.async-tests.test.ts +++ b/packages/vest/src/__tests__/integration.async-tests.test.ts @@ -1,9 +1,9 @@ -import { TTestSuite } from 'testUtils/TVestMock'; import wait from 'wait'; import { TestPromise } from '../testUtils/testPromise'; -import { Modes } from 'Modes'; +import { Modes } from '@/hooks/optional/Modes'; +import { TTestSuite } from '@/testUtils/TVestMock'; import * as vest from 'vest'; function genSuite() { diff --git a/packages/vest/src/__tests__/integration.exclusive.test.ts b/packages/vest/src/__tests__/integration.exclusive.test.ts index 6ff6882c5..6f8fd57c8 100644 --- a/packages/vest/src/__tests__/integration.exclusive.test.ts +++ b/packages/vest/src/__tests__/integration.exclusive.test.ts @@ -1,4 +1,4 @@ -import { TTestSuite } from 'testUtils/TVestMock'; +import { TTestSuite } from '@/testUtils/TVestMock'; import * as vest from 'vest'; let suite: TTestSuite; diff --git a/packages/vest/src/__tests__/integration.stateful-async.test.ts b/packages/vest/src/__tests__/integration.stateful-async.test.ts index a30fa266d..aaeda4dc0 100644 --- a/packages/vest/src/__tests__/integration.stateful-async.test.ts +++ b/packages/vest/src/__tests__/integration.stateful-async.test.ts @@ -3,10 +3,10 @@ import wait from 'wait'; import { dummyTest } from '../testUtils/testDummy'; import { TestPromise } from '../testUtils/testPromise'; -import { TIsolateTest } from 'IsolateTest'; -import { Modes } from 'Modes'; -import { TFieldName, TGroupName } from 'SuiteResultTypes'; -import { VestTest } from 'VestTest'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { Modes } from '@/hooks/optional/Modes'; +import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; import * as vest from 'vest'; type SuiteParams = { skip?: string; skipGroup?: true }; @@ -127,7 +127,7 @@ describe('Stateful async tests', () => { vest.test('field_1', tests.length.toString(), async () => { await wait(100); throw new Error(); - }) + }), ); }); suite().done(() => { diff --git a/packages/vest/src/__tests__/integration.stateful-tests.test.ts b/packages/vest/src/__tests__/integration.stateful-tests.test.ts index 9cf0463f9..612d894e6 100644 --- a/packages/vest/src/__tests__/integration.stateful-tests.test.ts +++ b/packages/vest/src/__tests__/integration.stateful-tests.test.ts @@ -1,6 +1,6 @@ import { enforce } from 'n4s'; -import { Modes } from 'Modes'; +import { Modes } from '@/hooks/optional/Modes'; import * as vest from 'vest'; describe('Stateful behavior', () => { @@ -133,9 +133,9 @@ describe('more complex', () => { vest.test('confirm', 'passwords do not match', () => { enforce(data.confirm).equals(data.password); }); - } + }, ); - } + }, ); }); diff --git a/packages/vest/src/__tests__/state_refill.test.ts b/packages/vest/src/__tests__/state_refill.test.ts index 66cc0f1a0..92df7640f 100644 --- a/packages/vest/src/__tests__/state_refill.test.ts +++ b/packages/vest/src/__tests__/state_refill.test.ts @@ -1,4 +1,4 @@ -import { Modes } from 'Modes'; +import { Modes } from '@/hooks/optional/Modes'; import * as vest from 'vest'; describe('state refill', () => { diff --git a/packages/vest/src/core/Runtime.ts b/packages/vest/src/core/Runtime.ts index caadb302d..6557f1f8e 100644 --- a/packages/vest/src/core/Runtime.ts +++ b/packages/vest/src/core/Runtime.ts @@ -1,3 +1,9 @@ +import { + SuiteName, + SuiteResult, + TFieldName, + TGroupName, +} from '@/suiteResult/SuiteResultTypes'; import { CB, CacheApi, @@ -9,14 +15,9 @@ import { } from 'vest-utils'; import { IRecociler, TIsolate, VestRuntime } from 'vestjs-runtime'; -import { TIsolateSuite } from 'IsolateSuite'; -import { Severity } from 'Severity'; -import { - SuiteName, - SuiteResult, - TFieldName, - TGroupName, -} from 'SuiteResultTypes'; +import { Severity } from '../suiteResult/Severity'; + +import { TIsolateSuite } from './isolate/IsolateSuite/IsolateSuite'; export type DoneCallback = (res: SuiteResult) => void; type FieldCallbacks = Record; diff --git a/packages/vest/src/core/StateMachines/IsolateTestStateMachine.ts b/packages/vest/src/core/StateMachines/IsolateTestStateMachine.ts index 53f5aaa74..87be2e676 100644 --- a/packages/vest/src/core/StateMachines/IsolateTestStateMachine.ts +++ b/packages/vest/src/core/StateMachines/IsolateTestStateMachine.ts @@ -1,6 +1,6 @@ import { StateMachine, TStateMachine, ValueOf } from 'vest-utils'; -import { CommonStates } from 'CommonStateMachine'; +import { CommonStates } from '@/core/StateMachines/CommonStateMachine'; export const TestStatus = { [CommonStates.PENDING]: CommonStates.PENDING, diff --git a/packages/vest/src/core/VestBus/VestBus.ts b/packages/vest/src/core/VestBus/VestBus.ts index ae106fb97..d5043ab90 100644 --- a/packages/vest/src/core/VestBus/VestBus.ts +++ b/packages/vest/src/core/VestBus/VestBus.ts @@ -1,20 +1,23 @@ +// import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; import { CB, ValueOf } from 'vest-utils'; import { Bus, RuntimeEvents, TIsolate } from 'vestjs-runtime'; -import { Events } from 'BusEvents'; -// import { TIsolateTest } from 'IsolateTest'; import { useExpireSuiteResultCache, useResetCallbacks, useResetSuite, -} from 'Runtime'; -import { TFieldName } from 'SuiteResultTypes'; -import { SuiteWalker } from 'SuiteWalker'; -import { TestWalker } from 'TestWalker'; -import { VestIsolate } from 'VestIsolate'; -import { VestTest } from 'VestTest'; -import { useOmitOptionalFields } from 'omitOptionalFields'; -import { useRunDoneCallbacks, useRunFieldCallbacks } from 'runCallbacks'; +} from '@/core/Runtime'; +import { Events } from '@/core/VestBus/BusEvents'; +import { TestWalker } from '@/core/isolate/IsolateTest/TestWalker'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { VestIsolate } from '@/core/isolate/VestIsolate'; +import { useOmitOptionalFields } from '@/hooks/optional/omitOptionalFields'; +import { SuiteWalker } from '@/suite/SuiteWalker'; +import { + useRunDoneCallbacks, + useRunFieldCallbacks, +} from '@/suite/runCallbacks'; +import { TFieldName } from '@/suiteResult/SuiteResultTypes'; // eslint-disable-next-line max-statements, max-lines-per-function export function useInitVestBus() { diff --git a/packages/vest/src/core/context/SuiteContext.ts b/packages/vest/src/core/context/SuiteContext.ts index ef541e01a..f11de7aa0 100644 --- a/packages/vest/src/core/context/SuiteContext.ts +++ b/packages/vest/src/core/context/SuiteContext.ts @@ -8,8 +8,8 @@ import { DynamicValue, } from 'vest-utils'; -import { TIsolateTest } from 'IsolateTest'; -import { Modes } from 'Modes'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { Modes } from '@/hooks/optional/Modes'; export const SuiteContext = createCascade((ctxRef, parentContext) => { if (parentContext) { @@ -23,7 +23,7 @@ export const SuiteContext = createCascade((ctxRef, parentContext) => { suiteParams: [], testMemoCache, }, - ctxRef + ctxRef, ); }); diff --git a/packages/vest/src/core/isolate/IsolateEach/IsolateEach.ts b/packages/vest/src/core/isolate/IsolateEach/IsolateEach.ts index 2099bff6f..86b764cdc 100644 --- a/packages/vest/src/core/isolate/IsolateEach/IsolateEach.ts +++ b/packages/vest/src/core/isolate/IsolateEach/IsolateEach.ts @@ -1,12 +1,12 @@ import { CB } from 'vest-utils'; import { TIsolate, Isolate } from 'vestjs-runtime'; -import { VestIsolateType } from 'VestIsolateType'; +import { VestIsolateType } from '@/core/isolate/VestIsolateType'; type TIsolateEach = TIsolate; export function IsolateEach( - callback: Callback + callback: Callback, ): TIsolateEach { return Isolate.create(VestIsolateType.Each, callback, { allowReorder: true, diff --git a/packages/vest/src/core/isolate/IsolateSuite/IsolateSuite.ts b/packages/vest/src/core/isolate/IsolateSuite/IsolateSuite.ts index 573ae0981..300eb9ed1 100644 --- a/packages/vest/src/core/isolate/IsolateSuite/IsolateSuite.ts +++ b/packages/vest/src/core/isolate/IsolateSuite/IsolateSuite.ts @@ -1,9 +1,12 @@ import { CB, assign } from 'vest-utils'; import { Isolate, TIsolate } from 'vestjs-runtime'; -import { OptionalFieldDeclaration, OptionalFields } from 'OptionalTypes'; -import { TFieldName } from 'SuiteResultTypes'; -import { VestIsolateType } from 'VestIsolateType'; +import { + OptionalFieldDeclaration, + OptionalFields, +} from '@/hooks/optional/OptionalTypes'; +import { TFieldName } from '@/suiteResult/SuiteResultTypes'; +import { VestIsolateType } from '@/core/isolate/VestIsolateType'; export type TIsolateSuite = TIsolate<{ optional: OptionalFields; diff --git a/packages/vest/src/core/isolate/IsolateTest/IsolateTest.ts b/packages/vest/src/core/isolate/IsolateTest/IsolateTest.ts index f601819ce..a01a3af06 100644 --- a/packages/vest/src/core/isolate/IsolateTest/IsolateTest.ts +++ b/packages/vest/src/core/isolate/IsolateTest/IsolateTest.ts @@ -1,24 +1,27 @@ import { CB, Maybe } from 'vest-utils'; import { TIsolate, Isolate, IsolateKey } from 'vestjs-runtime'; -import { IsolateTestStateMachine, TestStatus } from 'IsolateTestStateMachine'; -import { TestSeverity } from 'Severity'; -import { TFieldName, TGroupName } from 'SuiteResultTypes'; -import { AsyncTest, TestFn } from 'TestTypes'; -import { VestIsolateType } from 'VestIsolateType'; +import { + IsolateTestStateMachine, + TestStatus, +} from '@/core/StateMachines/IsolateTestStateMachine'; +import { VestIsolateType } from '@/core/isolate/VestIsolateType'; +import { AsyncTest, TestFn } from '@/core/test/TestTypes'; +import { TestSeverity } from '@/suiteResult/Severity'; +import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; export type TIsolateTest< F extends TFieldName = TFieldName, - G extends TGroupName = TGroupName + G extends TGroupName = TGroupName, > = TIsolate & IsolateTestPayload>; export function IsolateTest< F extends TFieldName = TFieldName, - G extends TGroupName = TGroupName + G extends TGroupName = TGroupName, >( callback: CB, input: CommonTestFields, - key?: IsolateKey + key?: IsolateKey, ): TIsolateTest { const payload: IsolateTestPayload = { ...IsolateTestBase(), @@ -37,7 +40,7 @@ export function IsolateTest< VestIsolateType.Test, callback, payload, - key ?? null + key ?? null, ); return isolate as TIsolateTest; @@ -52,7 +55,7 @@ export function IsolateTestBase() { export type IsolateTestPayload< F extends TFieldName = TFieldName, - G extends TGroupName = TGroupName + G extends TGroupName = TGroupName, > = CommonTestFields & { severity: TestSeverity; status: TestStatus; @@ -61,7 +64,7 @@ export type IsolateTestPayload< type CommonTestFields< F extends TFieldName = TFieldName, - G extends TGroupName = TGroupName + G extends TGroupName = TGroupName, > = { message?: Maybe; groupName?: G; diff --git a/packages/vest/src/core/isolate/IsolateTest/IsolateTestReconciler.ts b/packages/vest/src/core/isolate/IsolateTest/IsolateTestReconciler.ts index 2997a216a..d0a297cf8 100644 --- a/packages/vest/src/core/isolate/IsolateTest/IsolateTestReconciler.ts +++ b/packages/vest/src/core/isolate/IsolateTest/IsolateTestReconciler.ts @@ -2,13 +2,14 @@ import { Maybe, deferThrow, text } from 'vest-utils'; import { IsolateInspector, Reconciler } from 'vestjs-runtime'; import type { TIsolate } from 'vestjs-runtime'; -import { ErrorStrings } from 'ErrorStrings'; -import type { TIsolateTest } from 'IsolateTest'; -import { VestTest } from 'VestTest'; -import cancelOverriddenPendingTest from 'cancelOverriddenPendingTest'; -import { isSameProfileTest } from 'isSameProfileTest'; -import { useIsExcluded } from 'useIsExcluded'; -import { useVerifyTestRun } from 'verifyTestRun'; +import cancelOverriddenPendingTest from './cancelOverriddenPendingTest'; +import { isSameProfileTest } from './isSameProfileTest'; + +import type { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { useVerifyTestRun } from '@/core/test/testLevelFlowControl/verifyTestRun'; +import { ErrorStrings } from '@/errors/ErrorStrings'; +import { useIsExcluded } from '@/hooks/focused/useIsExcluded'; export class IsolateTestReconciler { static match(currentNode: TIsolate, historyNode: TIsolate): boolean { diff --git a/packages/vest/src/core/isolate/IsolateTest/TestWalker.ts b/packages/vest/src/core/isolate/IsolateTest/TestWalker.ts index 75b77c809..5a148e6e5 100644 --- a/packages/vest/src/core/isolate/IsolateTest/TestWalker.ts +++ b/packages/vest/src/core/isolate/IsolateTest/TestWalker.ts @@ -1,10 +1,10 @@ import { Nullable } from 'vest-utils'; import { Walker, VestRuntime, TIsolate } from 'vestjs-runtime'; -import { TIsolateTest } from 'IsolateTest'; -import { TFieldName, TGroupName } from 'SuiteResultTypes'; -import { VestTest } from 'VestTest'; -import matchingFieldName from 'matchingFieldName'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import matchingFieldName from '@/core/test/helpers/matchingFieldName'; type MaybeRoot = Nullable; diff --git a/packages/vest/src/core/isolate/IsolateTest/VestTest.ts b/packages/vest/src/core/isolate/IsolateTest/VestTest.ts index 908894d83..67bd24969 100644 --- a/packages/vest/src/core/isolate/IsolateTest/VestTest.ts +++ b/packages/vest/src/core/isolate/IsolateTest/VestTest.ts @@ -1,17 +1,18 @@ import { Maybe, invariant, isPromise, optionalFunctionValue } from 'vest-utils'; import { IsolateMutator, IsolateSelectors, TIsolate } from 'vestjs-runtime'; -import { ErrorStrings } from 'ErrorStrings'; -import type { TIsolateTest } from 'IsolateTest'; +import { ErrorStrings } from '../../../errors/ErrorStrings'; +import { TestSeverity } from '../../../suiteResult/Severity'; +import { TFieldName, TGroupName } from '../../../suiteResult/SuiteResultTypes'; import { IsolateTestStateMachine, TestAction, TestStatus, -} from 'IsolateTestStateMachine'; -import { TestSeverity } from 'Severity'; -import { TFieldName, TGroupName } from 'SuiteResultTypes'; -import { VestIsolate } from 'VestIsolate'; -import { VestIsolateType } from 'VestIsolateType'; +} from '../../StateMachines/IsolateTestStateMachine'; +import { VestIsolate } from '../VestIsolate'; +import { VestIsolateType } from '../VestIsolateType'; + +import { TIsolateTest } from './IsolateTest'; export class VestTest extends VestIsolate { static stateMachine = IsolateTestStateMachine; @@ -20,7 +21,7 @@ export class VestTest extends VestIsolate { static getData< F extends TFieldName = TFieldName, - G extends TGroupName = TGroupName + G extends TGroupName = TGroupName, >(test: TIsolateTest) { invariant(test.data); return test.data; @@ -29,7 +30,7 @@ export class VestTest extends VestIsolate { static is(isolate?: Maybe): isolate is TIsolateTest { return IsolateSelectors.isIsolateType( isolate, - VestIsolateType.Test + VestIsolateType.Test, ); } @@ -38,7 +39,7 @@ export class VestTest extends VestIsolate { } static cast( - isolate?: Maybe + isolate?: Maybe, ): TIsolateTest { VestTest.isX(isolate); return isolate as TIsolateTest; @@ -115,7 +116,7 @@ export class VestTest extends VestIsolate { static fail(test: TIsolateTest): void { VestTest.setStatus( test, - VestTest.warns(test) ? TestStatus.WARNING : TestStatus.FAILED + VestTest.warns(test) ? TestStatus.WARNING : TestStatus.FAILED, ); } @@ -134,7 +135,7 @@ export class VestTest extends VestIsolate { test: TIsolateTest, setter: | ((current: TIsolateTest['data']) => TIsolateTest['data']) - | TIsolateTest['data'] + | TIsolateTest['data'], ): void { test.data = optionalFunctionValue(setter, VestTest.getData(test)); } diff --git a/packages/vest/src/core/isolate/IsolateTest/__tests__/VestTestInspector.test.ts b/packages/vest/src/core/isolate/IsolateTest/__tests__/VestTestInspector.test.ts index 167c47d06..245e0fad3 100644 --- a/packages/vest/src/core/isolate/IsolateTest/__tests__/VestTestInspector.test.ts +++ b/packages/vest/src/core/isolate/IsolateTest/__tests__/VestTestInspector.test.ts @@ -1,7 +1,7 @@ -import { TIsolateTest } from 'IsolateTest'; -import { TestStatus } from 'IsolateTestStateMachine'; -import { VestTest } from 'VestTest'; -import { mockIsolateTest } from 'vestMocks'; +import { TestStatus } from '@/core/StateMachines/IsolateTestStateMachine'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { mockIsolateTest } from '@/testUtils/vestMocks'; describe('VestTest', () => { let testObject: TIsolateTest; diff --git a/packages/vest/src/core/isolate/IsolateTest/__tests__/hasRemainingTests.test.ts b/packages/vest/src/core/isolate/IsolateTest/__tests__/hasRemainingTests.test.ts index 11de5a269..0de4578d6 100644 --- a/packages/vest/src/core/isolate/IsolateTest/__tests__/hasRemainingTests.test.ts +++ b/packages/vest/src/core/isolate/IsolateTest/__tests__/hasRemainingTests.test.ts @@ -1,6 +1,6 @@ import wait from 'wait'; -import { SuiteWalker } from 'SuiteWalker'; +import { SuiteWalker } from '@/suite/SuiteWalker'; import * as vest from 'vest'; describe('SuiteWalker.useHasRemainingWithTestNameMatching', () => { diff --git a/packages/vest/src/core/isolate/IsolateTest/cancelOverriddenPendingTest.ts b/packages/vest/src/core/isolate/IsolateTest/cancelOverriddenPendingTest.ts index 2ca3479a3..ba2d0194c 100644 --- a/packages/vest/src/core/isolate/IsolateTest/cancelOverriddenPendingTest.ts +++ b/packages/vest/src/core/isolate/IsolateTest/cancelOverriddenPendingTest.ts @@ -1,10 +1,10 @@ -import { TIsolateTest } from 'IsolateTest'; -import { VestTest } from 'VestTest'; -import { isSameProfileTest } from 'isSameProfileTest'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { isSameProfileTest } from './isSameProfileTest'; export default function cancelOverriddenPendingTest( prevRunTestObject: TIsolateTest, - currentRunTestObject: TIsolateTest + currentRunTestObject: TIsolateTest, ): void { if ( currentRunTestObject !== prevRunTestObject && diff --git a/packages/vest/src/core/isolate/IsolateTest/isSameProfileTest.ts b/packages/vest/src/core/isolate/IsolateTest/isSameProfileTest.ts index 0889ea8fd..7431a824f 100644 --- a/packages/vest/src/core/isolate/IsolateTest/isSameProfileTest.ts +++ b/packages/vest/src/core/isolate/IsolateTest/isSameProfileTest.ts @@ -1,6 +1,6 @@ -import { TIsolateTest } from 'IsolateTest'; -import { VestTest } from 'VestTest'; -import matchingFieldName from 'matchingFieldName'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import matchingFieldName from '@/core/test/helpers/matchingFieldName'; export function isSameProfileTest( testObject1: TIsolateTest, diff --git a/packages/vest/src/core/isolate/VestIsolate.ts b/packages/vest/src/core/isolate/VestIsolate.ts index fb82a991b..cf08fafba 100644 --- a/packages/vest/src/core/isolate/VestIsolate.ts +++ b/packages/vest/src/core/isolate/VestIsolate.ts @@ -1,7 +1,7 @@ import { TStateMachineApi } from 'vest-utils'; import { TIsolate } from 'vestjs-runtime'; -import { CommonStateMachine, CommonStates } from 'CommonStateMachine'; +import { CommonStateMachine, CommonStates } from '@/core/StateMachines/CommonStateMachine'; export class VestIsolate { static stateMachine: TStateMachineApi = CommonStateMachine; diff --git a/packages/vest/src/core/isolate/VestReconciler.ts b/packages/vest/src/core/isolate/VestReconciler.ts index 5fa35baf0..748718227 100644 --- a/packages/vest/src/core/isolate/VestReconciler.ts +++ b/packages/vest/src/core/isolate/VestReconciler.ts @@ -1,7 +1,7 @@ import { Nullable } from 'vest-utils'; import { TIsolate } from 'vestjs-runtime'; -import { IsolateTestReconciler } from 'IsolateTestReconciler'; +import { IsolateTestReconciler } from './IsolateTest/IsolateTestReconciler'; const reconcilers: IsolateReconciler[] = [IsolateTestReconciler]; diff --git a/packages/vest/src/core/test/TestTypes.ts b/packages/vest/src/core/test/TestTypes.ts index 9c5edc422..64d6cfcb7 100644 --- a/packages/vest/src/core/test/TestTypes.ts +++ b/packages/vest/src/core/test/TestTypes.ts @@ -1,6 +1,6 @@ import { Maybe } from 'vest-utils'; -import { TFieldName } from 'SuiteResultTypes'; +import { TFieldName } from '@/suiteResult/SuiteResultTypes'; export type TestFnPayload = { signal: AbortSignal }; diff --git a/packages/vest/src/core/test/__tests__/IsolateTest.test.ts b/packages/vest/src/core/test/__tests__/IsolateTest.test.ts index 44e6e4d58..91a2ee8dd 100644 --- a/packages/vest/src/core/test/__tests__/IsolateTest.test.ts +++ b/packages/vest/src/core/test/__tests__/IsolateTest.test.ts @@ -2,10 +2,10 @@ import wait from 'wait'; import { TestPromise } from '../../../testUtils/testPromise'; -import { TIsolateTest } from 'IsolateTest'; -import { VestTest } from 'VestTest'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; import * as vest from 'vest'; -import { mockIsolateTest } from 'vestMocks'; +import { mockIsolateTest } from '@/testUtils/vestMocks'; const fieldName = 'unicycle'; const message = 'I am Root.'; diff --git a/packages/vest/src/core/test/__tests__/key.test.ts b/packages/vest/src/core/test/__tests__/key.test.ts index 218d9bfc0..ae511fb05 100644 --- a/packages/vest/src/core/test/__tests__/key.test.ts +++ b/packages/vest/src/core/test/__tests__/key.test.ts @@ -3,7 +3,7 @@ import { TDeferThrow } from 'vest-utils/src/deferThrow'; import { TVestMock } from '../../../testUtils/TVestMock'; import mockThrowError from '../../../testUtils/mockThrowError'; -import { TIsolateTest } from 'IsolateTest'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; import * as vest from 'vest'; describe('key', () => { diff --git a/packages/vest/src/core/test/__tests__/memo.test.ts b/packages/vest/src/core/test/__tests__/memo.test.ts index 7d8d1e761..af56a6b82 100644 --- a/packages/vest/src/core/test/__tests__/memo.test.ts +++ b/packages/vest/src/core/test/__tests__/memo.test.ts @@ -2,10 +2,10 @@ import wait from 'wait'; import { TestPromise } from '../../../testUtils/testPromise'; -import { TIsolateTest } from 'IsolateTest'; -import { Modes } from 'Modes'; -import { VestTest } from 'VestTest'; -import promisify from 'promisify'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { Modes } from '@/hooks/optional/Modes'; +import promisify from '@exports/promisify'; import * as vest from 'vest'; import { test as vestTest, enforce } from 'vest'; @@ -39,7 +39,7 @@ describe('test.memo', () => { vest.warn(); return false; }, - [{}] + [{}], ); })(); @@ -61,7 +61,7 @@ describe('test.memo', () => { vest.warn(); return false; }, - [4] + [4], ); }); @@ -90,7 +90,7 @@ describe('test.memo', () => { await wait(500); enforce(1).equals(2); }, - [1] + [1], ); vestTest.memo( 'field2', @@ -98,7 +98,7 @@ describe('test.memo', () => { await wait(500); enforce(1).equals(2); }, - [2] + [2], ); }); @@ -129,8 +129,8 @@ describe('test.memo', () => { async () => { await wait(10); }, - [true] - ) + [true], + ), ); if (count === 1) { @@ -152,7 +152,7 @@ describe('test.memo', () => { it('Should run test normally', () => { const cb1 = jest.fn(res => res); const cb2 = jest.fn( - res => new Promise((resolve, rej) => (res ? resolve() : rej())) + res => new Promise((resolve, rej) => (res ? resolve() : rej())), ); const suite = vest.create((key, res) => { vestTest.memo('f1', () => cb1(res), [1, key]); diff --git a/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts b/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts index 6edde051c..7e01a9902 100644 --- a/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts +++ b/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts @@ -2,8 +2,8 @@ import { TTestSuite, TVestMock } from '../../../testUtils/TVestMock'; import mockThrowError from '../../../testUtils/mockThrowError'; import { dummyTest } from '../../../testUtils/testDummy'; -import { TIsolateTest } from 'IsolateTest'; -import { Modes } from 'Modes'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { Modes } from '@/hooks/optional/Modes'; import * as vest from 'vest'; describe('Merging of previous test runs', () => { @@ -104,8 +104,8 @@ describe('Merging of previous test runs', () => { expect(deferThrow).toHaveBeenCalledWith( expect.stringContaining( - 'Vest Critical Error: Tests called in different order than previous run.' - ) + 'Vest Critical Error: Tests called in different order than previous run.', + ), ); }); @@ -337,7 +337,7 @@ describe('Merging of previous test runs', () => { () => { vest.test('f4', () => false); vest.test('f5', () => false); - } + }, ); counter++; }); diff --git a/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts b/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts index 575ee890e..843bfda94 100644 --- a/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts +++ b/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts @@ -1,7 +1,7 @@ import wait from 'wait'; -import { TIsolateTest } from 'IsolateTest'; -import { VestTest } from 'VestTest'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; import * as vest from 'vest'; describe('runAsyncTest', () => { @@ -99,7 +99,7 @@ describe('runAsyncTest', () => { testObject.push( vest.test('field_1', async () => { await wait(10); - }) + }), ); vest.test('field_2', () => {}); }); diff --git a/packages/vest/src/core/test/__tests__/test.test.ts b/packages/vest/src/core/test/__tests__/test.test.ts index 9ac8af15d..cb9e1a32a 100644 --- a/packages/vest/src/core/test/__tests__/test.test.ts +++ b/packages/vest/src/core/test/__tests__/test.test.ts @@ -1,12 +1,12 @@ import { faker } from '@faker-js/faker'; import { text } from 'vest-utils'; -import { IsolateSerializer } from 'vestjs-runtime'; +import { IsolateSerializer } from 'vestjs-runtime/IsolateSerializer'; import { TestPromise } from '../../../testUtils/testPromise'; -import { ErrorStrings } from 'ErrorStrings'; -import { TIsolateTest } from 'IsolateTest'; -import { VestTest } from 'VestTest'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { ErrorStrings } from '@/errors/ErrorStrings'; import { enforce } from 'vest'; import * as vest from 'vest'; diff --git a/packages/vest/src/core/test/helpers/__tests__/nonMatchingSeverityProfile.test.ts b/packages/vest/src/core/test/helpers/__tests__/nonMatchingSeverityProfile.test.ts index 698da5f83..35b131255 100644 --- a/packages/vest/src/core/test/helpers/__tests__/nonMatchingSeverityProfile.test.ts +++ b/packages/vest/src/core/test/helpers/__tests__/nonMatchingSeverityProfile.test.ts @@ -1,9 +1,9 @@ -import { VestTest } from 'VestTest'; +import { nonMatchingSeverityProfile } from '../nonMatchingSeverityProfile'; -import { TIsolateTest } from 'IsolateTest'; -import { Severity } from 'Severity'; -import { nonMatchingSeverityProfile } from 'nonMatchingSeverityProfile'; -import { mockIsolateTest } from 'vestMocks'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { Severity } from '@/suiteResult/Severity'; +import { mockIsolateTest } from '@/testUtils/vestMocks'; describe('nonMatchingSeverityProfile', () => { let testObject: TIsolateTest; @@ -18,7 +18,7 @@ describe('nonMatchingSeverityProfile', () => { it('should return false', () => { VestTest.warn(testObject); expect(nonMatchingSeverityProfile(Severity.WARNINGS, testObject)).toBe( - false + false, ); }); }); @@ -26,7 +26,7 @@ describe('nonMatchingSeverityProfile', () => { describe('When both are not warning', () => { it('should return false', () => { expect(nonMatchingSeverityProfile(Severity.ERRORS, testObject)).toBe( - false + false, ); }); }); @@ -37,7 +37,7 @@ describe('nonMatchingSeverityProfile', () => { it('should return true', () => { VestTest.warn(testObject); expect(nonMatchingSeverityProfile(Severity.ERRORS, testObject)).toBe( - true + true, ); }); }); @@ -45,7 +45,7 @@ describe('nonMatchingSeverityProfile', () => { describe('When severity is warning', () => { it('should return true', () => { expect(nonMatchingSeverityProfile(Severity.WARNINGS, testObject)).toBe( - true + true, ); }); }); diff --git a/packages/vest/src/core/test/helpers/matchingFieldName.ts b/packages/vest/src/core/test/helpers/matchingFieldName.ts index 2bf6092b2..426ea7bd9 100644 --- a/packages/vest/src/core/test/helpers/matchingFieldName.ts +++ b/packages/vest/src/core/test/helpers/matchingFieldName.ts @@ -1,7 +1,7 @@ import { Maybe } from 'vest-utils'; -import { TFieldName } from 'SuiteResultTypes'; -import { WithFieldName } from 'TestTypes'; +import { TFieldName } from '@/suiteResult/SuiteResultTypes'; +import { WithFieldName } from '@/core/test/TestTypes'; export function nonMatchingFieldName( WithFieldName: WithFieldName, diff --git a/packages/vest/src/core/test/helpers/matchingGroupName.ts b/packages/vest/src/core/test/helpers/matchingGroupName.ts index d410b8fc7..b156d1058 100644 --- a/packages/vest/src/core/test/helpers/matchingGroupName.ts +++ b/packages/vest/src/core/test/helpers/matchingGroupName.ts @@ -1,14 +1,14 @@ import { Maybe, bindNot } from 'vest-utils'; -import { TIsolateTest } from 'IsolateTest'; -import { TGroupName } from 'SuiteResultTypes'; -import { VestTest } from 'VestTest'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { TGroupName } from '@/suiteResult/SuiteResultTypes'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; export const nonMatchingGroupName = bindNot(matchingGroupName); export function matchingGroupName( testObject: TIsolateTest, - groupName: Maybe + groupName: Maybe, ): boolean { return VestTest.getData(testObject).groupName === groupName; } diff --git a/packages/vest/src/core/test/helpers/nonMatchingSeverityProfile.ts b/packages/vest/src/core/test/helpers/nonMatchingSeverityProfile.ts index 7c7fbcf8f..5bd945a3a 100644 --- a/packages/vest/src/core/test/helpers/nonMatchingSeverityProfile.ts +++ b/packages/vest/src/core/test/helpers/nonMatchingSeverityProfile.ts @@ -1,15 +1,15 @@ import { either } from 'vest-utils'; -import { TIsolateTest } from 'IsolateTest'; -import { Severity } from 'Severity'; -import { VestTest } from 'VestTest'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { Severity } from '@/suiteResult/Severity'; /** * Checks that a given test object matches the currently specified severity level */ export function nonMatchingSeverityProfile( severity: Severity, - testObject: TIsolateTest + testObject: TIsolateTest, ): boolean { return either(severity === Severity.WARNINGS, VestTest.warns(testObject)); } diff --git a/packages/vest/src/core/test/test.memo.ts b/packages/vest/src/core/test/test.memo.ts index 7d1d5c5df..69b180aaa 100644 --- a/packages/vest/src/core/test/test.memo.ts +++ b/packages/vest/src/core/test/test.memo.ts @@ -1,13 +1,13 @@ import { CB, isNull } from 'vest-utils'; import { VestRuntime } from 'vestjs-runtime'; -import { TIsolateTest } from 'IsolateTest'; -import * as Runtime from 'Runtime'; -import { useTestMemoCache } from 'SuiteContext'; -import { TFieldName } from 'SuiteResultTypes'; -import { TestFn } from 'TestTypes'; -import { VestTest } from 'VestTest'; -import { VTest } from 'test'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import * as Runtime from '@/core/Runtime'; +import { useTestMemoCache } from '@/core/context/SuiteContext'; +import { TFieldName } from '@/suiteResult/SuiteResultTypes'; +import { TestFn } from '@/core/test/TestTypes'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { VTest } from '@/core/test/test'; // @vx-allow use-use export function wrapTestMemo(test: VTest): TestMemo { @@ -47,7 +47,7 @@ export function wrapTestMemo(test: VTest): TestMemo { function useGetTestFromCache( dependencies: any[], - cacheAction: CB + cacheAction: CB, ): TIsolateTest { const cache = useTestMemoCache(); @@ -80,7 +80,7 @@ type ParametersWithoutMessage = [test: TestFn, dependencies: unknown[]]; type ParametersWithMessage = [ message: string, test: TestFn, - dependencies: unknown[] + dependencies: unknown[], ]; type ParamsOverload = ParametersWithoutMessage | ParametersWithMessage; diff --git a/packages/vest/src/core/test/test.ts b/packages/vest/src/core/test/test.ts index 8e1e732e5..be8ce17a9 100644 --- a/packages/vest/src/core/test/test.ts +++ b/packages/vest/src/core/test/test.ts @@ -1,31 +1,35 @@ import { assign, invariant, isFunction, isStringValue, text } from 'vest-utils'; import { Bus, IsolateKey } from 'vestjs-runtime'; -import { Events } from 'BusEvents'; -import { ErrorStrings } from 'ErrorStrings'; -import { IsolateTest, TIsolateTest } from 'IsolateTest'; -import { useGroupName } from 'SuiteContext'; -import { TFieldName } from 'SuiteResultTypes'; -import { TestFn } from 'TestTypes'; -import { useAttemptRunTest } from 'runTest'; -import { wrapTestMemo } from 'test.memo'; +import { wrapTestMemo } from './test.memo'; +import { useAttemptRunTest } from './testLevelFlowControl/runTest'; + +import { Events } from '@/core/VestBus/BusEvents'; +import { useGroupName } from '@/core/context/SuiteContext'; +import { + IsolateTest, + TIsolateTest, +} from '@/core/isolate/IsolateTest/IsolateTest'; +import { TestFn } from '@/core/test/TestTypes'; +import { ErrorStrings } from '@/errors/ErrorStrings'; +import { TFieldName } from '@/suiteResult/SuiteResultTypes'; function vestTest( fieldName: F, message: string, - cb: TestFn + cb: TestFn, ): TIsolateTest; function vestTest(fieldName: F, cb: TestFn): TIsolateTest; function vestTest( fieldName: F, message: string, cb: TestFn, - key: IsolateKey + key: IsolateKey, ): TIsolateTest; function vestTest( fieldName: F, cb: TestFn, - key: IsolateKey + key: IsolateKey, ): TIsolateTest; // @vx-allow use-use function vestTest( @@ -66,7 +70,7 @@ function validateTestParams(fieldName: string, testFn: TestFn): void { fn_name: fnName, param: 'fieldName', expected: 'string', - }) + }), ); invariant( isFunction(testFn), @@ -74,6 +78,6 @@ function validateTestParams(fieldName: string, testFn: TestFn): void { fn_name: fnName, param: 'callback', expected: 'function', - }) + }), ); } diff --git a/packages/vest/src/core/test/testLevelFlowControl/runTest.ts b/packages/vest/src/core/test/testLevelFlowControl/runTest.ts index ffff5ac8b..b2599d989 100644 --- a/packages/vest/src/core/test/testLevelFlowControl/runTest.ts +++ b/packages/vest/src/core/test/testLevelFlowControl/runTest.ts @@ -1,13 +1,15 @@ import { isPromise, isStringValue, text, deferThrow } from 'vest-utils'; import { VestRuntime } from 'vestjs-runtime'; -import { ErrorStrings } from 'ErrorStrings'; -import { TIsolateTest } from 'IsolateTest'; -import { SuiteContext } from 'SuiteContext'; -import { TestResult } from 'TestTypes'; -import { VestTest } from 'VestTest'; -import { shouldUseErrorAsMessage } from 'shouldUseErrorMessage'; -import { useVerifyTestRun } from 'verifyTestRun'; +import { shouldUseErrorAsMessage } from '../helpers/shouldUseErrorMessage'; + +import { useVerifyTestRun } from './verifyTestRun'; + +import { SuiteContext } from '@/core/context/SuiteContext'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { TestResult } from '@/core/test/TestTypes'; +import { ErrorStrings } from '@/errors/ErrorStrings'; // eslint-disable-next-line max-statements export function useAttemptRunTest(testObject: TIsolateTest) { diff --git a/packages/vest/src/core/test/testLevelFlowControl/verifyTestRun.ts b/packages/vest/src/core/test/testLevelFlowControl/verifyTestRun.ts index 585ee6615..08fd278a3 100644 --- a/packages/vest/src/core/test/testLevelFlowControl/verifyTestRun.ts +++ b/packages/vest/src/core/test/testLevelFlowControl/verifyTestRun.ts @@ -1,12 +1,11 @@ -import { useIsOptionalFieldApplied } from 'optional'; - -import { TIsolateTest } from 'IsolateTest'; -import { TFieldName } from 'SuiteResultTypes'; -import { VestTest } from 'VestTest'; -import { useShouldSkipBasedOnMode } from 'mode'; -import { useWithinActiveOmitWhen } from 'omitWhen'; -import { useIsExcludedIndividually } from 'skipWhen'; -import { useIsExcluded } from 'useIsExcluded'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { useIsExcluded } from '@/hooks/focused/useIsExcluded'; +import { useShouldSkipBasedOnMode } from '@/hooks/optional/mode'; +import { useIsOptionalFieldApplied } from '@/hooks/optional/optional'; +import { useWithinActiveOmitWhen } from '@/isolates/omitWhen'; +import { useIsExcludedIndividually } from '@/isolates/skipWhen'; +import { TFieldName } from '@/suiteResult/SuiteResultTypes'; export function useVerifyTestRun( testObject: TIsolateTest, diff --git a/packages/vest/src/exports/SuiteSerializer.ts b/packages/vest/src/exports/SuiteSerializer.ts index 89ed205b6..c12a2ed55 100644 --- a/packages/vest/src/exports/SuiteSerializer.ts +++ b/packages/vest/src/exports/SuiteSerializer.ts @@ -1,9 +1,9 @@ import { CB } from 'vest-utils'; import { IsolateSerializer } from 'vestjs-runtime'; -import { TIsolateSuite } from 'IsolateSuite'; -import { TFieldName, TGroupName } from 'SuiteResultTypes'; -import { Suite } from 'SuiteTypes'; +import { TIsolateSuite } from '@/core/isolate/IsolateSuite/IsolateSuite'; +import { Suite } from '@/suite/SuiteTypes'; +import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; export type Dumpable = { dump: CB; diff --git a/packages/vest/src/exports/__tests__/SuiteSerializer.test.ts b/packages/vest/src/exports/__tests__/SuiteSerializer.test.ts index 3fb676811..04edf66f5 100644 --- a/packages/vest/src/exports/__tests__/SuiteSerializer.test.ts +++ b/packages/vest/src/exports/__tests__/SuiteSerializer.test.ts @@ -1,4 +1,5 @@ -import { SuiteSerializer } from 'SuiteSerializer'; +import { SuiteSerializer } from '../SuiteSerializer'; + import * as vest from 'vest'; describe('SuiteSerializer', () => { diff --git a/packages/vest/src/exports/__tests__/classnames.test.ts b/packages/vest/src/exports/__tests__/classnames.test.ts index 5d547f84b..615692c7c 100644 --- a/packages/vest/src/exports/__tests__/classnames.test.ts +++ b/packages/vest/src/exports/__tests__/classnames.test.ts @@ -2,7 +2,7 @@ import { dummyTest } from '../../testUtils/testDummy'; import classnames from '../classnames'; import promisify from '../promisify'; -import { Modes } from 'Modes'; +import { Modes } from '@/hooks/optional/Modes'; import * as vest from 'vest'; describe('Utility: classnames', () => { @@ -23,15 +23,15 @@ describe('Utility: classnames', () => { const validate = vest.create( jest.fn(() => { dummyTest.failing('field_0'); - }) + }), ); expect(typeof classnames(validate())).toBe('function'); const promisifed = await promisify( vest.create( jest.fn(() => { dummyTest.failing('field_0'); - }) - ) + }), + ), )(); expect(typeof classnames(promisifed)).toBe('function'); }); @@ -66,21 +66,21 @@ describe('Utility: classnames', () => { // splitting and sorting to not rely on object order which is unspecified in the language expect(genClass('field_2').split(' ').sort()).toEqual( - 'invalid_string tested_string warning_string'.split(' ').sort() + 'invalid_string tested_string warning_string'.split(' ').sort(), ); expect(genClass('field_3').split(' ').sort()).toEqual( - 'tested_string valid_string warning_string'.split(' ').sort() + 'tested_string valid_string warning_string'.split(' ').sort(), ); expect(genClass('field_4').split(' ').sort()).toEqual( - 'tested_string valid_string'.split(' ').sort() + 'tested_string valid_string'.split(' ').sort(), ); expect(genClass('field_5').split(' ').sort()).toEqual( - 'tested_string invalid_string'.split(' ').sort() + 'tested_string invalid_string'.split(' ').sort(), ); expect(genClass('field_6').split(' ').sort()).toEqual( - 'untested_string'.split(' ').sort() + 'untested_string'.split(' ').sort(), ); }); }); @@ -95,10 +95,10 @@ describe('Utility: classnames', () => { // splitting and sorting to not rely on object order which is unspecified in the language expect(genClass('field_2').split(' ').sort()).toEqual( - 'invalid_string'.split(' ').sort() + 'invalid_string'.split(' ').sort(), ); expect(genClass('field_3').split(' ').sort()).toEqual( - ''.split(' ').sort() + ''.split(' ').sort(), ); }); }); @@ -120,10 +120,10 @@ describe('Utility: classnames', () => { // splitting and sorting to not rely on object order which is unspecified in the language expect(genClass('field_2').split(' ').sort()).toEqual( - ''.split(' ').sort() + ''.split(' ').sort(), ); expect(genClass('field_3').split(' ').sort()).toEqual( - ''.split(' ').sort() + ''.split(' ').sort(), ); }); }); diff --git a/packages/vest/src/exports/__tests__/debounce.test.ts b/packages/vest/src/exports/__tests__/debounce.test.ts index 7e6575c66..14a3073ae 100644 --- a/packages/vest/src/exports/__tests__/debounce.test.ts +++ b/packages/vest/src/exports/__tests__/debounce.test.ts @@ -1,6 +1,6 @@ import wait from 'wait'; -import { TestFnPayload } from 'TestTypes'; +import { TestFnPayload } from '@/core/test/TestTypes'; import * as vest from 'vest'; import debounce from 'vest/debounce'; diff --git a/packages/vest/src/exports/__tests__/parser.test.ts b/packages/vest/src/exports/__tests__/parser.test.ts index ac456cc90..4fe6892fd 100644 --- a/packages/vest/src/exports/__tests__/parser.test.ts +++ b/packages/vest/src/exports/__tests__/parser.test.ts @@ -1,7 +1,7 @@ import * as suiteDummy from '../../testUtils/suiteDummy'; import { ser } from '../../testUtils/suiteDummy'; +import { parse } from '../parser'; -import { parse } from 'parser'; import * as vest from 'vest'; describe('parser.parse', () => { @@ -16,13 +16,13 @@ describe('parser.parse', () => { it('Should return true when provided field is failing', () => { expect(parse(suiteDummy.failing('username')).invalid('username')).toBe( - true + true, ); }); it('Should return false when provided field is passing', () => { expect(parse(suiteDummy.passing('username')).invalid('username')).toBe( - false + false, ); }); @@ -37,13 +37,13 @@ describe('parser.parse', () => { it('Should return true when provided field is failing', () => { expect( - parse(ser(suiteDummy.failing('username'))).invalid('username') + parse(ser(suiteDummy.failing('username'))).invalid('username'), ).toBe(true); }); it('Should return false when provided field is passing', () => { expect( - parse(ser(suiteDummy.passing('username'))).invalid('username') + parse(ser(suiteDummy.passing('username'))).invalid('username'), ).toBe(false); }); }); @@ -59,10 +59,10 @@ describe('parser.parse', () => { }); it('Should return true if provided field is tested', () => { expect(parse(suiteDummy.passing('username')).tested('username')).toBe( - true + true, ); expect(parse(suiteDummy.failing('username')).tested('username')).toBe( - true + true, ); }); @@ -76,10 +76,10 @@ describe('parser.parse', () => { }); it('Should return true if provided field is tested', () => { expect( - parse(ser(suiteDummy.passing('username'))).tested('username') + parse(ser(suiteDummy.passing('username'))).tested('username'), ).toBe(true); expect( - parse(ser(suiteDummy.failing('username'))).tested('username') + parse(ser(suiteDummy.failing('username'))).tested('username'), ).toBe(true); }); }); @@ -99,8 +99,8 @@ describe('parser.parse', () => { vest.skipWhen(true, () => { vest.test('untested', () => {}); }); - })() - ).untested('untested') + })(), + ).untested('untested'), ).toBe(true); }); @@ -110,7 +110,7 @@ describe('parser.parse', () => { it('Should return false if provided field is tested', () => { expect(parse(suiteDummy.passing('username')).untested('username')).toBe( - false + false, ); }); @@ -128,21 +128,21 @@ describe('parser.parse', () => { vest.skipWhen(true, () => { vest.test('untested', () => {}); }); - })() - ) - ).untested('untested') + })(), + ), + ).untested('untested'), ).toBe(true); }); it('Should return false if any field is tested', () => { expect(parse(ser(suiteDummy.passing('username'))).untested()).toBe( - false + false, ); }); it('Should return false if provided field is tested', () => { expect( - parse(ser(suiteDummy.passing('username'))).untested('username') + parse(ser(suiteDummy.passing('username'))).untested('username'), ).toBe(false); }); }); @@ -152,19 +152,19 @@ describe('parser.parse', () => { it('Should return true if all fields are passing', () => { expect(parse(suiteDummy.passing(['f1', 'f2', 'f3'])).valid()).toBe(true); expect(parse(suiteDummy.passing(['f1', 'f2', 'f3'])).valid('f2')).toBe( - true + true, ); }); it('Should return true if all required fields have been tested and are passing', () => { expect( - parse(suiteDummy.passingWithUntestedOptional('optional')).valid() + parse(suiteDummy.passingWithUntestedOptional('optional')).valid(), ).toBe(true); }); it('Should return true if all fields, including optional, pass', () => { expect(parse(suiteDummy.passingWithOptional('optional')).valid()).toBe( - true + true, ); }); @@ -193,8 +193,8 @@ describe('parser.parse', () => { vest.skipWhen(true, () => { vest.test('untested', () => {}); }); - })() - ).valid() + })(), + ).valid(), ).toBe(false); }); @@ -206,8 +206,8 @@ describe('parser.parse', () => { vest.skipWhen(true, () => { vest.test('f1', () => {}); }); - })() - ).valid('f1') + })(), + ).valid('f1'), ).toBe(false); }); @@ -219,8 +219,8 @@ describe('parser.parse', () => { vest.skipWhen(true, () => { vest.test('f1', () => {}); }); - })() - ).valid('f1') + })(), + ).valid('f1'), ).toBe(true); }); @@ -230,8 +230,8 @@ describe('parser.parse', () => { vest.create(() => { vest.test('f1', () => {}); vest.test('f2', () => false); - })() - ).valid('f1') + })(), + ).valid('f1'), ).toBe(true); }); @@ -241,8 +241,8 @@ describe('parser.parse', () => { vest.create(() => { vest.test('f1', () => {}); vest.test('f2', () => false); - })() - ).valid('f2') + })(), + ).valid('f2'), ).toBe(false); expect( parse( @@ -250,8 +250,8 @@ describe('parser.parse', () => { vest.test('f1', () => {}); vest.test('f2', () => {}); vest.test('f2', () => false); - })() - ).valid('f2') + })(), + ).valid('f2'), ).toBe(false); }); @@ -263,8 +263,8 @@ describe('parser.parse', () => { vest.warn(); return false; }); - })() - ).valid('f1') + })(), + ).valid('f1'), ).toBe(true); }); }); @@ -272,22 +272,24 @@ describe('parser.parse', () => { describe('Serialized Result', () => { it('Should return true if all fields are passing', () => { expect(parse(ser(suiteDummy.passing(['f1', 'f2', 'f3']))).valid()).toBe( - true + true, ); expect( - parse(ser(suiteDummy.passing(['f1', 'f2', 'f3']))).valid('f2') + parse(ser(suiteDummy.passing(['f1', 'f2', 'f3']))).valid('f2'), ).toBe(true); }); it('Should return true if all required fields have been tested and are passing', () => { expect( - parse(ser(suiteDummy.passingWithUntestedOptional('optional'))).valid() + parse( + ser(suiteDummy.passingWithUntestedOptional('optional')), + ).valid(), ).toBe(true); }); it('Should return true if all fields, including optional, pass', () => { expect( - parse(ser(suiteDummy.passingWithOptional('optional'))).valid() + parse(ser(suiteDummy.passingWithOptional('optional'))).valid(), ).toBe(true); }); @@ -301,7 +303,7 @@ describe('parser.parse', () => { it('Should return true if suite only has warnings', () => { expect(parse(ser(suiteDummy.warning(['f1', 'f2', 'f3']))).valid()).toBe( - true + true, ); }); @@ -319,9 +321,9 @@ describe('parser.parse', () => { vest.skipWhen(true, () => { vest.test('untested', () => {}); }); - })() - ) - ).valid() + })(), + ), + ).valid(), ).toBe(false); }); @@ -334,9 +336,9 @@ describe('parser.parse', () => { vest.skipWhen(true, () => { vest.test('f1', () => {}); }); - })() - ) - ).valid('f1') + })(), + ), + ).valid('f1'), ).toBe(false); }); @@ -349,9 +351,9 @@ describe('parser.parse', () => { vest.skipWhen(true, () => { vest.test('f1', () => {}); }); - })() - ) - ).valid('f1') + })(), + ), + ).valid('f1'), ).toBe(true); }); @@ -362,9 +364,9 @@ describe('parser.parse', () => { vest.create(() => { vest.test('f1', () => {}); vest.test('f2', () => false); - })() - ) - ).valid('f1') + })(), + ), + ).valid('f1'), ).toBe(true); }); @@ -375,9 +377,9 @@ describe('parser.parse', () => { vest.create(() => { vest.test('f1', () => {}); vest.test('f2', () => false); - })() - ) - ).valid('f2') + })(), + ), + ).valid('f2'), ).toBe(false); expect( parse( @@ -386,9 +388,9 @@ describe('parser.parse', () => { vest.test('f1', () => {}); vest.test('f2', () => {}); vest.test('f2', () => false); - })() - ) - ).valid('f2') + })(), + ), + ).valid('f2'), ).toBe(false); }); @@ -401,9 +403,9 @@ describe('parser.parse', () => { vest.warn(); return false; }); - })() - ) - ).valid('f1') + })(), + ), + ).valid('f1'), ).toBe(true); }); }); diff --git a/packages/vest/src/exports/__tests__/promisify.test.ts b/packages/vest/src/exports/__tests__/promisify.test.ts index 7385e5d72..409b743e2 100644 --- a/packages/vest/src/exports/__tests__/promisify.test.ts +++ b/packages/vest/src/exports/__tests__/promisify.test.ts @@ -4,7 +4,7 @@ import { dummyTest } from '../../testUtils/testDummy'; import { TestPromise } from '../../testUtils/testPromise'; import promisify from '../promisify'; -import { TFieldName } from 'SuiteResultTypes'; +import { TFieldName } from '@/suiteResult/SuiteResultTypes'; import * as vest from 'vest'; describe('Utility: promisify', () => { @@ -18,8 +18,8 @@ describe('Utility: promisify', () => { vest.create( jest.fn(() => { dummyTest.failing('field_0'); - }) - ) + }), + ), ); validateAsync = promisify(validatorFn); }); @@ -52,7 +52,7 @@ describe('Utility: promisify', () => { vest.create(() => { dummyTest.failing('field_0'); done(); - }) + }), ); validateAsync(); })); diff --git a/packages/vest/src/exports/classnames.ts b/packages/vest/src/exports/classnames.ts index 5cc24f1c6..669939868 100644 --- a/packages/vest/src/exports/classnames.ts +++ b/packages/vest/src/exports/classnames.ts @@ -1,14 +1,18 @@ import { isFunction } from 'vest-utils'; -import { SuiteSummary, TFieldName, TGroupName } from 'SuiteResultTypes'; -import { ParsedVestObject, parse } from 'parser'; +import { ParsedVestObject, parse } from '@/exports/parser'; +import { + SuiteSummary, + TFieldName, + TGroupName, +} from '@/suiteResult/SuiteResultTypes'; /** * Creates a function that returns class names that match the validation result */ export default function classnames( res: SuiteSummary, - classes: SupportedClasses = {} + classes: SupportedClasses = {}, ): (fieldName: F) => string { const selectors = parse(res); diff --git a/packages/vest/src/exports/debounce.ts b/packages/vest/src/exports/debounce.ts index b185d1721..d48288136 100644 --- a/packages/vest/src/exports/debounce.ts +++ b/packages/vest/src/exports/debounce.ts @@ -1,8 +1,8 @@ +import { registerReconciler } from 'vest'; import { CB, isPromise, Nullable } from 'vest-utils'; import { Isolate, TIsolate, IsolateSelectors } from 'vestjs-runtime'; -import { TestFn, TestFnPayload } from 'TestTypes'; -import { registerReconciler } from 'vest'; +import { TestFn, TestFnPayload } from '@/core/test/TestTypes'; const isolateType = 'Debounce'; diff --git a/packages/vest/src/exports/parser.ts b/packages/vest/src/exports/parser.ts index f31e52093..19ddf8aa4 100644 --- a/packages/vest/src/exports/parser.ts +++ b/packages/vest/src/exports/parser.ts @@ -1,8 +1,8 @@ +import { suiteSelectors, SuiteSummary } from 'vest'; import { hasOwnProperty, invariant, isNullish, isPositive } from 'vest-utils'; -import { ErrorStrings } from 'ErrorStrings'; -import { SuiteSummary, TFieldName, TGroupName } from 'SuiteResultTypes'; -import { suiteSelectors } from 'vest'; +import { ErrorStrings } from '../errors/ErrorStrings'; +import { TFieldName, TGroupName } from '../suiteResult/SuiteResultTypes'; export function parse( summary: SuiteSummary, diff --git a/packages/vest/src/exports/promisify.ts b/packages/vest/src/exports/promisify.ts index 101a86f9b..2459b440a 100644 --- a/packages/vest/src/exports/promisify.ts +++ b/packages/vest/src/exports/promisify.ts @@ -1,15 +1,15 @@ import { invariant, isFunction } from 'vest-utils'; -import { ErrorStrings } from 'ErrorStrings'; +import { ErrorStrings } from '@/errors/ErrorStrings'; import { SuiteResult, SuiteRunResult, TFieldName, TGroupName, -} from 'SuiteResultTypes'; +} from '@/suiteResult/SuiteResultTypes'; function promisify( - validatorFn: (...args: any[]) => SuiteRunResult + validatorFn: (...args: any[]) => SuiteRunResult, ) { return (...args: any[]): Promise> => { invariant(isFunction(validatorFn), ErrorStrings.PROMISIFY_REQUIRE_FUNCTION); diff --git a/packages/vest/src/hooks/__tests__/include.test.ts b/packages/vest/src/hooks/__tests__/include.test.ts index 951ffd962..25c946e8c 100644 --- a/packages/vest/src/hooks/__tests__/include.test.ts +++ b/packages/vest/src/hooks/__tests__/include.test.ts @@ -1,4 +1,4 @@ -import { Modes } from 'Modes'; +import { Modes } from '@/hooks/optional/Modes'; import * as vest from 'vest'; describe('include', () => { diff --git a/packages/vest/src/hooks/__tests__/mode.test.ts b/packages/vest/src/hooks/__tests__/mode.test.ts index 6dd6a1472..6eda320bb 100644 --- a/packages/vest/src/hooks/__tests__/mode.test.ts +++ b/packages/vest/src/hooks/__tests__/mode.test.ts @@ -1,9 +1,9 @@ -import { TTestSuite } from 'testUtils/TVestMock'; +import { TTestSuite } from '@/testUtils/TVestMock'; import wait from 'wait'; import { dummyTest } from '../../testUtils/testDummy'; -import { Modes } from 'Modes'; +import { Modes } from '@/hooks/optional/Modes'; import { create, only, group, mode } from 'vest'; import * as Vest from 'vest'; diff --git a/packages/vest/src/hooks/__tests__/warn.test.ts b/packages/vest/src/hooks/__tests__/warn.test.ts index 523b08ed8..6559b895b 100644 --- a/packages/vest/src/hooks/__tests__/warn.test.ts +++ b/packages/vest/src/hooks/__tests__/warn.test.ts @@ -1,7 +1,7 @@ import { faker } from '@faker-js/faker'; -import { ErrorStrings } from 'ErrorStrings'; -import { VestTest } from 'VestTest'; +import { ErrorStrings } from '@/errors/ErrorStrings'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; import * as vest from 'vest'; const { create, test, warn } = vest; diff --git a/packages/vest/src/hooks/focused/focused.ts b/packages/vest/src/hooks/focused/focused.ts index 08bc45a92..3df2f1b69 100644 --- a/packages/vest/src/hooks/focused/focused.ts +++ b/packages/vest/src/hooks/focused/focused.ts @@ -9,9 +9,10 @@ import { } from 'vest-utils'; import { IsolateSelectors, TIsolate, Isolate } from 'vestjs-runtime'; -import { FocusModes } from 'FocusedKeys'; -import { TFieldName, TGroupName } from 'SuiteResultTypes'; -import { VestIsolateType } from 'VestIsolateType'; +import { FocusModes } from './FocusedKeys'; + +import { VestIsolateType } from '@/core/isolate/VestIsolateType'; +import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; export type ExclusionItem = Maybe>; export type FieldExclusion = Maybe>; @@ -27,7 +28,7 @@ export type IsolateFocusedPayload = { export function IsolateFocused( focusMode: FocusModes, - match?: true | FieldExclusion + match?: true | FieldExclusion, ): TIsolateFocused { return Isolate.create(VestIsolateType.Focused, noop, { focusMode, @@ -39,7 +40,7 @@ export function IsolateFocused( export class FocusSelectors { static isSkipFocused( focus: Nullable, - fieldName?: TFieldName + fieldName?: TFieldName, ): boolean { return ( focus?.data.focusMode === FocusModes.SKIP && @@ -48,7 +49,7 @@ export class FocusSelectors { } static isOnlyFocused( focus: Nullable, - fieldName?: TFieldName + fieldName?: TFieldName, ): boolean { return ( focus?.data.focusMode === FocusModes.ONLY && hasFocus(focus, fieldName) diff --git a/packages/vest/src/hooks/focused/useHasOnliedTests.ts b/packages/vest/src/hooks/focused/useHasOnliedTests.ts index 0cffdd841..b18784231 100644 --- a/packages/vest/src/hooks/focused/useHasOnliedTests.ts +++ b/packages/vest/src/hooks/focused/useHasOnliedTests.ts @@ -1,22 +1,22 @@ import { isNotNullish } from 'vest-utils'; import { TIsolate, Walker } from 'vestjs-runtime'; -import { TIsolateTest } from 'IsolateTest'; -import { TFieldName } from 'SuiteResultTypes'; -import { FocusSelectors } from 'focused'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { TFieldName } from '@/suiteResult/SuiteResultTypes'; +import { FocusSelectors } from '@/hooks/focused/focused'; /** * Checks if context has included tests */ export function useHasOnliedTests( testObject: TIsolateTest, - fieldName?: TFieldName + fieldName?: TFieldName, ): boolean { return isNotNullish( Walker.findClosest(testObject, (child: TIsolate) => { if (!FocusSelectors.isIsolateFocused(child)) return false; return FocusSelectors.isOnlyFocused(child, fieldName); - }) + }), ); } diff --git a/packages/vest/src/hooks/focused/useIsExcluded.ts b/packages/vest/src/hooks/focused/useIsExcluded.ts index 702f0d697..4e7ca2d6f 100644 --- a/packages/vest/src/hooks/focused/useIsExcluded.ts +++ b/packages/vest/src/hooks/focused/useIsExcluded.ts @@ -1,12 +1,14 @@ import { Nullable, optionalFunctionValue } from 'vest-utils'; import { TIsolate, Walker } from 'vestjs-runtime'; -import { TIsolateTest } from 'IsolateTest'; -import { useInclusion } from 'SuiteContext'; -import { VestTest } from 'VestTest'; -import { FocusSelectors, TIsolateFocused } from 'focused'; -import { useIsExcludedIndividually } from 'skipWhen'; -import { useHasOnliedTests } from 'useHasOnliedTests'; +import { useHasOnliedTests } from './useHasOnliedTests'; + +import { useInclusion } from '@/core/context/SuiteContext'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { FocusSelectors, TIsolateFocused } from '@/hooks/focused/focused'; +import { useIsExcludedIndividually } from '@/isolates/skipWhen'; + //Checks whether a certain test profile excluded by any of the exclusion groups. function useClosestMatchingFocus( diff --git a/packages/vest/src/hooks/include.ts b/packages/vest/src/hooks/include.ts index 157fa1353..d2e866e51 100644 --- a/packages/vest/src/hooks/include.ts +++ b/packages/vest/src/hooks/include.ts @@ -1,12 +1,13 @@ import { isStringValue, invariant, optionalFunctionValue } from 'vest-utils'; -import { ErrorStrings } from 'ErrorStrings'; -import { TIsolateTest } from 'IsolateTest'; -import { useInclusion } from 'SuiteContext'; -import { TFieldName, TGroupName } from 'SuiteResultTypes'; -import { TDraftCondition } from 'getTypedMethods'; -import { useCreateSuiteResult } from 'suiteResult'; -import { useHasOnliedTests } from 'useHasOnliedTests'; +import { useHasOnliedTests } from './focused/useHasOnliedTests'; + +import { useInclusion } from '@/core/context/SuiteContext'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { ErrorStrings } from '@/errors/ErrorStrings'; +import { TDraftCondition } from '@/suite/getTypedMethods'; +import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; +import { useCreateSuiteResult } from '@/suiteResult/suiteResult'; /** * Conditionally includes a field for testing, based on specified criteria. @@ -28,7 +29,7 @@ import { useHasOnliedTests } from 'useHasOnliedTests'; */ // @vx-allow use-use export function include( - fieldName: F + fieldName: F, ): { when: (condition: F | TFieldName | TDraftCondition) => void; } { @@ -49,7 +50,7 @@ export function include( // This callback will run as part of the "isExcluded" series of checks inclusion[fieldName] = function isIncluded( - currentNode: TIsolateTest + currentNode: TIsolateTest, ): boolean { if (isStringValue(condition)) { return useHasOnliedTests(currentNode, condition); @@ -57,7 +58,7 @@ export function include( return optionalFunctionValue( condition, - optionalFunctionValue(useCreateSuiteResult) + optionalFunctionValue(useCreateSuiteResult), ); }; } diff --git a/packages/vest/src/hooks/optional/OptionalTypes.ts b/packages/vest/src/hooks/optional/OptionalTypes.ts index 7410fac0b..7332c1d51 100644 --- a/packages/vest/src/hooks/optional/OptionalTypes.ts +++ b/packages/vest/src/hooks/optional/OptionalTypes.ts @@ -1,6 +1,6 @@ import { DynamicValue, OneOrMoreOf } from 'vest-utils'; -import { TFieldName } from 'SuiteResultTypes'; +import { TFieldName } from '@/suiteResult/SuiteResultTypes'; export type OptionalFields = Record; diff --git a/packages/vest/src/hooks/optional/__tests__/optional.test.ts b/packages/vest/src/hooks/optional/__tests__/optional.test.ts index 6351d3985..430b447f0 100644 --- a/packages/vest/src/hooks/optional/__tests__/optional.test.ts +++ b/packages/vest/src/hooks/optional/__tests__/optional.test.ts @@ -1,4 +1,4 @@ -import { TTestSuite } from 'testUtils/TVestMock'; +import { TTestSuite } from '@/testUtils/TVestMock'; import { BlankValue } from 'vest-utils'; import wait from 'wait'; @@ -250,7 +250,7 @@ describe('optional hook', () => { expect(res.hasErrors('field_1')).toBe(false); expect(res.isValid('field_1')).toBe(true); expect(res.isValid()).toBe(true); - } + }, ); }); diff --git a/packages/vest/src/hooks/optional/mode.ts b/packages/vest/src/hooks/optional/mode.ts index 99a707319..fb36abc99 100644 --- a/packages/vest/src/hooks/optional/mode.ts +++ b/packages/vest/src/hooks/optional/mode.ts @@ -1,7 +1,7 @@ -import { Modes } from 'Modes'; -import { useMode } from 'SuiteContext'; -import { WithFieldName } from 'TestTypes'; -import { hasErrorsByTestObjects } from 'hasFailuresByTestObjects'; +import { useMode } from '@/core/context/SuiteContext'; +import { WithFieldName } from '@/core/test/TestTypes'; +import { Modes } from '@/hooks/optional/Modes'; +import { hasErrorsByTestObjects } from '@/suiteResult/selectors/hasFailuresByTestObjects'; /** * Sets the current execution mode for the current suite. diff --git a/packages/vest/src/hooks/optional/omitOptionalFields.ts b/packages/vest/src/hooks/optional/omitOptionalFields.ts index fb0580514..93ac1d895 100644 --- a/packages/vest/src/hooks/optional/omitOptionalFields.ts +++ b/packages/vest/src/hooks/optional/omitOptionalFields.ts @@ -1,11 +1,14 @@ import { isEmpty, optionalFunctionValue } from 'vest-utils'; import { Bus, VestRuntime } from 'vestjs-runtime'; -import { Events } from 'BusEvents'; -import { SuiteOptionalFields, TIsolateSuite } from 'IsolateSuite'; -import { TIsolateTest } from 'IsolateTest'; -import { TestWalker } from 'TestWalker'; -import { VestTest } from 'VestTest'; +import { Events } from '../../core/VestBus/BusEvents'; +import { + SuiteOptionalFields, + TIsolateSuite, +} from '../../core/isolate/IsolateSuite/IsolateSuite'; +import { TIsolateTest } from '../../core/isolate/IsolateTest/IsolateTest'; +import { TestWalker } from '../../core/isolate/IsolateTest/TestWalker'; +import { VestTest } from '../../core/isolate/IsolateTest/VestTest'; /** * This module gets triggered once the suite is done running its sync tests. @@ -63,7 +66,7 @@ export function useOmitOptionalFields(): void { // Ge the optional configuration for the given field const optionalConfig = SuiteOptionalFields.getOptionalField( root, - fieldName + fieldName, ); // If the optional was set to a function or a boolean, run it and verify/omit the test diff --git a/packages/vest/src/hooks/optional/optional.ts b/packages/vest/src/hooks/optional/optional.ts index ac9bc745e..4167dd17e 100644 --- a/packages/vest/src/hooks/optional/optional.ts +++ b/packages/vest/src/hooks/optional/optional.ts @@ -2,14 +2,18 @@ import { enforce } from 'n4s'; import { isArray, isStringValue, asArray, hasOwnProperty } from 'vest-utils'; import { VestRuntime } from 'vestjs-runtime'; -import { SuiteOptionalFields, TIsolateSuite } from 'IsolateSuite'; -import { OptionalFieldTypes, OptionalsInput } from 'OptionalTypes'; -import { useSuiteParams } from 'SuiteContext'; -import { TFieldName } from 'SuiteResultTypes'; +import { useSuiteParams } from '../../core/context/SuiteContext'; +import { + SuiteOptionalFields, + TIsolateSuite, +} from '../../core/isolate/IsolateSuite/IsolateSuite'; +import { TFieldName } from '../../suiteResult/SuiteResultTypes'; + +import { OptionalFieldTypes, OptionalsInput } from './OptionalTypes'; // @vx-allow use-use export function optional( - optionals: OptionalsInput + optionals: OptionalsInput, ): void { const suiteRoot = VestRuntime.useAvailableRoot(); diff --git a/packages/vest/src/hooks/warn.ts b/packages/vest/src/hooks/warn.ts index 312e0138f..046d1e978 100644 --- a/packages/vest/src/hooks/warn.ts +++ b/packages/vest/src/hooks/warn.ts @@ -1,8 +1,8 @@ import { invariant } from 'vest-utils'; -import { ErrorStrings } from 'ErrorStrings'; -import { useCurrentTest } from 'SuiteContext'; -import { VestTest } from 'VestTest'; +import { ErrorStrings } from '@/errors/ErrorStrings'; +import { useCurrentTest } from '@/core/context/SuiteContext'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; const ERROR_OUTSIDE_OF_TEST = ErrorStrings.WARN_MUST_BE_CALLED_FROM_TEST; diff --git a/packages/vest/src/isolates/__tests__/omitWhen.test.ts b/packages/vest/src/isolates/__tests__/omitWhen.test.ts index 2ef0603f2..f0256448a 100644 --- a/packages/vest/src/isolates/__tests__/omitWhen.test.ts +++ b/packages/vest/src/isolates/__tests__/omitWhen.test.ts @@ -1,6 +1,6 @@ import { Maybe } from 'vest-utils'; -import { TTestSuite } from 'testUtils/TVestMock'; +import { TTestSuite } from '@/testUtils/TVestMock'; import * as vest from 'vest'; import { omitWhen, only } from 'vest'; diff --git a/packages/vest/src/isolates/__tests__/skipWhen.test.ts b/packages/vest/src/isolates/__tests__/skipWhen.test.ts index 66c032ab6..cd85b5f66 100644 --- a/packages/vest/src/isolates/__tests__/skipWhen.test.ts +++ b/packages/vest/src/isolates/__tests__/skipWhen.test.ts @@ -1,4 +1,4 @@ -import { TTestSuite } from 'testUtils/TVestMock'; +import { TTestSuite } from '@/testUtils/TVestMock'; import { dummyTest } from '../../testUtils/testDummy'; diff --git a/packages/vest/src/isolates/each.ts b/packages/vest/src/isolates/each.ts index be41b3ca9..7a7b24997 100644 --- a/packages/vest/src/isolates/each.ts +++ b/packages/vest/src/isolates/each.ts @@ -1,7 +1,7 @@ import { invariant, isFunction } from 'vest-utils'; -import { ErrorStrings } from 'ErrorStrings'; -import { IsolateEach } from 'IsolateEach'; +import { IsolateEach } from '@/core/isolate/IsolateEach/IsolateEach'; +import { ErrorStrings } from '@/errors/ErrorStrings'; /** * Iterates over an array of items, allowing to run tests individually per item. @@ -18,11 +18,11 @@ import { IsolateEach } from 'IsolateEach'; */ export function each( list: T[], - callback: (arg: T, index: number) => void + callback: (arg: T, index: number) => void, ): void { invariant( isFunction(callback), - ErrorStrings.EACH_CALLBACK_MUST_BE_A_FUNCTION + ErrorStrings.EACH_CALLBACK_MUST_BE_A_FUNCTION, ); IsolateEach(() => { diff --git a/packages/vest/src/isolates/group.ts b/packages/vest/src/isolates/group.ts index 556d21619..5dfce9e81 100644 --- a/packages/vest/src/isolates/group.ts +++ b/packages/vest/src/isolates/group.ts @@ -1,9 +1,10 @@ import { CB } from 'vest-utils'; import { TIsolate, Isolate } from 'vestjs-runtime'; -import { SuiteContext } from 'SuiteContext'; -import { TGroupName } from 'SuiteResultTypes'; -import { VestIsolateType } from 'VestIsolateType'; + +import { SuiteContext } from '@/core/context/SuiteContext'; +import { VestIsolateType } from '@/core/isolate/VestIsolateType'; +import { TGroupName } from '@/suiteResult/SuiteResultTypes'; export function group( groupName: G, diff --git a/packages/vest/src/isolates/omitWhen.ts b/packages/vest/src/isolates/omitWhen.ts index 3003d8ecf..2eed63533 100644 --- a/packages/vest/src/isolates/omitWhen.ts +++ b/packages/vest/src/isolates/omitWhen.ts @@ -2,11 +2,11 @@ import type { CB } from 'vest-utils'; import { optionalFunctionValue } from 'vest-utils'; import { Isolate } from 'vestjs-runtime'; -import { SuiteContext, useOmitted } from 'SuiteContext'; -import { TFieldName, TGroupName } from 'SuiteResultTypes'; -import { VestIsolateType } from 'VestIsolateType'; -import { TDraftCondition } from 'getTypedMethods'; -import { useCreateSuiteResult } from 'suiteResult'; +import { SuiteContext, useOmitted } from '../core/context/SuiteContext'; +import { VestIsolateType } from '../core/isolate/VestIsolateType'; +import { TDraftCondition } from '../suite/getTypedMethods'; +import { TFieldName, TGroupName } from '../suiteResult/SuiteResultTypes'; +import { useCreateSuiteResult } from '../suiteResult/suiteResult'; /** * Conditionally omits tests from the suite. @@ -20,7 +20,7 @@ import { useCreateSuiteResult } from 'suiteResult'; // @vx-allow use-use export function omitWhen( conditional: TDraftCondition, - callback: CB + callback: CB, ): void { Isolate.create(VestIsolateType.OmitWhen, () => { SuiteContext.run( @@ -29,10 +29,10 @@ export function omitWhen( useWithinActiveOmitWhen() || optionalFunctionValue( conditional, - optionalFunctionValue(useCreateSuiteResult) + optionalFunctionValue(useCreateSuiteResult), ), }, - callback + callback, ); }); } diff --git a/packages/vest/src/isolates/skipWhen.ts b/packages/vest/src/isolates/skipWhen.ts index 45e75c19b..f8d19a15f 100644 --- a/packages/vest/src/isolates/skipWhen.ts +++ b/packages/vest/src/isolates/skipWhen.ts @@ -1,11 +1,11 @@ import { CB, optionalFunctionValue } from 'vest-utils'; import { Isolate } from 'vestjs-runtime'; -import { SuiteContext, useSkipped } from 'SuiteContext'; -import { TFieldName, TGroupName } from 'SuiteResultTypes'; -import { VestIsolateType } from 'VestIsolateType'; -import { TDraftCondition } from 'getTypedMethods'; -import { useCreateSuiteResult } from 'suiteResult'; +import { SuiteContext, useSkipped } from '../core/context/SuiteContext'; +import { VestIsolateType } from '../core/isolate/VestIsolateType'; +import { TDraftCondition } from '../suite/getTypedMethods'; +import { TFieldName, TGroupName } from '../suiteResult/SuiteResultTypes'; +import { useCreateSuiteResult } from '../suiteResult/suiteResult'; /** * Conditionally skips running tests within the callback. @@ -19,7 +19,7 @@ import { useCreateSuiteResult } from 'suiteResult'; // @vx-allow use-use export function skipWhen( condition: TDraftCondition, - callback: CB + callback: CB, ): void { Isolate.create(VestIsolateType.SkipWhen, () => { SuiteContext.run( @@ -31,10 +31,10 @@ export function skipWhen( // Otherwise, we should skip the test if the conditional is true. optionalFunctionValue( condition, - optionalFunctionValue(useCreateSuiteResult) + optionalFunctionValue(useCreateSuiteResult), ), }, - callback + callback, ); }); } diff --git a/packages/vest/src/suite/SuiteTypes.ts b/packages/vest/src/suite/SuiteTypes.ts index b9ae2eddc..8fd1f8534 100644 --- a/packages/vest/src/suite/SuiteTypes.ts +++ b/packages/vest/src/suite/SuiteTypes.ts @@ -1,15 +1,16 @@ import { CB } from 'vest-utils'; -import { TIsolateSuite } from 'IsolateSuite'; +import { StaticSuiteRunResult } from './createSuite'; +import { TTypedMethods } from './getTypedMethods'; + +import { TIsolateSuite } from '@/core/isolate/IsolateSuite/IsolateSuite'; import { SuiteResult, SuiteRunResult, TFieldName, TGroupName, -} from 'SuiteResultTypes'; -import { StaticSuiteRunResult } from 'createSuite'; -import { TTypedMethods } from 'getTypedMethods'; -import { SuiteSelectors } from 'suiteSelectors'; +} from '@/suiteResult/SuiteResultTypes'; +import { SuiteSelectors } from '@/suiteResult/selectors/suiteSelectors'; export type Suite< F extends TFieldName, diff --git a/packages/vest/src/suite/SuiteWalker.ts b/packages/vest/src/suite/SuiteWalker.ts index 1ebb15231..e5d2d15e7 100644 --- a/packages/vest/src/suite/SuiteWalker.ts +++ b/packages/vest/src/suite/SuiteWalker.ts @@ -1,12 +1,12 @@ import { Predicate, Predicates, isEmpty, isNullish } from 'vest-utils'; import { TIsolate, VestRuntime, Walker } from 'vestjs-runtime'; -import { TIsolateTest } from 'IsolateTest'; -import { PreAggCache, usePreAggCache } from 'Runtime'; -import { TFieldName } from 'SuiteResultTypes'; -import { VestIsolate } from 'VestIsolate'; -import { VestTest } from 'VestTest'; -import { matchesOrHasNoFieldName } from 'matchingFieldName'; +import { PreAggCache, usePreAggCache } from '../core/Runtime'; +import { TIsolateTest } from '../core/isolate/IsolateTest/IsolateTest'; +import { VestTest } from '../core/isolate/IsolateTest/VestTest'; +import { VestIsolate } from '../core/isolate/VestIsolate'; +import { matchesOrHasNoFieldName } from '../core/test/helpers/matchingFieldName'; +import { TFieldName } from '../suiteResult/SuiteResultTypes'; export class SuiteWalker { static defaultRoot = VestRuntime.useAvailableRoot; diff --git a/packages/vest/src/suite/__tests__/create.test.ts b/packages/vest/src/suite/__tests__/create.test.ts index 75ddfc131..ec54ae97b 100644 --- a/packages/vest/src/suite/__tests__/create.test.ts +++ b/packages/vest/src/suite/__tests__/create.test.ts @@ -4,7 +4,7 @@ import { noop } from 'lodash'; import { dummyTest } from '../../testUtils/testDummy'; import { TestPromise } from '../../testUtils/testPromise'; -import { ErrorStrings } from 'ErrorStrings'; +import { ErrorStrings } from '@/errors/ErrorStrings'; import { create } from 'vest'; describe('Test createSuite module', () => { @@ -22,9 +22,9 @@ describe('Test createSuite module', () => { value => { // @ts-expect-error - testing invalid input expect(() => create(value)).toThrow( - ErrorStrings.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION + ErrorStrings.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION, ); - } + }, ); describe('When suite name is provided', () => { diff --git a/packages/vest/src/suite/__tests__/remove.test.ts b/packages/vest/src/suite/__tests__/remove.test.ts index aada25460..4c2d119cc 100644 --- a/packages/vest/src/suite/__tests__/remove.test.ts +++ b/packages/vest/src/suite/__tests__/remove.test.ts @@ -1,4 +1,4 @@ -import { Modes } from 'Modes'; +import { Modes } from '@/hooks/optional/Modes'; import wait from 'wait'; import { dummyTest } from '../../testUtils/testDummy'; diff --git a/packages/vest/src/suite/__tests__/resetField.test.ts b/packages/vest/src/suite/__tests__/resetField.test.ts index 01f957740..3abe3d8a6 100644 --- a/packages/vest/src/suite/__tests__/resetField.test.ts +++ b/packages/vest/src/suite/__tests__/resetField.test.ts @@ -1,4 +1,4 @@ -import { TTestSuite } from 'testUtils/TVestMock'; +import { TTestSuite } from '@/testUtils/TVestMock'; import { create, test } from 'vest'; describe('suite.resetField', () => { diff --git a/packages/vest/src/suite/__tests__/staticSuite.test.ts b/packages/vest/src/suite/__tests__/staticSuite.test.ts index 6d8696498..3bc6be3a7 100644 --- a/packages/vest/src/suite/__tests__/staticSuite.test.ts +++ b/packages/vest/src/suite/__tests__/staticSuite.test.ts @@ -1,7 +1,7 @@ import wait from 'wait'; -import { SuiteSerializer } from 'SuiteSerializer'; -import { VestIsolateType } from 'VestIsolateType'; +import { VestIsolateType } from '@/core/isolate/VestIsolateType'; +import { SuiteSerializer } from '@exports/SuiteSerializer'; import * as vest from 'vest'; import { staticSuite } from 'vest'; diff --git a/packages/vest/src/suite/__tests__/subscribe.test.ts b/packages/vest/src/suite/__tests__/subscribe.test.ts index a463fe71c..be6f27e55 100644 --- a/packages/vest/src/suite/__tests__/subscribe.test.ts +++ b/packages/vest/src/suite/__tests__/subscribe.test.ts @@ -1,7 +1,7 @@ import { enforce } from 'n4s'; import wait from 'wait'; -import { SuiteSerializer } from 'SuiteSerializer'; +import { SuiteSerializer } from '@exports/SuiteSerializer'; import * as vest from 'vest'; describe('suite.subscribe', () => { diff --git a/packages/vest/src/suite/__tests__/suiteSelectorsOnSuite.test.ts b/packages/vest/src/suite/__tests__/suiteSelectorsOnSuite.test.ts index c3c9c31d7..216bb20c0 100644 --- a/packages/vest/src/suite/__tests__/suiteSelectorsOnSuite.test.ts +++ b/packages/vest/src/suite/__tests__/suiteSelectorsOnSuite.test.ts @@ -1,4 +1,4 @@ -import { TTestSuite } from 'testUtils/TVestMock'; +import { TTestSuite } from '@/testUtils/TVestMock'; import * as vest from 'vest'; describe('Suite Selectors on Suite', () => { @@ -79,29 +79,29 @@ describe('Suite Selectors on Suite', () => { expect(res.hasWarnings('f4')).toEqual(suite.hasWarnings('f4')); expect(res.hasErrorsByGroup('g1')).toEqual(suite.hasErrorsByGroup('g1')); expect(res.hasErrorsByGroup('g1', 'f1')).toEqual( - suite.hasErrorsByGroup('g1', 'f1') + suite.hasErrorsByGroup('g1', 'f1'), ); expect(res.hasErrorsByGroup('g1', 'f2')).toEqual( - suite.hasErrorsByGroup('g1', 'f2') + suite.hasErrorsByGroup('g1', 'f2'), ); expect(res.hasErrorsByGroup('g1', 'f3')).toEqual( - suite.hasErrorsByGroup('g1', 'f3') + suite.hasErrorsByGroup('g1', 'f3'), ); expect(res.hasErrorsByGroup('g1', 'f4')).toEqual( - suite.hasErrorsByGroup('g1', 'f4') + suite.hasErrorsByGroup('g1', 'f4'), ); expect(res.getErrorsByGroup('g1')).toEqual(suite.getErrorsByGroup('g1')); expect(res.getErrorsByGroup('g1, f1')).toEqual( - suite.getErrorsByGroup('g1, f1') + suite.getErrorsByGroup('g1, f1'), ); expect(res.getErrorsByGroup('g1, f2')).toEqual( - suite.getErrorsByGroup('g1, f2') + suite.getErrorsByGroup('g1, f2'), ); expect(res.getErrorsByGroup('g1, f3')).toEqual( - suite.getErrorsByGroup('g1, f3') + suite.getErrorsByGroup('g1, f3'), ); expect(res.getErrorsByGroup('g1, f4')).toEqual( - suite.getErrorsByGroup('g1, f4') + suite.getErrorsByGroup('g1, f4'), ); expect(res.isValid()).toEqual(suite.isValid()); expect(res.isValid('f1')).toEqual(suite.isValid('f1')); diff --git a/packages/vest/src/suite/createSuite.ts b/packages/vest/src/suite/createSuite.ts index 06412167e..101d15989 100644 --- a/packages/vest/src/suite/createSuite.ts +++ b/packages/vest/src/suite/createSuite.ts @@ -1,26 +1,27 @@ import { assign, CB } from 'vest-utils'; import { Bus, VestRuntime } from 'vestjs-runtime'; -import { TTypedMethods, getTypedMethods } from './getTypedMethods'; - -import { Events } from 'BusEvents'; -import { IsolateSuite, TIsolateSuite } from 'IsolateSuite'; -import { useCreateVestState, useLoadSuite } from 'Runtime'; -import { SuiteContext } from 'SuiteContext'; +import { SuiteResult, SuiteRunResult } from '../../types/vest'; +import { useCreateVestState, useLoadSuite } from '../core/Runtime'; +import { Events } from '../core/VestBus/BusEvents'; +import { useInitVestBus } from '../core/VestBus/VestBus'; +import { SuiteContext } from '../core/context/SuiteContext'; +import { + IsolateSuite, + TIsolateSuite, +} from '../core/isolate/IsolateSuite/IsolateSuite'; import { SuiteName, - SuiteResult, - SuiteRunResult, TFieldName, TGroupName, -} from 'SuiteResultTypes'; -import { Suite } from 'SuiteTypes'; -import { useInitVestBus } from 'VestBus'; -import { VestReconciler } from 'VestReconciler'; -import { useCreateSuiteResult } from 'suiteResult'; -import { useSuiteRunResult } from 'suiteRunResult'; -import { bindSuiteSelectors } from 'suiteSelectors'; -import { validateSuiteCallback } from 'validateSuiteParams'; +} from '../suiteResult/SuiteResultTypes'; +import { bindSuiteSelectors } from '../suiteResult/selectors/suiteSelectors'; +import { useCreateSuiteResult } from '../suiteResult/suiteResult'; +import { useSuiteRunResult } from '../suiteResult/suiteRunResult'; + +import { Suite } from './SuiteTypes'; +import { TTypedMethods, getTypedMethods } from './getTypedMethods'; +import { validateSuiteCallback } from './validateParams/validateSuiteParams'; function createSuite< F extends TFieldName = string, diff --git a/packages/vest/src/suite/getTypedMethods.ts b/packages/vest/src/suite/getTypedMethods.ts index 8d21d25c6..89795066c 100644 --- a/packages/vest/src/suite/getTypedMethods.ts +++ b/packages/vest/src/suite/getTypedMethods.ts @@ -1,23 +1,26 @@ -// import { optional, skipWhen, omitWhen, IsolateTest, group } from 'vest'; -import { optional } from 'optional'; import { CB, DynamicValue } from 'vest-utils'; import { TIsolate, IsolateKey } from 'vestjs-runtime'; -import { TIsolateTest } from 'IsolateTest'; -import { OptionalsInput } from 'OptionalTypes'; -import { SuiteResult, TFieldName, TGroupName } from 'SuiteResultTypes'; -import { TestFn } from 'TestTypes'; -import { FieldExclusion, only, skip } from 'focused'; -import { group } from 'group'; -import { include } from 'include'; -import { omitWhen } from 'omitWhen'; -import { skipWhen } from 'skipWhen'; -import { test } from 'test'; -import { TestMemo } from 'test.memo'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { TestFn } from '@/core/test/TestTypes'; +import { test } from '@/core/test/test'; +import { TestMemo } from '@/core/test/test.memo'; +import { FieldExclusion, only, skip } from '@/hooks/focused/focused'; +import { include } from '@/hooks/include'; +import { OptionalsInput } from '@/hooks/optional/OptionalTypes'; +import { optional } from '@/hooks/optional/optional'; +import { group } from '@/isolates/group'; +import { omitWhen } from '@/isolates/omitWhen'; +import { skipWhen } from '@/isolates/skipWhen'; +import { + SuiteResult, + TFieldName, + TGroupName, +} from '@/suiteResult/SuiteResultTypes'; export function getTypedMethods< F extends TFieldName, - G extends TGroupName + G extends TGroupName, >(): TTypedMethods { return { group, @@ -60,5 +63,5 @@ export type TTypedMethods = { export type TDraftCondition< F extends TFieldName, - G extends TGroupName + G extends TGroupName, > = DynamicValue]>; diff --git a/packages/vest/src/suite/runCallbacks.ts b/packages/vest/src/suite/runCallbacks.ts index 813579805..7454164cf 100644 --- a/packages/vest/src/suite/runCallbacks.ts +++ b/packages/vest/src/suite/runCallbacks.ts @@ -1,8 +1,8 @@ import { isArray, callEach } from 'vest-utils'; -import { useDoneCallbacks, useFieldCallbacks } from 'Runtime'; -import { TFieldName } from 'SuiteResultTypes'; -import { SuiteWalker } from 'SuiteWalker'; +import { useDoneCallbacks, useFieldCallbacks } from '@/core/Runtime'; +import { TFieldName } from '@/suiteResult/SuiteResultTypes'; +import { SuiteWalker } from '@/suite/SuiteWalker'; /** * Runs done callback per field when async tests are finished running. diff --git a/packages/vest/src/suite/validateParams/validateSuiteParams.ts b/packages/vest/src/suite/validateParams/validateSuiteParams.ts index 692ac0e17..6f89bbe74 100644 --- a/packages/vest/src/suite/validateParams/validateSuiteParams.ts +++ b/packages/vest/src/suite/validateParams/validateSuiteParams.ts @@ -1,14 +1,12 @@ import { CB, invariant, isFunction } from 'vest-utils'; -import { ErrorStrings } from 'ErrorStrings'; - - +import { ErrorStrings } from '@/errors/ErrorStrings'; export function validateSuiteCallback( - suiteCallback: T + suiteCallback: T, ): asserts suiteCallback is T { invariant( isFunction(suiteCallback), - ErrorStrings.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION + ErrorStrings.SUITE_MUST_BE_INITIALIZED_WITH_FUNCTION, ); } diff --git a/packages/vest/src/suiteResult/SuiteResultTypes.ts b/packages/vest/src/suiteResult/SuiteResultTypes.ts index e3b9fc05b..f1c739eff 100644 --- a/packages/vest/src/suiteResult/SuiteResultTypes.ts +++ b/packages/vest/src/suiteResult/SuiteResultTypes.ts @@ -1,9 +1,9 @@ import { Maybe, Nullable } from 'vest-utils'; -import { Severity } from 'Severity'; -import { SummaryFailure } from 'SummaryFailure'; -import { Done } from 'suiteRunResult'; -import { SuiteSelectors } from 'suiteSelectors'; +import { Severity } from '@/suiteResult/Severity'; +import { SummaryFailure } from '@/suiteResult/SummaryFailure'; +import { SuiteSelectors } from '@/suiteResult/selectors/suiteSelectors'; +import { Done } from '@/suiteResult/suiteRunResult'; export class SummaryBase { public errorCount = 0; diff --git a/packages/vest/src/suiteResult/SummaryFailure.ts b/packages/vest/src/suiteResult/SummaryFailure.ts index fbbcc2c0f..fd6ef2d84 100644 --- a/packages/vest/src/suiteResult/SummaryFailure.ts +++ b/packages/vest/src/suiteResult/SummaryFailure.ts @@ -1,7 +1,7 @@ -import { TIsolateTest } from 'IsolateTest'; -import { TFieldName, TGroupName } from 'SuiteResultTypes'; -import { WithFieldName } from 'TestTypes'; -import { VestTest } from 'VestTest'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; +import { WithFieldName } from '@/core/test/TestTypes'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; export class SummaryFailure implements WithFieldName @@ -9,11 +9,11 @@ export class SummaryFailure constructor( public fieldName: F, public message: string | undefined, - public groupName: G | undefined + public groupName: G | undefined, ) {} static fromTestObject( - testObject: TIsolateTest + testObject: TIsolateTest, ) { const { fieldName, message, groupName } = VestTest.getData(testObject); diff --git a/packages/vest/src/suiteResult/__tests__/useProduceSuiteSummary.test.ts b/packages/vest/src/suiteResult/__tests__/useProduceSuiteSummary.test.ts index 8d50c2e96..df3590a56 100644 --- a/packages/vest/src/suiteResult/__tests__/useProduceSuiteSummary.test.ts +++ b/packages/vest/src/suiteResult/__tests__/useProduceSuiteSummary.test.ts @@ -3,7 +3,7 @@ import wait from 'wait'; import { ser } from '../../testUtils/suiteDummy'; import { dummyTest } from '../../testUtils/testDummy'; -import { Modes } from 'Modes'; +import { Modes } from '@/hooks/optional/Modes'; import * as vest from 'vest'; describe('useProduceSuiteSummary', () => { diff --git a/packages/vest/src/suiteResult/done/deferDoneCallback.ts b/packages/vest/src/suiteResult/done/deferDoneCallback.ts index 2258694c6..ff0b12d67 100644 --- a/packages/vest/src/suiteResult/done/deferDoneCallback.ts +++ b/packages/vest/src/suiteResult/done/deferDoneCallback.ts @@ -1,11 +1,15 @@ import { assign } from 'vest-utils'; -import { DoneCallback, useDoneCallbacks, useFieldCallbacks } from 'Runtime'; -import { TFieldName } from 'SuiteResultTypes'; +import { + DoneCallback, + useDoneCallbacks, + useFieldCallbacks, +} from '@/core/Runtime'; +import { TFieldName } from '@/suiteResult/SuiteResultTypes'; export function useDeferDoneCallback( doneCallback: DoneCallback, - fieldName?: TFieldName + fieldName?: TFieldName, ): void { const [, setFieldCallbacks] = useFieldCallbacks(); const [, setDoneCallbacks] = useDoneCallbacks(); @@ -14,7 +18,7 @@ export function useDeferDoneCallback( setFieldCallbacks(fieldCallbacks => assign(fieldCallbacks, { [fieldName]: (fieldCallbacks[fieldName] || []).concat(doneCallback), - }) + }), ); return; diff --git a/packages/vest/src/suiteResult/done/shouldSkipDoneRegistration.ts b/packages/vest/src/suiteResult/done/shouldSkipDoneRegistration.ts index d6a9931ae..af872eedc 100644 --- a/packages/vest/src/suiteResult/done/shouldSkipDoneRegistration.ts +++ b/packages/vest/src/suiteResult/done/shouldSkipDoneRegistration.ts @@ -9,16 +9,16 @@ import { SuiteRunResult, TFieldName, TGroupName, -} from 'SuiteResultTypes'; +} from '@/suiteResult/SuiteResultTypes'; export function shouldSkipDoneRegistration< F extends TFieldName, - G extends TGroupName + G extends TGroupName, >( callback: (res: SuiteResult) => void, fieldName: Maybe, - output: SuiteRunResult + output: SuiteRunResult, ): boolean { // If we do not have any test runs for the current field return !!( diff --git a/packages/vest/src/suiteResult/selectors/__tests__/collectFailureMessages.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/collectFailureMessages.test.ts index 78bb8d2a5..e0a82a1f6 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/collectFailureMessages.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/collectFailureMessages.test.ts @@ -1,9 +1,9 @@ -import { TTestSuite } from 'testUtils/TVestMock'; +import { TTestSuite } from '@/testUtils/TVestMock'; import { dummyTest } from '../../../testUtils/testDummy'; -import { Modes } from 'Modes'; -import { SuiteResult } from 'SuiteResultTypes'; +import { Modes } from '@/hooks/optional/Modes'; +import { SuiteResult } from '@/suiteResult/SuiteResultTypes'; import { create, group } from 'vest'; import * as vest from 'vest'; diff --git a/packages/vest/src/suiteResult/selectors/__tests__/getFailures.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/getFailures.test.ts index 4fc566d9d..97f4c2b62 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/getFailures.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/getFailures.test.ts @@ -1,6 +1,6 @@ import { dummyTest } from '../../../testUtils/testDummy'; -import { Modes } from 'Modes'; +import { Modes } from '@/hooks/optional/Modes'; import * as vest from 'vest'; describe('->getFailures', () => { diff --git a/packages/vest/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts index af312a626..26c5ea3c7 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts @@ -1,8 +1,8 @@ -import { TTestSuite } from 'testUtils/TVestMock'; +import { TTestSuite } from '@/testUtils/TVestMock'; import { dummyTest } from '../../../testUtils/testDummy'; -import { Modes } from 'Modes'; +import { Modes } from '@/hooks/optional/Modes'; import { create, group } from 'vest'; import * as vest from 'vest'; @@ -29,7 +29,7 @@ describe.each(modes)('produce method: %s', mode => { describe('When fieldName passed', () => { it('Should return an empty array', () => { expect(getRes().getErrorsByGroup('group_name', 'field_name')).toEqual( - [] + [], ); }); }); @@ -59,7 +59,7 @@ describe.each(modes)('produce method: %s', mode => { dummyTest.passing(); }); expect(getRes().getErrorsByGroup('group_name', 'field_name')).toEqual( - [] + [], ); }); }); @@ -128,7 +128,7 @@ describe.each(modes)('produce method: %s', mode => { describe('When fieldName passed', () => { it('Should return an empty array', () => { expect( - getRes().getWarningsByGroup('group_name', 'field_name') + getRes().getWarningsByGroup('group_name', 'field_name'), ).toEqual([]); }); }); @@ -158,7 +158,7 @@ describe.each(modes)('produce method: %s', mode => { dummyTest.passing(); }); expect( - getRes().getWarningsByGroup('group_name', 'field_name') + getRes().getWarningsByGroup('group_name', 'field_name'), ).toEqual([]); }); }); diff --git a/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts index a2bfe9e85..9a463fa8c 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts @@ -2,7 +2,7 @@ import { faker } from '@faker-js/faker'; import { dummyTest } from '../../../testUtils/testDummy'; -import { TTestSuite } from 'testUtils/TVestMock'; +import { TTestSuite } from '@/testUtils/TVestMock'; import * as vest from 'vest'; const fieldName = faker.lorem.word(); @@ -79,7 +79,7 @@ describe('hasErrorsByGroup', () => { }); }); expect(suite().hasErrorsByGroup(groupName, 'non_matching_field')).toBe( - false + false, ); }); }); @@ -167,7 +167,7 @@ describe('hasWarningsByGroup', () => { }); }); expect( - suite().hasWarningsByGroup(groupName, 'non_matching_field') + suite().hasWarningsByGroup(groupName, 'non_matching_field'), ).toBe(false); }); }); diff --git a/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByTestObject.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByTestObject.test.ts index 7d261210c..d3ca63d79 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByTestObject.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByTestObject.test.ts @@ -1,10 +1,10 @@ import { faker } from '@faker-js/faker'; -import { TIsolateTest } from 'IsolateTest'; -import { Severity } from 'Severity'; -import { VestTest } from 'VestTest'; -import { hasFailuresByTestObject } from 'hasFailuresByTestObjects'; -import { mockIsolateTest } from 'vestMocks'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { Severity } from '@/suiteResult/Severity'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { hasFailuresByTestObject } from '@/suiteResult/selectors/hasFailuresByTestObjects'; +import { mockIsolateTest } from '@/testUtils/vestMocks'; const fieldName: string = faker.lorem.word(); diff --git a/packages/vest/src/suiteResult/selectors/__tests__/isValid.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/isValid.test.ts index efa2b3b60..a65042ca5 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/isValid.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/isValid.test.ts @@ -1,4 +1,4 @@ -import { TTestSuite } from 'testUtils/TVestMock'; +import { TTestSuite } from '@/testUtils/TVestMock'; import wait from 'wait'; import { TestPromise } from '../../../testUtils/testPromise'; @@ -268,7 +268,7 @@ describe('isValid', () => { return true; }); }); - })().isValid() + })().isValid(), ).toBe(false); }); }); @@ -279,7 +279,7 @@ describe('isValid', () => { create(() => { skip('field_1'); test('field_1', () => true); - })().isValid('field_1') + })().isValid('field_1'), ).toBe(false); }); @@ -287,7 +287,7 @@ describe('isValid', () => { expect( create(() => { test('field_1', () => {}); - })().isValid('field 2') + })().isValid('field 2'), ).toBe(false); }); @@ -302,7 +302,7 @@ describe('isValid', () => { return true; }); }); - })().isValid('field_1') + })().isValid('field_1'), ).toBe(false); }); @@ -312,7 +312,7 @@ describe('isValid', () => { test('field_1', () => { return false; }); - })().isValid('field_1') + })().isValid('field_1'), ).toBe(false); }); @@ -322,7 +322,7 @@ describe('isValid', () => { test('field_1', () => { return true; }); - })().isValid('field_1') + })().isValid('field_1'), ).toBe(true); }); @@ -333,7 +333,7 @@ describe('isValid', () => { warn(); return false; }); - })().isValid('field_1') + })().isValid('field_1'), ).toBe(true); }); @@ -344,7 +344,7 @@ describe('isValid', () => { skipWhen(true, () => { test('field_1', () => false); }); - })().isValid('field_1') + })().isValid('field_1'), ).toBe(true); }); }); @@ -354,7 +354,7 @@ describe('isValid', () => { expect( create(() => { test('field_1', () => true); - })().isValid('field_2') + })().isValid('field_2'), ).toBe(false); }); }); diff --git a/packages/vest/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts index 78a75f0f1..c75548f61 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts @@ -2,8 +2,8 @@ import wait from 'wait'; import { TestPromise } from '../../../testUtils/testPromise'; -import { Modes } from 'Modes'; -import { TTestSuite } from 'testUtils/TVestMock'; +import { Modes } from '@/hooks/optional/Modes'; +import { TTestSuite } from '@/testUtils/TVestMock'; import { test, optional, @@ -50,19 +50,19 @@ describe('isValidByGroup', () => { it('Should return false when an optional test has errors', () => { expect(suite('field_2').isValidByGroup(GROUP_NAME)).toBe(false); expect(suite('field_2').isValidByGroup(GROUP_NAME, 'field_1')).toBe( - false + false, ); }); it('Should return false when a required test has errors', () => { expect(suite('field_1').isValidByGroup(GROUP_NAME)).toBe(false); expect(suite('field_1').isValidByGroup(GROUP_NAME, 'field_2')).toBe( - false + false, ); }); it('Should return false when the queried field is not optional and has errors', () => { expect(suite('field_2').isValidByGroup(GROUP_NAME, 'field_2')).toBe( - false + false, ); }); @@ -147,7 +147,7 @@ describe('isValidByGroup', () => { }); it('Should return false', () => { expect(suite(['field_2', 'field_3']).isValidByGroup(GROUP_NAME)).toBe( - false + false, ); }); }); @@ -310,7 +310,7 @@ describe('isValidByGroup', () => { }); }); }); - })().isValidByGroup(GROUP_NAME) + })().isValidByGroup(GROUP_NAME), ).toBe(false); }); }); @@ -323,7 +323,7 @@ describe('isValidByGroup', () => { group(GROUP_NAME, () => { test('field_1', () => true); }); - })().isValidByGroup(GROUP_NAME, 'field_1') + })().isValidByGroup(GROUP_NAME, 'field_1'), ).toBe(false); }); @@ -333,7 +333,7 @@ describe('isValidByGroup', () => { group(GROUP_NAME, () => { test('field_1', () => {}); }); - })().isValidByGroup(GROUP_NAME, 'field 2') + })().isValidByGroup(GROUP_NAME, 'field 2'), ).toBe(false); }); @@ -350,7 +350,7 @@ describe('isValidByGroup', () => { }); }); }); - })().isValidByGroup(GROUP_NAME, 'field_1') + })().isValidByGroup(GROUP_NAME, 'field_1'), ).toBe(false); }); @@ -360,7 +360,7 @@ describe('isValidByGroup', () => { group(GROUP_NAME, () => { test('field_1', () => false); }); - })().isValidByGroup(GROUP_NAME, 'field_1') + })().isValidByGroup(GROUP_NAME, 'field_1'), ).toBe(false); }); @@ -370,7 +370,7 @@ describe('isValidByGroup', () => { group(GROUP_NAME, () => { test('field_1', () => {}); }); - })().isValidByGroup(GROUP_NAME, 'field_1') + })().isValidByGroup(GROUP_NAME, 'field_1'), ).toBe(true); }); @@ -383,7 +383,7 @@ describe('isValidByGroup', () => { return false; }); }); - })().isValidByGroup(GROUP_NAME, 'field_1') + })().isValidByGroup(GROUP_NAME, 'field_1'), ).toBe(true); }); @@ -396,7 +396,7 @@ describe('isValidByGroup', () => { test('field_1', () => false); }); }); - })().isValidByGroup(GROUP_NAME, 'field_1') + })().isValidByGroup(GROUP_NAME, 'field_1'), ).toBe(true); }); }); @@ -408,7 +408,7 @@ describe('isValidByGroup', () => { group(GROUP_NAME, () => { test('field_1', () => true); }); - })().isValidByGroup(GROUP_NAME, 'field_2') + })().isValidByGroup(GROUP_NAME, 'field_2'), ).toBe(false); }); }); @@ -435,7 +435,7 @@ describe('isValidByGroup', () => { group(GROUP_NAME, () => { test('field_1', () => false); }); - })().isValidByGroup(GROUP_NAME) + })().isValidByGroup(GROUP_NAME), ).toBe(true); }); }); diff --git a/packages/vest/src/suiteResult/selectors/__tests__/summaryFailures.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/summaryFailures.test.ts index 1d2e1199d..baef8d210 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/summaryFailures.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/summaryFailures.test.ts @@ -1,4 +1,4 @@ -import { TTestSuite } from 'testUtils/TVestMock'; +import { TTestSuite } from '@/testUtils/TVestMock'; import * as vest from 'vest'; diff --git a/packages/vest/src/suiteResult/selectors/collectFailures.ts b/packages/vest/src/suiteResult/selectors/collectFailures.ts index 798d69c70..af1057e12 100644 --- a/packages/vest/src/suiteResult/selectors/collectFailures.ts +++ b/packages/vest/src/suiteResult/selectors/collectFailures.ts @@ -1,19 +1,19 @@ import { isPositive } from 'vest-utils'; -import { countKeyBySeverity, Severity } from 'Severity'; +import { countKeyBySeverity, Severity } from '@/suiteResult/Severity'; import { FailureMessages, TestsContainer, TFieldName, TGroupName, -} from 'SuiteResultTypes'; +} from '@/suiteResult/SuiteResultTypes'; // calls collectAll or getByFieldName depending on whether fieldName is provided export function gatherFailures( testGroup: TestsContainer, severityKey: Severity, - fieldName?: TFieldName + fieldName?: TFieldName, ): string[] | FailureMessages { return fieldName ? getByFieldName(testGroup, severityKey, fieldName) @@ -23,14 +23,14 @@ export function gatherFailures( function getByFieldName( testGroup: TestsContainer, severityKey: Severity, - fieldName: TFieldName + fieldName: TFieldName, ): string[] { return testGroup?.[fieldName]?.[severityKey] || []; } function collectAll( testGroup: TestsContainer, - severityKey: Severity + severityKey: Severity, ): FailureMessages { const output: FailureMessages = {}; diff --git a/packages/vest/src/suiteResult/selectors/hasFailuresByTestObjects.ts b/packages/vest/src/suiteResult/selectors/hasFailuresByTestObjects.ts index d83df1e25..86e785313 100644 --- a/packages/vest/src/suiteResult/selectors/hasFailuresByTestObjects.ts +++ b/packages/vest/src/suiteResult/selectors/hasFailuresByTestObjects.ts @@ -1,14 +1,14 @@ import { isEmpty } from 'vest-utils'; -import { TIsolateTest } from 'IsolateTest'; -import { Severity } from 'Severity'; -import { TFieldName, TGroupName } from 'SuiteResultTypes'; -import { SuiteWalker } from 'SuiteWalker'; -import { TestWalker } from 'TestWalker'; -import { VestTest } from 'VestTest'; -import { nonMatchingFieldName } from 'matchingFieldName'; -import { nonMatchingGroupName } from 'matchingGroupName'; -import { nonMatchingSeverityProfile } from 'nonMatchingSeverityProfile'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { TestWalker } from '@/core/isolate/IsolateTest/TestWalker'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { nonMatchingFieldName } from '@/core/test/helpers/matchingFieldName'; +import { nonMatchingGroupName } from '@/core/test/helpers/matchingGroupName'; +import { nonMatchingSeverityProfile } from '@/core/test/helpers/nonMatchingSeverityProfile'; +import { SuiteWalker } from '@/suite/SuiteWalker'; +import { Severity } from '@/suiteResult/Severity'; +import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; /** * The difference between this file and hasFailures is that hasFailures uses the static diff --git a/packages/vest/src/suiteResult/selectors/shouldAddValidProperty.ts b/packages/vest/src/suiteResult/selectors/shouldAddValidProperty.ts index f1f2016cc..71e8156a7 100644 --- a/packages/vest/src/suiteResult/selectors/shouldAddValidProperty.ts +++ b/packages/vest/src/suiteResult/selectors/shouldAddValidProperty.ts @@ -1,21 +1,24 @@ -import { useIsOptionalFieldApplied } from 'optional'; import { Predicates } from 'vest-utils'; import { VestRuntime } from 'vestjs-runtime'; -import { SuiteOptionalFields, TIsolateSuite } from 'IsolateSuite'; -import { TIsolateTest } from 'IsolateTest'; -import { OptionalFieldTypes } from 'OptionalTypes'; -import { Severity } from 'Severity'; -import { TFieldName, TGroupName } from 'SuiteResultTypes'; -import { SuiteWalker } from 'SuiteWalker'; -import { TestWalker } from 'TestWalker'; -import { VestTest } from 'VestTest'; +import { + SuiteOptionalFields, + TIsolateSuite, +} from '@/core/isolate/IsolateSuite/IsolateSuite'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { TestWalker } from '@/core/isolate/IsolateTest/TestWalker'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { nonMatchingFieldName } from '@/core/test/helpers/matchingFieldName'; +import { nonMatchingGroupName } from '@/core/test/helpers/matchingGroupName'; +import { OptionalFieldTypes } from '@/hooks/optional/OptionalTypes'; +import { useIsOptionalFieldApplied } from '@/hooks/optional/optional'; +import { SuiteWalker } from '@/suite/SuiteWalker'; +import { Severity } from '@/suiteResult/Severity'; +import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; import { hasErrorsByTestObjects, hasGroupFailuresByTestObjects, -} from 'hasFailuresByTestObjects'; -import { nonMatchingFieldName } from 'matchingFieldName'; -import { nonMatchingGroupName } from 'matchingGroupName'; +} from '@/suiteResult/selectors/hasFailuresByTestObjects'; export function useShouldAddValidProperty(fieldName?: TFieldName): boolean { // Is the field optional, and the optional condition is applied diff --git a/packages/vest/src/suiteResult/selectors/suiteSelectors.ts b/packages/vest/src/suiteResult/selectors/suiteSelectors.ts index d07b4cf55..0f879c82e 100644 --- a/packages/vest/src/suiteResult/selectors/suiteSelectors.ts +++ b/packages/vest/src/suiteResult/selectors/suiteSelectors.ts @@ -1,6 +1,9 @@ import { Maybe, greaterThan, isPositive } from 'vest-utils'; -import { Severity, SeverityCount } from 'Severity'; +import { gatherFailures } from './collectFailures'; + +import matchingFieldName from '@/core/test/helpers/matchingFieldName'; +import { Severity, SeverityCount } from '@/suiteResult/Severity'; import { FailureMessages, GetFailuresResponse, @@ -9,10 +12,8 @@ import { TFieldName, TGroupName, TestsContainer, -} from 'SuiteResultTypes'; -import { SummaryFailure } from 'SummaryFailure'; -import { gatherFailures } from 'collectFailures'; -import matchingFieldName from 'matchingFieldName'; +} from '@/suiteResult/SuiteResultTypes'; +import { SummaryFailure } from '@/suiteResult/SummaryFailure'; export function bindSuiteSelectors( get: () => SuiteResult, diff --git a/packages/vest/src/suiteResult/selectors/useProduceSuiteSummary.ts b/packages/vest/src/suiteResult/selectors/useProduceSuiteSummary.ts index bf5e5922b..0cd3e5237 100644 --- a/packages/vest/src/suiteResult/selectors/useProduceSuiteSummary.ts +++ b/packages/vest/src/suiteResult/selectors/useProduceSuiteSummary.ts @@ -1,7 +1,7 @@ import { Maybe, assign, defaultTo } from 'vest-utils'; -import { TIsolateTest } from 'IsolateTest'; -import { countKeyBySeverity, Severity } from 'Severity'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { countKeyBySeverity, Severity } from '@/suiteResult/Severity'; import { Groups, SingleTestSummary, @@ -10,10 +10,10 @@ import { TFieldName, TGroupName, Tests, -} from 'SuiteResultTypes'; -import { SummaryFailure } from 'SummaryFailure'; -import { TestWalker } from 'TestWalker'; -import { VestTest } from 'VestTest'; +} from '@/suiteResult/SuiteResultTypes'; +import { SummaryFailure } from '@/suiteResult/SummaryFailure'; +import { TestWalker } from '@/core/isolate/IsolateTest/TestWalker'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; import { useShouldAddValidProperty, useShouldAddValidPropertyInGroup, diff --git a/packages/vest/src/suiteResult/suiteResult.ts b/packages/vest/src/suiteResult/suiteResult.ts index 76086110d..edec7a140 100644 --- a/packages/vest/src/suiteResult/suiteResult.ts +++ b/packages/vest/src/suiteResult/suiteResult.ts @@ -1,9 +1,14 @@ import { freezeAssign } from 'vest-utils'; -import { useSuiteName, useSuiteResultCache } from 'Runtime'; -import { SuiteResult, TFieldName, TGroupName } from 'SuiteResultTypes'; -import { suiteSelectors } from 'suiteSelectors'; -import { useProduceSuiteSummary } from 'useProduceSuiteSummary'; +import { useProduceSuiteSummary } from './selectors/useProduceSuiteSummary'; + +import { useSuiteName, useSuiteResultCache } from '@/core/Runtime'; +import { + SuiteResult, + TFieldName, + TGroupName, +} from '@/suiteResult/SuiteResultTypes'; +import { suiteSelectors } from '@/suiteResult/selectors/suiteSelectors'; export function useCreateSuiteResult< F extends TFieldName, diff --git a/packages/vest/src/suiteResult/suiteRunResult.ts b/packages/vest/src/suiteResult/suiteRunResult.ts index fd6f7357d..d87ec6578 100644 --- a/packages/vest/src/suiteResult/suiteRunResult.ts +++ b/packages/vest/src/suiteResult/suiteRunResult.ts @@ -1,16 +1,17 @@ import { freezeAssign } from 'vest-utils'; import { VestRuntime } from 'vestjs-runtime'; +import { useDeferDoneCallback } from './done/deferDoneCallback'; +import { shouldSkipDoneRegistration } from './done/shouldSkipDoneRegistration'; + +import { SuiteWalker } from '@/suite/SuiteWalker'; import { SuiteResult, SuiteRunResult, TFieldName, TGroupName, -} from 'SuiteResultTypes'; -import { SuiteWalker } from 'SuiteWalker'; -import { useDeferDoneCallback } from 'deferDoneCallback'; -import { shouldSkipDoneRegistration } from 'shouldSkipDoneRegistration'; -import { useCreateSuiteResult } from 'suiteResult'; +} from '@/suiteResult/SuiteResultTypes'; +import { useCreateSuiteResult } from '@/suiteResult/suiteResult'; export function useSuiteRunResult< F extends TFieldName, diff --git a/packages/vest/src/testUtils/TVestMock.ts b/packages/vest/src/testUtils/TVestMock.ts index 9d7770654..975f11260 100644 --- a/packages/vest/src/testUtils/TVestMock.ts +++ b/packages/vest/src/testUtils/TVestMock.ts @@ -1,4 +1,4 @@ -import { TFieldName, TGroupName } from 'SuiteResultTypes'; +import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; import * as vest from 'vest'; export type TVestMock = typeof vest; diff --git a/packages/vest/src/testUtils/suiteDummy.ts b/packages/vest/src/testUtils/suiteDummy.ts index 59917a1d4..bd617a334 100644 --- a/packages/vest/src/testUtils/suiteDummy.ts +++ b/packages/vest/src/testUtils/suiteDummy.ts @@ -2,7 +2,7 @@ import { OneOrMoreOf, asArray, Maybe } from 'vest-utils'; import { dummyTest } from './testDummy'; -import { TFieldName, TGroupName } from 'SuiteResultTypes'; +import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; import { optional, create, skip, SuiteResult } from 'vest'; export function failing(failingFields?: OneOrMoreOf) { @@ -31,7 +31,7 @@ export function passing(fields?: OneOrMoreOf) { export function passingWithUntestedOptional( optionals: OneOrMoreOf = 'optional_field', - required: OneOrMoreOf = 'field_1' + required: OneOrMoreOf = 'field_1', ) { return create(() => { optional(optionals); @@ -49,7 +49,7 @@ export function passingWithUntestedOptional( export function passingWithOptional( optionals: OneOrMoreOf = 'optional_field', - required: OneOrMoreOf = 'field_1' + required: OneOrMoreOf = 'field_1', ) { return create(() => { optional(optionals); @@ -66,7 +66,7 @@ export function passingWithOptional( export function failingOptional( optionals: OneOrMoreOf = 'optional_field', - required: OneOrMoreOf = 'field_1' + required: OneOrMoreOf = 'field_1', ) { return create(() => { optional(optionals); @@ -90,14 +90,14 @@ export function untested(fields?: OneOrMoreOf) { function createSuiteRunResult( fieldNames: Maybe, - callback: (_fieldName?: string) => void + callback: (_fieldName?: string) => void, ) { return createSuite(fieldNames, callback)(); } function createSuite( fieldNames: Maybe = 'field_1', - callback: (_fieldName?: string) => void + callback: (_fieldName?: string) => void, ) { return create(() => { asArray(fieldNames).forEach(fieldName => callback(fieldName)); @@ -105,7 +105,7 @@ function createSuite( } export function ser( - res: SuiteResult + res: SuiteResult, ) { return JSON.parse(JSON.stringify(res)); } diff --git a/packages/vest/src/testUtils/vestMocks.ts b/packages/vest/src/testUtils/vestMocks.ts index d6804e041..d212a81f6 100644 --- a/packages/vest/src/testUtils/vestMocks.ts +++ b/packages/vest/src/testUtils/vestMocks.ts @@ -1,10 +1,14 @@ import { genTestIsolate } from 'vestjs-runtime/test-utils'; -import { IsolateTestBase, IsolateTestPayload, TIsolateTest } from 'IsolateTest'; -import { VestIsolateType } from 'VestIsolateType'; +import { + IsolateTestBase, + IsolateTestPayload, + TIsolateTest, +} from '@/core/isolate/IsolateTest/IsolateTest'; +import { VestIsolateType } from '@/core/isolate/VestIsolateType'; export function mockIsolateTest( - payload: Partial = {} + payload: Partial = {}, ): TIsolateTest { const isolate = genTestIsolate({ ...IsolateTestBase(), diff --git a/packages/vest/src/vest.ts b/packages/vest/src/vest.ts index 0c83f41a1..be4b14449 100644 --- a/packages/vest/src/vest.ts +++ b/packages/vest/src/vest.ts @@ -1,25 +1,25 @@ import { enforce } from 'n4s'; -import { optional } from 'optional'; -import { Modes } from 'Modes'; +import { registerReconciler } from '@/core/isolate/VestReconciler'; +import { test } from '@/core/test/test'; +import { skip, only } from '@/hooks/focused/focused'; +import { include } from '@/hooks/include'; +import { Modes } from '@/hooks/optional/Modes'; +import { mode } from '@/hooks/optional/mode'; +import { optional } from '@/hooks/optional/optional'; +import { warn } from '@/hooks/warn'; +import { each } from '@/isolates/each'; +import { group } from '@/isolates/group'; +import { omitWhen } from '@/isolates/omitWhen'; +import { skipWhen } from '@/isolates/skipWhen'; +import type { Suite } from '@/suite/SuiteTypes'; +import { createSuite, staticSuite, StaticSuite } from '@/suite/createSuite'; import type { SuiteResult, SuiteRunResult, SuiteSummary, -} from 'SuiteResultTypes'; -import type { Suite } from 'SuiteTypes'; -import { registerReconciler } from 'VestReconciler'; -import { createSuite, staticSuite, StaticSuite } from 'createSuite'; -import { each } from 'each'; -import { skip, only } from 'focused'; -import { group } from 'group'; -import { include } from 'include'; -import { mode } from 'mode'; -import { omitWhen } from 'omitWhen'; -import { skipWhen } from 'skipWhen'; -import { suiteSelectors } from 'suiteSelectors'; -import { test } from 'test'; -import { warn } from 'warn'; +} from '@/suiteResult/SuiteResultTypes'; +import { suiteSelectors } from '@/suiteResult/selectors/suiteSelectors'; export { createSuite as create, diff --git a/packages/vest/tsconfig.json b/packages/vest/tsconfig.json index 1eee3487e..fca81718b 100644 --- a/packages/vest/tsconfig.json +++ b/packages/vest/tsconfig.json @@ -7,110 +7,8 @@ "declarationMap": true, "outDir": "./dist", "paths": { - "vest": ["./src/vest.ts"], - "vestMocks": ["./src/testUtils/vestMocks.ts"], - "testPromise": ["./src/testUtils/testPromise.ts"], - "testDummy": ["./src/testUtils/testDummy.ts"], - "suiteDummy": ["./src/testUtils/suiteDummy.ts"], - "partition": ["./src/testUtils/partition.ts"], - "mockThrowError": ["./src/testUtils/mockThrowError.ts"], - "TVestMock": ["./src/testUtils/TVestMock.ts"], - "suiteRunResult": ["./src/suiteResult/suiteRunResult.ts"], - "suiteResult": ["./src/suiteResult/suiteResult.ts"], - "SummaryFailure": ["./src/suiteResult/SummaryFailure.ts"], - "SuiteResultTypes": ["./src/suiteResult/SuiteResultTypes.ts"], - "Severity": ["./src/suiteResult/Severity.ts"], - "useProduceSuiteSummary": [ - "./src/suiteResult/selectors/useProduceSuiteSummary.ts" - ], - "suiteSelectors": ["./src/suiteResult/selectors/suiteSelectors.ts"], - "shouldAddValidProperty": [ - "./src/suiteResult/selectors/shouldAddValidProperty.ts" - ], - "hasFailuresByTestObjects": [ - "./src/suiteResult/selectors/hasFailuresByTestObjects.ts" - ], - "collectFailures": ["./src/suiteResult/selectors/collectFailures.ts"], - "shouldSkipDoneRegistration": [ - "./src/suiteResult/done/shouldSkipDoneRegistration.ts" - ], - "deferDoneCallback": ["./src/suiteResult/done/deferDoneCallback.ts"], - "runCallbacks": ["./src/suite/runCallbacks.ts"], - "getTypedMethods": ["./src/suite/getTypedMethods.ts"], - "createSuite": ["./src/suite/createSuite.ts"], - "SuiteWalker": ["./src/suite/SuiteWalker.ts"], - "SuiteTypes": ["./src/suite/SuiteTypes.ts"], - "validateSuiteParams": [ - "./src/suite/validateParams/validateSuiteParams.ts" - ], - "skipWhen": ["./src/isolates/skipWhen.ts"], - "omitWhen": ["./src/isolates/omitWhen.ts"], - "group": ["./src/isolates/group.ts"], - "each": ["./src/isolates/each.ts"], - "warn": ["./src/hooks/warn.ts"], - "include": ["./src/hooks/include.ts"], - "optional": ["./src/hooks/optional/optional.ts"], - "omitOptionalFields": ["./src/hooks/optional/omitOptionalFields.ts"], - "mode": ["./src/hooks/optional/mode.ts"], - "OptionalTypes": ["./src/hooks/optional/OptionalTypes.ts"], - "Modes": ["./src/hooks/optional/Modes.ts"], - "useIsExcluded": ["./src/hooks/focused/useIsExcluded.ts"], - "useHasOnliedTests": ["./src/hooks/focused/useHasOnliedTests.ts"], - "focused": ["./src/hooks/focused/focused.ts"], - "FocusedKeys": ["./src/hooks/focused/FocusedKeys.ts"], - "promisify": ["./src/exports/promisify.ts"], - "parser": ["./src/exports/parser.ts"], - "enforce@schema": ["./src/exports/enforce@schema.ts"], - "enforce@isURL": ["./src/exports/enforce@isURL.ts"], - "enforce@email": ["./src/exports/enforce@email.ts"], - "enforce@date": ["./src/exports/enforce@date.ts"], - "enforce@compounds": ["./src/exports/enforce@compounds.ts"], - "enforce@compose": ["./src/exports/enforce@compose.ts"], - "debounce": ["./src/exports/debounce.ts"], - "classnames": ["./src/exports/classnames.ts"], - "SuiteSerializer": ["./src/exports/SuiteSerializer.ts"], - "ErrorStrings": ["./src/errors/ErrorStrings.ts"], - "Runtime": ["./src/core/Runtime.ts"], - "test": ["./src/core/test/test.ts"], - "test.memo": ["./src/core/test/test.memo.ts"], - "TestTypes": ["./src/core/test/TestTypes.ts"], - "verifyTestRun": [ - "./src/core/test/testLevelFlowControl/verifyTestRun.ts" - ], - "runTest": ["./src/core/test/testLevelFlowControl/runTest.ts"], - "shouldUseErrorMessage": [ - "./src/core/test/helpers/shouldUseErrorMessage.ts" - ], - "nonMatchingSeverityProfile": [ - "./src/core/test/helpers/nonMatchingSeverityProfile.ts" - ], - "matchingGroupName": ["./src/core/test/helpers/matchingGroupName.ts"], - "matchingFieldName": ["./src/core/test/helpers/matchingFieldName.ts"], - "VestReconciler": ["./src/core/isolate/VestReconciler.ts"], - "VestIsolateType": ["./src/core/isolate/VestIsolateType.ts"], - "VestIsolate": ["./src/core/isolate/VestIsolate.ts"], - "IsolateReconciler": ["./src/core/isolate/IsolateReconciler.ts"], - "isSameProfileTest": [ - "./src/core/isolate/IsolateTest/isSameProfileTest.ts" - ], - "cancelOverriddenPendingTest": [ - "./src/core/isolate/IsolateTest/cancelOverriddenPendingTest.ts" - ], - "VestTest": ["./src/core/isolate/IsolateTest/VestTest.ts"], - "TestWalker": ["./src/core/isolate/IsolateTest/TestWalker.ts"], - "IsolateTestReconciler": [ - "./src/core/isolate/IsolateTest/IsolateTestReconciler.ts" - ], - "IsolateTest": ["./src/core/isolate/IsolateTest/IsolateTest.ts"], - "IsolateSuite": ["./src/core/isolate/IsolateSuite/IsolateSuite.ts"], - "IsolateEach": ["./src/core/isolate/IsolateEach/IsolateEach.ts"], - "SuiteContext": ["./src/core/context/SuiteContext.ts"], - "VestBus": ["./src/core/VestBus/VestBus.ts"], - "BusEvents": ["./src/core/VestBus/BusEvents.ts"], - "IsolateTestStateMachine": [ - "./src/core/StateMachines/IsolateTestStateMachine.ts" - ], - "CommonStateMachine": ["./src/core/StateMachines/CommonStateMachine.ts"] + "@exports/*": ["src/exports/*"], + "@/*": ["src/*"] } } } diff --git a/packages/vestjs-runtime/src/Bus.ts b/packages/vestjs-runtime/src/Bus.ts index 38bbefd33..d144918e5 100644 --- a/packages/vestjs-runtime/src/Bus.ts +++ b/packages/vestjs-runtime/src/Bus.ts @@ -1,6 +1,6 @@ import { isNullish } from 'vest-utils'; -import { persist, useX } from 'VestRuntime'; +import { persist, useX } from '@/VestRuntime'; export function useBus() { return useX().stateRef.Bus; diff --git a/packages/vestjs-runtime/src/Isolate/Isolate.ts b/packages/vestjs-runtime/src/Isolate/Isolate.ts index 2ec4874d8..f78819607 100644 --- a/packages/vestjs-runtime/src/Isolate/Isolate.ts +++ b/packages/vestjs-runtime/src/Isolate/Isolate.ts @@ -1,11 +1,10 @@ import { CB, Maybe, Nullable, isNotNullish, isPromise } from 'vest-utils'; -import { useEmit } from 'Bus'; -import { IsolateKeys } from 'IsolateKeys'; -import { IsolateMutator } from 'IsolateMutator'; -import { Reconciler } from 'Reconciler'; -import { RuntimeEvents } from 'RuntimeEvents'; -import * as VestRuntime from 'VestRuntime'; +import { useEmit } from '../Bus'; +import { RuntimeEvents } from '../RuntimeEvents'; +import { IsolateMutator, Reconciler, VestRuntime } from '../vestjs-runtime'; + +import { IsolateKeys } from './IsolateKeys'; export type IsolateKey = Nullable; diff --git a/packages/vestjs-runtime/src/Isolate/IsolateInspector.ts b/packages/vestjs-runtime/src/Isolate/IsolateInspector.ts index 98b42ae2b..0130887e3 100644 --- a/packages/vestjs-runtime/src/Isolate/IsolateInspector.ts +++ b/packages/vestjs-runtime/src/Isolate/IsolateInspector.ts @@ -1,6 +1,6 @@ import { Nullable, isNotNullish, isNullish } from 'vest-utils'; -import { TIsolate } from 'Isolate'; +import { TIsolate } from './Isolate'; export class IsolateInspector { static at(isolate: Nullable, at: number): Nullable { @@ -26,7 +26,7 @@ export class IsolateInspector { } static allowsReorder>( - isolate: Nullable + isolate: Nullable, ): boolean { return isolate?.allowReorder === true; } @@ -40,7 +40,7 @@ export class IsolateInspector { static getChildByKey( isolate: Nullable, - key: string + key: string, ): Nullable { if (isNullish(isolate)) { return null; diff --git a/packages/vestjs-runtime/src/Isolate/IsolateMutator.ts b/packages/vestjs-runtime/src/Isolate/IsolateMutator.ts index b4dd5d15a..4ed4e15ad 100644 --- a/packages/vestjs-runtime/src/Isolate/IsolateMutator.ts +++ b/packages/vestjs-runtime/src/Isolate/IsolateMutator.ts @@ -1,6 +1,6 @@ import { Nullable, invariant, isNullish } from 'vest-utils'; -import { TIsolate } from 'Isolate'; +import { TIsolate } from './Isolate'; export class IsolateMutator { static setParent(isolate: TIsolate, parent: Nullable): TIsolate { diff --git a/packages/vestjs-runtime/src/Isolate/IsolateSelectors.ts b/packages/vestjs-runtime/src/Isolate/IsolateSelectors.ts index 119e0f9f1..e209b1b38 100644 --- a/packages/vestjs-runtime/src/Isolate/IsolateSelectors.ts +++ b/packages/vestjs-runtime/src/Isolate/IsolateSelectors.ts @@ -1,25 +1,25 @@ import { Maybe } from 'vest-utils'; -import { TIsolate } from 'Isolate'; -import { IsolateKeys } from 'IsolateKeys'; +import { TIsolate } from './Isolate'; +import { IsolateKeys } from './IsolateKeys'; export function isIsolateType( node: Maybe, - type: string + type: string, ): node is I { return node?.[IsolateKeys.Type] === type; } export function isSameIsolateType( a: A, - b: B + b: B, ): boolean { return isIsolateType(a, b[IsolateKeys.Type]); } export function isSameIsolateIdentity( a: A, - b: B + b: B, ): boolean { return Object.is(a, b) || (isSameIsolateType(a, b) && a.key === b.key); } diff --git a/packages/vestjs-runtime/src/Isolate/__tests__/Isolate.test.ts b/packages/vestjs-runtime/src/Isolate/__tests__/Isolate.test.ts index b34a9c6ba..0c9f1bce8 100644 --- a/packages/vestjs-runtime/src/Isolate/__tests__/Isolate.test.ts +++ b/packages/vestjs-runtime/src/Isolate/__tests__/Isolate.test.ts @@ -1,8 +1,8 @@ import { CB } from 'vest-utils'; -import { TIsolate, Isolate } from 'Isolate'; -import { StateRefType, useAvailableRoot } from 'VestRuntime'; -import { IsolateMutator, VestRuntime } from 'vestjs-runtime'; +import { StateRefType, useAvailableRoot } from '../../VestRuntime'; +import { Isolate, IsolateMutator, VestRuntime } from '../../vestjs-runtime'; +import { TIsolate } from '../Isolate'; enum IsolateType { Isolate = 'Isolate', @@ -39,7 +39,7 @@ describe('Isolate', () => { () => { return 'foo'; }, - {} + {}, ); }); expect(isolate.output).toBe('foo'); diff --git a/packages/vestjs-runtime/src/Isolate/__tests__/IsolateInspector.test.ts b/packages/vestjs-runtime/src/Isolate/__tests__/IsolateInspector.test.ts index 67441ec57..e4e1970c1 100644 --- a/packages/vestjs-runtime/src/Isolate/__tests__/IsolateInspector.test.ts +++ b/packages/vestjs-runtime/src/Isolate/__tests__/IsolateInspector.test.ts @@ -1,5 +1,5 @@ -import { TIsolate } from 'Isolate'; -import { IsolateInspector } from 'IsolateInspector'; +import { IsolateInspector } from '../../vestjs-runtime'; +import { TIsolate } from '../Isolate'; describe('IsolateInspector', () => { describe('at', () => { diff --git a/packages/vestjs-runtime/src/Isolate/__tests__/IsolateMutator.test.ts b/packages/vestjs-runtime/src/Isolate/__tests__/IsolateMutator.test.ts index 82f954278..27c42cd77 100644 --- a/packages/vestjs-runtime/src/Isolate/__tests__/IsolateMutator.test.ts +++ b/packages/vestjs-runtime/src/Isolate/__tests__/IsolateMutator.test.ts @@ -1,5 +1,5 @@ -import { TIsolate } from 'Isolate'; -import { IsolateMutator } from 'IsolateMutator'; +import { IsolateMutator } from '../../vestjs-runtime'; +import { TIsolate } from '../Isolate'; describe('IsolateMutator', () => { describe('setParent', () => { diff --git a/packages/vestjs-runtime/src/Isolate/__tests__/asyncIsolate.test.ts b/packages/vestjs-runtime/src/Isolate/__tests__/asyncIsolate.test.ts index 61ee003bc..4b551da7d 100644 --- a/packages/vestjs-runtime/src/Isolate/__tests__/asyncIsolate.test.ts +++ b/packages/vestjs-runtime/src/Isolate/__tests__/asyncIsolate.test.ts @@ -1,10 +1,10 @@ import { CB } from 'vest-utils'; import wait from 'wait'; -import { useBus } from 'Bus'; -import { Isolate, TIsolate } from 'Isolate'; -import { RuntimeEvents } from 'RuntimeEvents'; -import { VestRuntime } from 'vestjs-runtime'; +import { useBus } from '../../Bus'; +import { RuntimeEvents } from '../../RuntimeEvents'; +import { Isolate, VestRuntime } from '../../vestjs-runtime'; +import { TIsolate } from '../Isolate'; describe('AsyncIsolate', () => { test('It should resolve async isolate into the parent', () => { @@ -32,15 +32,15 @@ describe('AsyncIsolate', () => { expect(root?.children?.[0].parent).toBe(root); expect(root?.children?.[0]?.children?.[0]?.$type).toBe('UGrandChild_1'); expect(root?.children?.[0]?.children?.[0].parent).toBe( - root?.children?.[0] + root?.children?.[0], ); expect(root?.children?.[0]?.children?.[1]?.$type).toBe('UGrandChild_2'); expect(root?.children?.[0]?.children?.[1].parent).toBe( - root?.children?.[0] + root?.children?.[0], ); expect(root?.children?.[0]?.children?.[2]?.$type).toBe('UGrandChild_3'); expect(root?.children?.[0]?.children?.[2].parent).toBe( - root?.children?.[0] + root?.children?.[0], ); expect(root).toMatchSnapshot(); @@ -88,6 +88,6 @@ async function genChildren() { Isolate.create('UGrandChild_1', () => {}); Isolate.create('UGrandChild_2', () => {}); Isolate.create('UGrandChild_3', () => {}); - }) + }), ); } diff --git a/packages/vestjs-runtime/src/IsolateWalker.ts b/packages/vestjs-runtime/src/IsolateWalker.ts index 907fd3440..87b59ef29 100644 --- a/packages/vestjs-runtime/src/IsolateWalker.ts +++ b/packages/vestjs-runtime/src/IsolateWalker.ts @@ -1,7 +1,7 @@ import { CB, Nullable, isNullish, optionalFunctionValue } from 'vest-utils'; -import { type TIsolate } from 'Isolate'; -import { IsolateMutator } from 'IsolateMutator'; +import { type TIsolate } from '@/Isolate/Isolate'; +import { IsolateMutator } from '@/Isolate/IsolateMutator'; type VisitOnlyPredicate = (isolate: TIsolate) => boolean; diff --git a/packages/vestjs-runtime/src/Reconciler.ts b/packages/vestjs-runtime/src/Reconciler.ts index 79d91298e..1b248ea17 100644 --- a/packages/vestjs-runtime/src/Reconciler.ts +++ b/packages/vestjs-runtime/src/Reconciler.ts @@ -1,4 +1,3 @@ -import { ErrorStrings } from 'ErrorStrings'; import { Maybe, Nullable, @@ -7,12 +6,15 @@ import { optionalFunctionValue, } from 'vest-utils'; -import { type TIsolate } from 'Isolate'; -import { IsolateInspector } from 'IsolateInspector'; -import { IsolateMutator } from 'IsolateMutator'; -import { isSameIsolateType } from 'IsolateSelectors'; -import * as VestRuntime from 'VestRuntime'; -// import { isSameIsolateType } from 'IsolateSelectors'; +import { ErrorStrings } from './errors/ErrorStrings'; +import { + IsolateInspector, + IsolateMutator, + VestRuntime, +} from './vestjs-runtime'; + +import { type TIsolate } from '@/Isolate/Isolate'; +import { isSameIsolateType } from '@/Isolate/IsolateSelectors'; // I would rather not use `any` here, but instead use `Isolate`. // The problem is that it breaks the actual implementation of `Isolate` in `IsolateTest` diff --git a/packages/vestjs-runtime/src/VestRuntime.ts b/packages/vestjs-runtime/src/VestRuntime.ts index 7c4506268..b8ea0d36d 100644 --- a/packages/vestjs-runtime/src/VestRuntime.ts +++ b/packages/vestjs-runtime/src/VestRuntime.ts @@ -1,4 +1,3 @@ -import { ErrorStrings } from 'ErrorStrings'; import { createCascade } from 'context'; import { invariant, @@ -15,10 +14,12 @@ import { DynamicValue, } from 'vest-utils'; -import { TIsolate } from 'Isolate'; -import { IsolateInspector } from 'IsolateInspector'; -import { IsolateMutator } from 'IsolateMutator'; -import { IRecociler } from 'Reconciler'; +import { ErrorStrings } from './errors/ErrorStrings'; + +import { TIsolate } from '@/Isolate/Isolate'; +import { IsolateInspector } from '@/Isolate/IsolateInspector'; +import { IsolateMutator } from '@/Isolate/IsolateMutator'; +import { IRecociler } from '@/Reconciler'; type CTXType = StateRefType & { historyNode: Nullable; @@ -76,7 +77,7 @@ export function useXAppData() { export function createRef( Reconciler: IRecociler, - setter: DynamicValue> + setter: DynamicValue>, ): StateRefType { return Object.freeze({ Bus: bus.createBus(), diff --git a/packages/vestjs-runtime/src/__tests__/IsolateWalker.test.ts b/packages/vestjs-runtime/src/__tests__/IsolateWalker.test.ts index e86cb3a30..cf7b83b6b 100644 --- a/packages/vestjs-runtime/src/__tests__/IsolateWalker.test.ts +++ b/packages/vestjs-runtime/src/__tests__/IsolateWalker.test.ts @@ -1,5 +1,5 @@ -import { TIsolate } from 'Isolate'; -import { walk, reduce, findAll } from 'IsolateWalker'; +import { TIsolate } from '@/Isolate/Isolate'; +import { walk, reduce, findAll } from '@/IsolateWalker'; type WalkedNode = TIsolate<{ id: string }>; diff --git a/packages/vestjs-runtime/src/exports/IsolateSerializer.ts b/packages/vestjs-runtime/src/exports/IsolateSerializer.ts index 9b57e4a60..0d7e1c0af 100644 --- a/packages/vestjs-runtime/src/exports/IsolateSerializer.ts +++ b/packages/vestjs-runtime/src/exports/IsolateSerializer.ts @@ -1,4 +1,3 @@ -import { ErrorStrings } from 'ErrorStrings'; import { Nullable, hasOwnProperty, @@ -7,11 +6,15 @@ import { isStringValue, text, } from 'vest-utils'; -import { expandObject, minifyObject } from 'vest-utils/minifyObject'; - -import { TIsolate } from 'Isolate'; -import { ExcludedFromDump, IsolateKeys } from 'IsolateKeys'; -import { IsolateMutator } from 'IsolateMutator'; +import { + expandObject, + minifyObject, +} from 'vest-utils/src/exports/minifyObject'; + +import { TIsolate } from '../../types/vestjs-runtime'; +import { ExcludedFromDump, IsolateKeys } from '../Isolate/IsolateKeys'; +import { ErrorStrings } from '../errors/ErrorStrings'; +import { IsolateMutator } from '../vestjs-runtime'; export class IsolateSerializer { // eslint-disable-next-line max-statements, complexity, max-lines-per-function diff --git a/packages/vestjs-runtime/src/exports/__tests__/IsolateSerializer.test.ts b/packages/vestjs-runtime/src/exports/__tests__/IsolateSerializer.test.ts index df9d528aa..a571110be 100644 --- a/packages/vestjs-runtime/src/exports/__tests__/IsolateSerializer.test.ts +++ b/packages/vestjs-runtime/src/exports/__tests__/IsolateSerializer.test.ts @@ -1,9 +1,11 @@ -import { Maybe } from 'vest-utils'; +import { CB, Maybe } from 'vest-utils'; -import { Isolate, TIsolate } from 'Isolate'; -import { MinifiedKeys } from 'IsolateKeys'; -import { IsolateSerializer } from 'IsolateSerializer'; -import { IsolateMutator, VestRuntime } from 'vestjs-runtime'; +import { + Isolate, + IsolateSerializer, + TIsolate, + VestRuntime, +} from 'vestjs-runtime'; describe('IsolateSerializer', () => { describe('serialize', () => { @@ -16,7 +18,7 @@ describe('IsolateSerializer', () => { describe('deserialize', () => { it('Should fully inflate the tree', () => { - const { root, serialized } = createRoot(); + const { serialized } = createRoot(); const inflated = IsolateSerializer.deserialize(serialized); @@ -67,7 +69,6 @@ describe('IsolateSerializer', () => { }, }); - const parsed = JSON.parse(serialized); expect(serialized).toMatchSnapshot(); }); @@ -97,8 +98,8 @@ describe('IsolateSerializer', () => { }, }; - const serialized = IsolateSerializer.serialize(root, minimap); - const inflated = IsolateSerializer.deserialize(serialized, minimap); + const serialized = IsolateSerializer.serialize(root); + const inflated = IsolateSerializer.deserialize(serialized); expect(inflated.status).toBe('pending'); // @ts-ignore @@ -193,7 +194,7 @@ function withRunTime(fn: CB) { }); } -function createRoot(miniMap: Maybe>) { +function createRoot(miniMap?: Maybe>) { let serialized: string, root: TIsolate; withRunTime(() => { @@ -209,7 +210,7 @@ function createRoot(miniMap: Maybe>) { }, ); - serialized = IsolateSerializer.serialize(root, miniMap); + serialized = IsolateSerializer.serialize(root); }); // @ts-ignore diff --git a/packages/vestjs-runtime/src/exports/test-utils.ts b/packages/vestjs-runtime/src/exports/test-utils.ts index f2a63c7e9..cfc2010a7 100644 --- a/packages/vestjs-runtime/src/exports/test-utils.ts +++ b/packages/vestjs-runtime/src/exports/test-utils.ts @@ -1,5 +1,5 @@ -import { TIsolate } from 'Isolate'; -import { IsolateKeys } from 'IsolateKeys'; +import { TIsolate } from '../Isolate/Isolate'; +import { IsolateKeys } from '../Isolate/IsolateKeys'; export function genTestIsolate(payload: Record = {}): TIsolate { const { status, ...data } = payload; diff --git a/packages/vestjs-runtime/src/vestjs-runtime.ts b/packages/vestjs-runtime/src/vestjs-runtime.ts index 8a662a69d..992282acf 100644 --- a/packages/vestjs-runtime/src/vestjs-runtime.ts +++ b/packages/vestjs-runtime/src/vestjs-runtime.ts @@ -1,10 +1,10 @@ -export { RuntimeEvents } from 'RuntimeEvents'; -export { IsolateKey, TIsolate, Isolate } from 'Isolate'; -export { Reconciler, IRecociler } from 'Reconciler'; -export * as Walker from 'IsolateWalker'; -export { RuntimeApi as VestRuntime } from 'VestRuntime'; -export { IsolateInspector } from 'IsolateInspector'; -export { IsolateMutator } from 'IsolateMutator'; -export * as Bus from 'Bus'; -export * as IsolateSelectors from 'IsolateSelectors'; -export { IsolateSerializer } from 'IsolateSerializer'; +export { RuntimeEvents } from '@/RuntimeEvents'; +export { IsolateKey, TIsolate, Isolate } from '@/Isolate/Isolate'; +export { Reconciler, IRecociler } from '@/Reconciler'; +export * as Walker from '@/IsolateWalker'; +export { RuntimeApi as VestRuntime } from '@/VestRuntime'; +export { IsolateInspector } from '@/Isolate/IsolateInspector'; +export { IsolateMutator } from '@/Isolate/IsolateMutator'; +export * as Bus from '@/Bus'; +export * as IsolateSelectors from '@/Isolate/IsolateSelectors'; +export { IsolateSerializer } from '@exports/IsolateSerializer'; diff --git a/packages/vestjs-runtime/tsconfig.json b/packages/vestjs-runtime/tsconfig.json index b38a1d675..fca81718b 100644 --- a/packages/vestjs-runtime/tsconfig.json +++ b/packages/vestjs-runtime/tsconfig.json @@ -7,20 +7,8 @@ "declarationMap": true, "outDir": "./dist", "paths": { - "vestjs-runtime": ["./src/vestjs-runtime.ts"], - "VestRuntime": ["./src/VestRuntime.ts"], - "RuntimeEvents": ["./src/RuntimeEvents.ts"], - "Reconciler": ["./src/Reconciler.ts"], - "IsolateWalker": ["./src/IsolateWalker.ts"], - "Bus": ["./src/Bus.ts"], - "test-utils": ["./src/exports/test-utils.ts"], - "IsolateSerializer": ["./src/exports/IsolateSerializer.ts"], - "ErrorStrings": ["./src/errors/ErrorStrings.ts"], - "IsolateSelectors": ["./src/Isolate/IsolateSelectors.ts"], - "IsolateMutator": ["./src/Isolate/IsolateMutator.ts"], - "IsolateKeys": ["./src/Isolate/IsolateKeys.ts"], - "IsolateInspector": ["./src/Isolate/IsolateInspector.ts"], - "Isolate": ["./src/Isolate/Isolate.ts"] + "@exports/*": ["src/exports/*"], + "@/*": ["src/*"] } } } diff --git a/tsconfig.json b/tsconfig.json index f63991d99..77e202ad9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,6 @@ { "compilerOptions": { "allowJs": false, - "baseUrl": ".", "declaration": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 000000000..e586ae0a2 --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,21 @@ +import tsconfigPaths from 'vite-tsconfig-paths'; +import { defineConfig } from 'vitest/config'; + +export default defineConfig({ + test: { + globals: true, + }, + plugins: [ + tsconfigPaths({ + projects: [ + 'packages/vest', + 'packages/n4s', + 'packages/vest-utils', + 'packages/vestjs-runtime', + 'packages/context', + 'packages/vast', + 'packages/anyone', + ], + }), + ], +}); diff --git a/vx/config/jest/jest.config.js b/vx/config/jest/jest.config.js index e5eba8c46..455e91d5d 100644 --- a/vx/config/jest/jest.config.js +++ b/vx/config/jest/jest.config.js @@ -13,16 +13,16 @@ const setupPerPackage = glob.sync( vxPath.packageConfigPath( usePackage() ?? '*', opts.dir.JEST, - opts.fileNames.JEST_SETUP - ) + opts.fileNames.JEST_SETUP, + ), ); const setupAfterEnvPerPackage = glob.sync( vxPath.packageConfigPath( usePackage() ?? '*', opts.dir.JEST, - opts.fileNames.JEST_SETUP_AFTER_ENV - ) + opts.fileNames.JEST_SETUP_AFTER_ENV, + ), ); const projects = packageNames.list.map(packageName => ({ @@ -35,6 +35,8 @@ const projects = packageNames.list.map(packageName => ({ ], })); +console.log(projects); + module.exports = { projects, }; @@ -52,7 +54,7 @@ function baseConfig(packageName) { setupFilesAfterEnv: [ path.resolve( vxPath.JEST_CONFIG_PATH, - opts.fileNames.JEST_SETUP_AFTER_ENV + opts.fileNames.JEST_SETUP_AFTER_ENV, ), ].concat(setupAfterEnvPerPackage), testEnvironment: 'node', @@ -84,6 +86,6 @@ function genNameMapper(modules) { Object.assign(aliases, { [`^${name}$`]: absolute, }), - {} + {}, ); } diff --git a/vx/config/rollup/rollup.config.cjs b/vx/config/rollup/rollup.config.cjs index ae39a3ac0..8517b6b1a 100644 --- a/vx/config/rollup/rollup.config.cjs +++ b/vx/config/rollup/rollup.config.cjs @@ -16,7 +16,7 @@ const { usePackage } = require('vx/vxContext'); const vxPath = require('vx/vxPath'); const fastBuild = JSON.parse( - process.env.ROLLUP_WATCH ?? process.env.VX_FAST_BUILD ?? false + process.env.ROLLUP_WATCH ?? process.env.VX_FAST_BUILD ?? false, ); module.exports = commandLineArgs => { @@ -42,10 +42,10 @@ module.exports = commandLineArgs => { `Invalid build entry: ${buildEntry}. Must be one of: ${[ opts.vx_config.VX_ROLLUP_BUILD_ENTRY_MAIN, opts.vx_config.VX_ROLLUP_BUILD_ENTRY_EXPORTS, - ].join(', ')}` + ].join(', ')}`, ); } - }) + }), ); }; @@ -72,14 +72,14 @@ function genBaseConfig({ // This turns the installed "internal" dependencies into external dependencies external: [ ...Object.keys( - disallowExternals ? {} : packageJson()?.dependencies ?? {} + disallowExternals ? {} : packageJson()?.dependencies ?? {}, ), moduleName === usePackage() ? null : usePackage(), ].filter(Boolean), input: getInputFile(packageName, moduleName, namespace), output: format.map(format => - genOutput({ env, format, moduleName, namespace }) + genOutput({ env, format, moduleName, namespace }), ), plugins: getPlugins({ env, moduleName, namespace, packageName }), }; @@ -89,7 +89,7 @@ function genBaseConfig({ function genExportsConfig(pkgName, env) { return listExportedModules(pkgName).map(([moduleName, namespace]) => - genBaseConfig({ env, moduleName, namespace }) + genBaseConfig({ env, moduleName, namespace }), ); } @@ -107,7 +107,7 @@ function genOutput({ // creates "globals" from the installed internal packages const globals = Object.keys( - disallowExternals ? {} : packageJson()?.dependencies ?? {} + disallowExternals ? {} : packageJson()?.dependencies ?? {}, ).reduce((g, c) => Object.assign(g, { [c]: c }), { ...{ [usePackage()]: usePackage() }, }); @@ -118,7 +118,7 @@ function genOutput({ usePackage(), format, namespace, - joinTruthy([moduleName, env, 'js'], '.') + joinTruthy([moduleName, env, 'js'], '.'), ), format, globals, @@ -128,7 +128,7 @@ function genOutput({ function getInputFile( packageName = usePackage(), moduleName = usePackage(), - namespace + namespace, ) { const moduleToResolve = getExportedModuleNames(namespace, moduleName); const packageModules = pathsPerPackage.packages[packageName]; diff --git a/vx/scripts/genTsConfig.js b/vx/scripts/genTsConfig.js index fa312219c..72db4cb0b 100644 --- a/vx/scripts/genTsConfig.js +++ b/vx/scripts/genTsConfig.js @@ -27,7 +27,7 @@ module.exports = function genTsConfig() { if (isConfigEqual(tsConfigPath, tsConfig)) { logger.log( - `✅ tsConfig for package '${packageName}' is up to date. Skipping.` + `✅ tsConfig for package '${packageName}' is up to date. Skipping.`, ); return; } @@ -66,7 +66,10 @@ function packageTsConfigTemplate(paths = []) { declarationDir: './types', declarationMap: true, outDir: './dist', - paths, + paths: { + '@exports/*': ['src/exports/*'], + '@/*': ['src/*'], + }, }, }; } @@ -75,7 +78,7 @@ function rootTsConfigTemplate() { return { compilerOptions: { allowJs: false, - baseUrl: '.', + // baseUrl: '.', declaration: true, esModuleInterop: true, forceConsistentCasingInFileNames: true, diff --git a/yarn.lock b/yarn.lock index fa14c56cf..a49c205c1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -204,6 +204,16 @@ __metadata: languageName: node linkType: hard +"@ampproject/remapping@npm:^2.3.0": + version: 2.3.0 + resolution: "@ampproject/remapping@npm:2.3.0" + dependencies: + "@jridgewell/gen-mapping": ^0.3.5 + "@jridgewell/trace-mapping": ^0.3.24 + checksum: d3ad7b89d973df059c4e8e6d7c972cbeb1bb2f18f002a3bd04ae0707da214cb06cc06929b65aa2313b9347463df2914772298bae8b1d7973f246bb3f2ab3e8f0 + languageName: node + linkType: hard + "@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.10.4, @babel/code-frame@npm:^7.12.13, @babel/code-frame@npm:^7.16.0, @babel/code-frame@npm:^7.18.6, @babel/code-frame@npm:^7.21.4, @babel/code-frame@npm:^7.8.3": version: 7.21.4 resolution: "@babel/code-frame@npm:7.21.4" @@ -4497,6 +4507,167 @@ __metadata: languageName: node linkType: hard +"@esbuild/aix-ppc64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/aix-ppc64@npm:0.21.5" + conditions: os=aix & cpu=ppc64 + languageName: node + linkType: hard + +"@esbuild/android-arm64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/android-arm64@npm:0.21.5" + conditions: os=android & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/android-arm@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/android-arm@npm:0.21.5" + conditions: os=android & cpu=arm + languageName: node + linkType: hard + +"@esbuild/android-x64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/android-x64@npm:0.21.5" + conditions: os=android & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/darwin-arm64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/darwin-arm64@npm:0.21.5" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/darwin-x64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/darwin-x64@npm:0.21.5" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/freebsd-arm64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/freebsd-arm64@npm:0.21.5" + conditions: os=freebsd & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/freebsd-x64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/freebsd-x64@npm:0.21.5" + conditions: os=freebsd & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/linux-arm64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/linux-arm64@npm:0.21.5" + conditions: os=linux & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/linux-arm@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/linux-arm@npm:0.21.5" + conditions: os=linux & cpu=arm + languageName: node + linkType: hard + +"@esbuild/linux-ia32@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/linux-ia32@npm:0.21.5" + conditions: os=linux & cpu=ia32 + languageName: node + linkType: hard + +"@esbuild/linux-loong64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/linux-loong64@npm:0.21.5" + conditions: os=linux & cpu=loong64 + languageName: node + linkType: hard + +"@esbuild/linux-mips64el@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/linux-mips64el@npm:0.21.5" + conditions: os=linux & cpu=mips64el + languageName: node + linkType: hard + +"@esbuild/linux-ppc64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/linux-ppc64@npm:0.21.5" + conditions: os=linux & cpu=ppc64 + languageName: node + linkType: hard + +"@esbuild/linux-riscv64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/linux-riscv64@npm:0.21.5" + conditions: os=linux & cpu=riscv64 + languageName: node + linkType: hard + +"@esbuild/linux-s390x@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/linux-s390x@npm:0.21.5" + conditions: os=linux & cpu=s390x + languageName: node + linkType: hard + +"@esbuild/linux-x64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/linux-x64@npm:0.21.5" + conditions: os=linux & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/netbsd-x64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/netbsd-x64@npm:0.21.5" + conditions: os=netbsd & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/openbsd-x64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/openbsd-x64@npm:0.21.5" + conditions: os=openbsd & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/sunos-x64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/sunos-x64@npm:0.21.5" + conditions: os=sunos & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/win32-arm64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/win32-arm64@npm:0.21.5" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/win32-ia32@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/win32-ia32@npm:0.21.5" + conditions: os=win32 & cpu=ia32 + languageName: node + linkType: hard + +"@esbuild/win32-x64@npm:0.21.5": + version: 0.21.5 + resolution: "@esbuild/win32-x64@npm:0.21.5" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + "@eslint-community/eslint-utils@npm:^4.2.0, @eslint-community/eslint-utils@npm:^4.4.0": version: 4.4.0 resolution: "@eslint-community/eslint-utils@npm:4.4.0" @@ -4908,6 +5079,17 @@ __metadata: languageName: node linkType: hard +"@jridgewell/gen-mapping@npm:^0.3.5": + version: 0.3.5 + resolution: "@jridgewell/gen-mapping@npm:0.3.5" + dependencies: + "@jridgewell/set-array": ^1.2.1 + "@jridgewell/sourcemap-codec": ^1.4.10 + "@jridgewell/trace-mapping": ^0.3.24 + checksum: ff7a1764ebd76a5e129c8890aa3e2f46045109dabde62b0b6c6a250152227647178ff2069ea234753a690d8f3c4ac8b5e7b267bbee272bffb7f3b0a370ab6e52 + languageName: node + linkType: hard + "@jridgewell/resolve-uri@npm:3.1.0": version: 3.1.0 resolution: "@jridgewell/resolve-uri@npm:3.1.0" @@ -4929,6 +5111,13 @@ __metadata: languageName: node linkType: hard +"@jridgewell/set-array@npm:^1.2.1": + version: 1.2.1 + resolution: "@jridgewell/set-array@npm:1.2.1" + checksum: 832e513a85a588f8ed4f27d1279420d8547743cc37fcad5a5a76fc74bb895b013dfe614d0eed9cb860048e6546b798f8f2652020b4b2ba0561b05caa8c654b10 + languageName: node + linkType: hard + "@jridgewell/source-map@npm:^0.3.2": version: 0.3.3 resolution: "@jridgewell/source-map@npm:0.3.3" @@ -4983,6 +5172,16 @@ __metadata: languageName: node linkType: hard +"@jridgewell/trace-mapping@npm:^0.3.24": + version: 0.3.25 + resolution: "@jridgewell/trace-mapping@npm:0.3.25" + dependencies: + "@jridgewell/resolve-uri": ^3.1.0 + "@jridgewell/sourcemap-codec": ^1.4.14 + checksum: 9d3c40d225e139987b50c48988f8717a54a8c994d8a948ee42e1412e08988761d0754d7d10b803061cc3aebf35f92a5dbbab493bd0e1a9ef9e89a2130e83ba34 + languageName: node + linkType: hard + "@leichtgewicht/ip-codec@npm:^2.0.1": version: 2.0.4 resolution: "@leichtgewicht/ip-codec@npm:2.0.4" @@ -5345,6 +5544,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-android-arm-eabi@npm:4.19.0": + version: 4.19.0 + resolution: "@rollup/rollup-android-arm-eabi@npm:4.19.0" + conditions: os=android & cpu=arm + languageName: node + linkType: hard + "@rollup/rollup-android-arm64@npm:4.18.0": version: 4.18.0 resolution: "@rollup/rollup-android-arm64@npm:4.18.0" @@ -5352,6 +5558,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-android-arm64@npm:4.19.0": + version: 4.19.0 + resolution: "@rollup/rollup-android-arm64@npm:4.19.0" + conditions: os=android & cpu=arm64 + languageName: node + linkType: hard + "@rollup/rollup-darwin-arm64@npm:4.18.0": version: 4.18.0 resolution: "@rollup/rollup-darwin-arm64@npm:4.18.0" @@ -5359,6 +5572,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-darwin-arm64@npm:4.19.0": + version: 4.19.0 + resolution: "@rollup/rollup-darwin-arm64@npm:4.19.0" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + "@rollup/rollup-darwin-x64@npm:4.18.0": version: 4.18.0 resolution: "@rollup/rollup-darwin-x64@npm:4.18.0" @@ -5366,6 +5586,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-darwin-x64@npm:4.19.0": + version: 4.19.0 + resolution: "@rollup/rollup-darwin-x64@npm:4.19.0" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + "@rollup/rollup-linux-arm-gnueabihf@npm:4.18.0": version: 4.18.0 resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.18.0" @@ -5373,6 +5600,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-arm-gnueabihf@npm:4.19.0": + version: 4.19.0 + resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.19.0" + conditions: os=linux & cpu=arm & libc=glibc + languageName: node + linkType: hard + "@rollup/rollup-linux-arm-musleabihf@npm:4.18.0": version: 4.18.0 resolution: "@rollup/rollup-linux-arm-musleabihf@npm:4.18.0" @@ -5380,6 +5614,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-arm-musleabihf@npm:4.19.0": + version: 4.19.0 + resolution: "@rollup/rollup-linux-arm-musleabihf@npm:4.19.0" + conditions: os=linux & cpu=arm & libc=musl + languageName: node + linkType: hard + "@rollup/rollup-linux-arm64-gnu@npm:4.18.0": version: 4.18.0 resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.18.0" @@ -5387,6 +5628,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-arm64-gnu@npm:4.19.0": + version: 4.19.0 + resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.19.0" + conditions: os=linux & cpu=arm64 & libc=glibc + languageName: node + linkType: hard + "@rollup/rollup-linux-arm64-musl@npm:4.18.0": version: 4.18.0 resolution: "@rollup/rollup-linux-arm64-musl@npm:4.18.0" @@ -5394,6 +5642,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-arm64-musl@npm:4.19.0": + version: 4.19.0 + resolution: "@rollup/rollup-linux-arm64-musl@npm:4.19.0" + conditions: os=linux & cpu=arm64 & libc=musl + languageName: node + linkType: hard + "@rollup/rollup-linux-powerpc64le-gnu@npm:4.18.0": version: 4.18.0 resolution: "@rollup/rollup-linux-powerpc64le-gnu@npm:4.18.0" @@ -5401,6 +5656,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-powerpc64le-gnu@npm:4.19.0": + version: 4.19.0 + resolution: "@rollup/rollup-linux-powerpc64le-gnu@npm:4.19.0" + conditions: os=linux & cpu=ppc64 & libc=glibc + languageName: node + linkType: hard + "@rollup/rollup-linux-riscv64-gnu@npm:4.18.0": version: 4.18.0 resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.18.0" @@ -5408,6 +5670,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-riscv64-gnu@npm:4.19.0": + version: 4.19.0 + resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.19.0" + conditions: os=linux & cpu=riscv64 & libc=glibc + languageName: node + linkType: hard + "@rollup/rollup-linux-s390x-gnu@npm:4.18.0": version: 4.18.0 resolution: "@rollup/rollup-linux-s390x-gnu@npm:4.18.0" @@ -5415,6 +5684,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-s390x-gnu@npm:4.19.0": + version: 4.19.0 + resolution: "@rollup/rollup-linux-s390x-gnu@npm:4.19.0" + conditions: os=linux & cpu=s390x & libc=glibc + languageName: node + linkType: hard + "@rollup/rollup-linux-x64-gnu@npm:4.18.0": version: 4.18.0 resolution: "@rollup/rollup-linux-x64-gnu@npm:4.18.0" @@ -5422,6 +5698,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-x64-gnu@npm:4.19.0": + version: 4.19.0 + resolution: "@rollup/rollup-linux-x64-gnu@npm:4.19.0" + conditions: os=linux & cpu=x64 & libc=glibc + languageName: node + linkType: hard + "@rollup/rollup-linux-x64-musl@npm:4.18.0": version: 4.18.0 resolution: "@rollup/rollup-linux-x64-musl@npm:4.18.0" @@ -5429,6 +5712,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-x64-musl@npm:4.19.0": + version: 4.19.0 + resolution: "@rollup/rollup-linux-x64-musl@npm:4.19.0" + conditions: os=linux & cpu=x64 & libc=musl + languageName: node + linkType: hard + "@rollup/rollup-win32-arm64-msvc@npm:4.18.0": version: 4.18.0 resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.18.0" @@ -5436,6 +5726,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-win32-arm64-msvc@npm:4.19.0": + version: 4.19.0 + resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.19.0" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + "@rollup/rollup-win32-ia32-msvc@npm:4.18.0": version: 4.18.0 resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.18.0" @@ -5443,6 +5740,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-win32-ia32-msvc@npm:4.19.0": + version: 4.19.0 + resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.19.0" + conditions: os=win32 & cpu=ia32 + languageName: node + linkType: hard + "@rollup/rollup-win32-x64-msvc@npm:4.18.0": version: 4.18.0 resolution: "@rollup/rollup-win32-x64-msvc@npm:4.18.0" @@ -5450,6 +5754,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-win32-x64-msvc@npm:4.19.0": + version: 4.19.0 + resolution: "@rollup/rollup-win32-x64-msvc@npm:4.19.0" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + "@sideway/address@npm:^4.1.3": version: 4.1.4 resolution: "@sideway/address@npm:4.1.4" @@ -6150,10 +6461,10 @@ __metadata: languageName: node linkType: hard -"@types/lodash@npm:^4.17.5": - version: 4.17.5 - resolution: "@types/lodash@npm:4.17.5" - checksum: 3c9bb15772509f0ecb40428531863dbc3f064f2bf34bbccc2ce2b2923c69fb0868aec7e357b1d97fd0d7f7e435a014ea5c1adef8a64715529887179c97a5a823 +"@types/lodash@npm:^4.17.7": + version: 4.17.7 + resolution: "@types/lodash@npm:4.17.7" + checksum: 09e58a119cd8a70acfb33f8623dc2fc54f74cdce3b3429b879fc2daac4807fe376190a04b9e024dd300f9a3ee1876d6623979cefe619f70654ca0fe0c47679a7 languageName: node linkType: hard @@ -6622,6 +6933,69 @@ __metadata: languageName: node linkType: hard +"@vitest/expect@npm:2.0.4": + version: 2.0.4 + resolution: "@vitest/expect@npm:2.0.4" + dependencies: + "@vitest/spy": 2.0.4 + "@vitest/utils": 2.0.4 + chai: ^5.1.1 + tinyrainbow: ^1.2.0 + checksum: 6841da3ffa58572c24b3720c84bade5b7293d60905b17b3e2ea28fcecb7c18592851fe84538bfc9995ab3b7681cd3e0fc6913512390ae1564d3fb1de8d9edad8 + languageName: node + linkType: hard + +"@vitest/pretty-format@npm:2.0.4, @vitest/pretty-format@npm:^2.0.4": + version: 2.0.4 + resolution: "@vitest/pretty-format@npm:2.0.4" + dependencies: + tinyrainbow: ^1.2.0 + checksum: a0dbfea5a1379aa1b69ee208116bd88e39edccb7e2f71be56f85868495217b2d8c0284ecba81a6f66f8e78a6d50b9f2c2fc3f3bc2114e909b7b43b96fdee7042 + languageName: node + linkType: hard + +"@vitest/runner@npm:2.0.4": + version: 2.0.4 + resolution: "@vitest/runner@npm:2.0.4" + dependencies: + "@vitest/utils": 2.0.4 + pathe: ^1.1.2 + checksum: 313030973a80766de9bed1ed6f4342c5320d9b9dfcf97bc8d61899a41a916e8f5d2aa2ab727023372ad057ca5f95daae3820535f1124e0651814ce7045883414 + languageName: node + linkType: hard + +"@vitest/snapshot@npm:2.0.4": + version: 2.0.4 + resolution: "@vitest/snapshot@npm:2.0.4" + dependencies: + "@vitest/pretty-format": 2.0.4 + magic-string: ^0.30.10 + pathe: ^1.1.2 + checksum: af9bd9da387dca25c13d6b8323d9e574ce3be19b7965ef26c427394e07ca7c7d291d3d52e65c90cf2bcafbfe673a70d362c526597150fe4407d5c13f9cf47412 + languageName: node + linkType: hard + +"@vitest/spy@npm:2.0.4": + version: 2.0.4 + resolution: "@vitest/spy@npm:2.0.4" + dependencies: + tinyspy: ^3.0.0 + checksum: 097cef445965e4145993f0436007116f5c56da6e02d51f9c7f18c56fb9ae05c045c627b75a34609b4f39901f2f8e9acf54dae94b490db3c4b1656c0e4fbf5847 + languageName: node + linkType: hard + +"@vitest/utils@npm:2.0.4": + version: 2.0.4 + resolution: "@vitest/utils@npm:2.0.4" + dependencies: + "@vitest/pretty-format": 2.0.4 + estree-walker: ^3.0.3 + loupe: ^3.1.1 + tinyrainbow: ^1.2.0 + checksum: 1f6ce4d80403750e1ed3669de746327cd6626c3a80ba9e30613653521e4c9126d7db5b4ea764a644eb7e933f9fef218816515181deb746c5ed6988c5ea9dde0d + languageName: node + linkType: hard + "@webassemblyjs/ast@npm:1.11.5, @webassemblyjs/ast@npm:^1.11.5": version: 1.11.5 resolution: "@webassemblyjs/ast@npm:1.11.5" @@ -7232,6 +7606,13 @@ __metadata: languageName: node linkType: hard +"assertion-error@npm:^2.0.1": + version: 2.0.1 + resolution: "assertion-error@npm:2.0.1" + checksum: a0789dd882211b87116e81e2648ccb7f60340b34f19877dd020b39ebb4714e475eb943e14ba3e22201c221ef6645b7bfe10297e76b6ac95b48a9898c1211ce66 + languageName: node + linkType: hard + "astring@npm:^1.8.0": version: 1.8.6 resolution: "astring@npm:1.8.6" @@ -7797,6 +8178,13 @@ __metadata: languageName: node linkType: hard +"cac@npm:^6.7.14": + version: 6.7.14 + resolution: "cac@npm:6.7.14" + checksum: 45a2496a9443abbe7f52a49b22fbe51b1905eff46e03fd5e6c98e3f85077be3f8949685a1849b1a9cd2bc3e5567dfebcf64f01ce01847baf918f1b37c839791a + languageName: node + linkType: hard + "cacache@npm:^16.1.0": version: 16.1.3 resolution: "cacache@npm:16.1.3" @@ -7940,6 +8328,19 @@ __metadata: languageName: node linkType: hard +"chai@npm:^5.1.1": + version: 5.1.1 + resolution: "chai@npm:5.1.1" + dependencies: + assertion-error: ^2.0.1 + check-error: ^2.1.1 + deep-eql: ^5.0.1 + loupe: ^3.1.0 + pathval: ^2.0.0 + checksum: 1e0a5e1b5febdfa8ceb97b9aff608286861ecb86533863119b2f39f07c08fb59f3c1791ab554947f009b9d71d509b9e4e734fb12133cb81f231c2c2ee7c1e738 + languageName: node + linkType: hard + "chalk@npm:^2.0.0, chalk@npm:^2.4.2": version: 2.4.2 resolution: "chalk@npm:2.4.2" @@ -8010,6 +8411,13 @@ __metadata: languageName: node linkType: hard +"check-error@npm:^2.1.1": + version: 2.1.1 + resolution: "check-error@npm:2.1.1" + checksum: d785ed17b1d4a4796b6e75c765a9a290098cf52ff9728ce0756e8ffd4293d2e419dd30c67200aee34202463b474306913f2fcfaf1890641026d9fc6966fea27a + languageName: node + linkType: hard + "cheerio-select@npm:^2.1.0": version: 2.1.0 resolution: "cheerio-select@npm:2.1.0" @@ -9054,7 +9462,7 @@ __metadata: languageName: node linkType: hard -"debug@npm:^4.3.1": +"debug@npm:^4.3.1, debug@npm:^4.3.5": version: 4.3.5 resolution: "debug@npm:4.3.5" dependencies: @@ -9096,6 +9504,13 @@ __metadata: languageName: node linkType: hard +"deep-eql@npm:^5.0.1": + version: 5.0.2 + resolution: "deep-eql@npm:5.0.2" + checksum: 6aaaadb4c19cbce42e26b2bbe5bd92875f599d2602635dc97f0294bae48da79e89470aedee05f449e0ca8c65e9fd7e7872624d1933a1db02713d99c2ca8d1f24 + languageName: node + linkType: hard + "deep-extend@npm:^0.6.0": version: 0.6.0 resolution: "deep-extend@npm:0.6.0" @@ -9719,6 +10134,86 @@ __metadata: languageName: node linkType: hard +"esbuild@npm:^0.21.3": + version: 0.21.5 + resolution: "esbuild@npm:0.21.5" + dependencies: + "@esbuild/aix-ppc64": 0.21.5 + "@esbuild/android-arm": 0.21.5 + "@esbuild/android-arm64": 0.21.5 + "@esbuild/android-x64": 0.21.5 + "@esbuild/darwin-arm64": 0.21.5 + "@esbuild/darwin-x64": 0.21.5 + "@esbuild/freebsd-arm64": 0.21.5 + "@esbuild/freebsd-x64": 0.21.5 + "@esbuild/linux-arm": 0.21.5 + "@esbuild/linux-arm64": 0.21.5 + "@esbuild/linux-ia32": 0.21.5 + "@esbuild/linux-loong64": 0.21.5 + "@esbuild/linux-mips64el": 0.21.5 + "@esbuild/linux-ppc64": 0.21.5 + "@esbuild/linux-riscv64": 0.21.5 + "@esbuild/linux-s390x": 0.21.5 + "@esbuild/linux-x64": 0.21.5 + "@esbuild/netbsd-x64": 0.21.5 + "@esbuild/openbsd-x64": 0.21.5 + "@esbuild/sunos-x64": 0.21.5 + "@esbuild/win32-arm64": 0.21.5 + "@esbuild/win32-ia32": 0.21.5 + "@esbuild/win32-x64": 0.21.5 + dependenciesMeta: + "@esbuild/aix-ppc64": + optional: true + "@esbuild/android-arm": + optional: true + "@esbuild/android-arm64": + optional: true + "@esbuild/android-x64": + optional: true + "@esbuild/darwin-arm64": + optional: true + "@esbuild/darwin-x64": + optional: true + "@esbuild/freebsd-arm64": + optional: true + "@esbuild/freebsd-x64": + optional: true + "@esbuild/linux-arm": + optional: true + "@esbuild/linux-arm64": + optional: true + "@esbuild/linux-ia32": + optional: true + "@esbuild/linux-loong64": + optional: true + "@esbuild/linux-mips64el": + optional: true + "@esbuild/linux-ppc64": + optional: true + "@esbuild/linux-riscv64": + optional: true + "@esbuild/linux-s390x": + optional: true + "@esbuild/linux-x64": + optional: true + "@esbuild/netbsd-x64": + optional: true + "@esbuild/openbsd-x64": + optional: true + "@esbuild/sunos-x64": + optional: true + "@esbuild/win32-arm64": + optional: true + "@esbuild/win32-ia32": + optional: true + "@esbuild/win32-x64": + optional: true + bin: + esbuild: bin/esbuild + checksum: 2911c7b50b23a9df59a7d6d4cdd3a4f85855787f374dce751148dbb13305e0ce7e880dde1608c2ab7a927fc6cec3587b80995f7fc87a64b455f8b70b55fd8ec1 + languageName: node + linkType: hard + "escalade@npm:^3.1.1": version: 3.1.1 resolution: "escalade@npm:3.1.1" @@ -10113,7 +10608,7 @@ __metadata: languageName: node linkType: hard -"estree-walker@npm:^3.0.0": +"estree-walker@npm:^3.0.0, estree-walker@npm:^3.0.3": version: 3.0.3 resolution: "estree-walker@npm:3.0.3" dependencies: @@ -10201,6 +10696,23 @@ __metadata: languageName: node linkType: hard +"execa@npm:^8.0.1": + version: 8.0.1 + resolution: "execa@npm:8.0.1" + dependencies: + cross-spawn: ^7.0.3 + get-stream: ^8.0.1 + human-signals: ^5.0.0 + is-stream: ^3.0.0 + merge-stream: ^2.0.0 + npm-run-path: ^5.1.0 + onetime: ^6.0.0 + signal-exit: ^4.1.0 + strip-final-newline: ^3.0.0 + checksum: cac1bf86589d1d9b73bdc5dda65c52012d1a9619c44c526891956745f7b366ca2603d29fe3f7460bacc2b48c6eab5d6a4f7afe0534b31473d3708d1265545e1f + languageName: node + linkType: hard + "exit@npm:^0.1.2": version: 0.1.2 resolution: "exit@npm:0.1.2" @@ -10707,6 +11219,16 @@ __metadata: languageName: node linkType: hard +"fsevents@npm:~2.3.3": + version: 2.3.3 + resolution: "fsevents@npm:2.3.3" + dependencies: + node-gyp: latest + checksum: 11e6ea6fea15e42461fc55b4b0e4a0a3c654faa567f1877dbd353f39156f69def97a69936d1746619d656c4b93de2238bf731f6085a03a50cabf287c9d024317 + conditions: os=darwin + languageName: node + linkType: hard + "fsevents@patch:fsevents@^2.3.2#~builtin, fsevents@patch:fsevents@~2.3.2#~builtin": version: 2.3.2 resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1" @@ -10716,6 +11238,15 @@ __metadata: languageName: node linkType: hard +"fsevents@patch:fsevents@~2.3.3#~builtin": + version: 2.3.3 + resolution: "fsevents@patch:fsevents@npm%3A2.3.3#~builtin::version=2.3.3&hash=df0bf1" + dependencies: + node-gyp: latest + conditions: os=darwin + languageName: node + linkType: hard + "function-bind@npm:^1.1.1": version: 1.1.1 resolution: "function-bind@npm:1.1.1" @@ -10779,6 +11310,13 @@ __metadata: languageName: node linkType: hard +"get-func-name@npm:^2.0.1": + version: 2.0.2 + resolution: "get-func-name@npm:2.0.2" + checksum: 3f62f4c23647de9d46e6f76d2b3eafe58933a9b3830c60669e4180d6c601ce1b4aa310ba8366143f55e52b139f992087a9f0647274e8745621fa2af7e0acf13b + languageName: node + linkType: hard + "get-intrinsic@npm:^1.0.2, get-intrinsic@npm:^1.1.1, get-intrinsic@npm:^1.1.3, get-intrinsic@npm:^1.2.0": version: 1.2.0 resolution: "get-intrinsic@npm:1.2.0" @@ -10832,6 +11370,13 @@ __metadata: languageName: node linkType: hard +"get-stream@npm:^8.0.1": + version: 8.0.1 + resolution: "get-stream@npm:8.0.1" + checksum: 01e3d3cf29e1393f05f44d2f00445c5f9ec3d1c49e8179b31795484b9c117f4c695e5e07b88b50785d5c8248a788c85d9913a79266fc77e3ef11f78f10f1b974 + languageName: node + linkType: hard + "get-symbol-description@npm:^1.0.0": version: 1.0.0 resolution: "get-symbol-description@npm:1.0.0" @@ -11004,6 +11549,13 @@ __metadata: languageName: node linkType: hard +"globrex@npm:^0.1.2": + version: 0.1.2 + resolution: "globrex@npm:0.1.2" + checksum: adca162494a176ce9ecf4dd232f7b802956bb1966b37f60c15e49d2e7d961b66c60826366dc2649093cad5a0d69970cfa8875bd1695b5a1a2f33dcd2aa88da3c + languageName: node + linkType: hard + "gopd@npm:^1.0.1": version: 1.0.1 resolution: "gopd@npm:1.0.1" @@ -11568,6 +12120,13 @@ __metadata: languageName: node linkType: hard +"human-signals@npm:^5.0.0": + version: 5.0.0 + resolution: "human-signals@npm:5.0.0" + checksum: 6504560d5ed91444f16bea3bd9dfc66110a339442084e56c3e7fa7bbdf3f406426d6563d662bdce67064b165eac31eeabfc0857ed170aaa612cf14ec9f9a464c + languageName: node + linkType: hard + "humanize-ms@npm:^1.2.1": version: 1.2.1 resolution: "humanize-ms@npm:1.2.1" @@ -12209,6 +12768,13 @@ __metadata: languageName: node linkType: hard +"is-stream@npm:^3.0.0": + version: 3.0.0 + resolution: "is-stream@npm:3.0.0" + checksum: 172093fe99119ffd07611ab6d1bcccfe8bc4aa80d864b15f43e63e54b7abc71e779acd69afdb854c4e2a67fdc16ae710e370eda40088d1cfc956a50ed82d8f16 + languageName: node + linkType: hard + "is-string@npm:^1.0.5, is-string@npm:^1.0.7": version: 1.0.7 resolution: "is-string@npm:1.0.7" @@ -13293,6 +13859,15 @@ __metadata: languageName: node linkType: hard +"loupe@npm:^3.1.0, loupe@npm:^3.1.1": + version: 3.1.1 + resolution: "loupe@npm:3.1.1" + dependencies: + get-func-name: ^2.0.1 + checksum: c7efa6bc6d71f25ca03eb13c9a069e35ed86799e308ca27a7a3eff8cdf9500e7c22d1f2411468d154a8e960e91e5e685e0c6c83e96db748f177c1adf30811153 + languageName: node + linkType: hard + "lower-case@npm:^2.0.2": version: 2.0.2 resolution: "lower-case@npm:2.0.2" @@ -13355,6 +13930,15 @@ __metadata: languageName: node linkType: hard +"magic-string@npm:^0.30.10": + version: 0.30.10 + resolution: "magic-string@npm:0.30.10" + dependencies: + "@jridgewell/sourcemap-codec": ^1.4.15 + checksum: 456fd47c39b296c47dff967e1965121ace35417eab7f45a99e681e725b8661b48e1573c366ee67a27715025b3740773c46b088f115421c7365ea4ea6fa10d399 + languageName: node + linkType: hard + "magic-string@npm:^0.30.2": version: 0.30.3 resolution: "magic-string@npm:0.30.3" @@ -14316,6 +14900,13 @@ __metadata: languageName: node linkType: hard +"mimic-fn@npm:^4.0.0": + version: 4.0.0 + resolution: "mimic-fn@npm:4.0.0" + checksum: 995dcece15ee29aa16e188de6633d43a3db4611bcf93620e7e62109ec41c79c0f34277165b8ce5e361205049766e371851264c21ac64ca35499acb5421c2ba56 + languageName: node + linkType: hard + "mimic-response@npm:^3.1.0": version: 3.1.0 resolution: "mimic-response@npm:3.1.0" @@ -14713,6 +15304,15 @@ __metadata: languageName: node linkType: hard +"npm-run-path@npm:^5.1.0": + version: 5.3.0 + resolution: "npm-run-path@npm:5.3.0" + dependencies: + path-key: ^4.0.0 + checksum: ae8e7a89da9594fb9c308f6555c73f618152340dcaae423e5fb3620026fefbec463618a8b761920382d666fa7a2d8d240b6fe320e8a6cdd54dc3687e2b659d25 + languageName: node + linkType: hard + "npmlog@npm:^6.0.0": version: 6.0.2 resolution: "npmlog@npm:6.0.2" @@ -14873,6 +15473,15 @@ __metadata: languageName: node linkType: hard +"onetime@npm:^6.0.0": + version: 6.0.0 + resolution: "onetime@npm:6.0.0" + dependencies: + mimic-fn: ^4.0.0 + checksum: 0846ce78e440841335d4e9182ef69d5762e9f38aa7499b19f42ea1c4cd40f0b4446094c455c713f9adac3f4ae86f613bb5e30c99e52652764d06a89f709b3788 + languageName: node + linkType: hard + "open@npm:^8.0.9, open@npm:^8.4.0": version: 8.4.2 resolution: "open@npm:8.4.2" @@ -15171,6 +15780,13 @@ __metadata: languageName: node linkType: hard +"path-key@npm:^4.0.0": + version: 4.0.0 + resolution: "path-key@npm:4.0.0" + checksum: 8e6c314ae6d16b83e93032c61020129f6f4484590a777eed709c4a01b50e498822b00f76ceaf94bc64dbd90b327df56ceadce27da3d83393790f1219e07721d7 + languageName: node + linkType: hard + "path-parse@npm:^1.0.7": version: 1.0.7 resolution: "path-parse@npm:1.0.7" @@ -15218,6 +15834,20 @@ __metadata: languageName: node linkType: hard +"pathe@npm:^1.1.2": + version: 1.1.2 + resolution: "pathe@npm:1.1.2" + checksum: ec5f778d9790e7b9ffc3e4c1df39a5bb1ce94657a4e3ad830c1276491ca9d79f189f47609884671db173400256b005f4955f7952f52a2aeb5834ad5fb4faf134 + languageName: node + linkType: hard + +"pathval@npm:^2.0.0": + version: 2.0.0 + resolution: "pathval@npm:2.0.0" + checksum: 682b6a6289de7990909effef7dae9aa7bb6218c0426727bccf66a35b34e7bfbc65615270c5e44e3c9557a5cb44b1b9ef47fc3cb18bce6ad3ba92bcd28467ed7d + languageName: node + linkType: hard + "periscopic@npm:^3.0.0": version: 3.1.0 resolution: "periscopic@npm:3.1.0" @@ -15236,6 +15866,13 @@ __metadata: languageName: node linkType: hard +"picocolors@npm:^1.0.1": + version: 1.0.1 + resolution: "picocolors@npm:1.0.1" + checksum: fa68166d1f56009fc02a34cdfd112b0dd3cf1ef57667ac57281f714065558c01828cdf4f18600ad6851cbe0093952ed0660b1e0156bddf2184b6aaf5817553a5 + languageName: node + linkType: hard + "picomatch@npm:^2.0.4, picomatch@npm:^2.2.1, picomatch@npm:^2.2.3, picomatch@npm:^2.3.1": version: 2.3.1 resolution: "picomatch@npm:2.3.1" @@ -16119,6 +16756,17 @@ __metadata: languageName: node linkType: hard +"postcss@npm:^8.4.39": + version: 8.4.40 + resolution: "postcss@npm:8.4.40" + dependencies: + nanoid: ^3.3.7 + picocolors: ^1.0.1 + source-map-js: ^1.2.0 + checksum: afd0cc49d2169dcd96c0f17e155c5d75de048956306a3017f1cfa6a7d66b941592245bed20f7796ceeccb2d8967749b623be2c7b010a74f67ea10fb5bdb8ba28 + languageName: node + linkType: hard + "prelude-ls@npm:^1.2.1": version: 1.2.1 resolution: "prelude-ls@npm:1.2.1" @@ -17150,6 +17798,69 @@ __metadata: languageName: node linkType: hard +"rollup@npm:^4.13.0": + version: 4.19.0 + resolution: "rollup@npm:4.19.0" + dependencies: + "@rollup/rollup-android-arm-eabi": 4.19.0 + "@rollup/rollup-android-arm64": 4.19.0 + "@rollup/rollup-darwin-arm64": 4.19.0 + "@rollup/rollup-darwin-x64": 4.19.0 + "@rollup/rollup-linux-arm-gnueabihf": 4.19.0 + "@rollup/rollup-linux-arm-musleabihf": 4.19.0 + "@rollup/rollup-linux-arm64-gnu": 4.19.0 + "@rollup/rollup-linux-arm64-musl": 4.19.0 + "@rollup/rollup-linux-powerpc64le-gnu": 4.19.0 + "@rollup/rollup-linux-riscv64-gnu": 4.19.0 + "@rollup/rollup-linux-s390x-gnu": 4.19.0 + "@rollup/rollup-linux-x64-gnu": 4.19.0 + "@rollup/rollup-linux-x64-musl": 4.19.0 + "@rollup/rollup-win32-arm64-msvc": 4.19.0 + "@rollup/rollup-win32-ia32-msvc": 4.19.0 + "@rollup/rollup-win32-x64-msvc": 4.19.0 + "@types/estree": 1.0.5 + fsevents: ~2.3.2 + dependenciesMeta: + "@rollup/rollup-android-arm-eabi": + optional: true + "@rollup/rollup-android-arm64": + optional: true + "@rollup/rollup-darwin-arm64": + optional: true + "@rollup/rollup-darwin-x64": + optional: true + "@rollup/rollup-linux-arm-gnueabihf": + optional: true + "@rollup/rollup-linux-arm-musleabihf": + optional: true + "@rollup/rollup-linux-arm64-gnu": + optional: true + "@rollup/rollup-linux-arm64-musl": + optional: true + "@rollup/rollup-linux-powerpc64le-gnu": + optional: true + "@rollup/rollup-linux-riscv64-gnu": + optional: true + "@rollup/rollup-linux-s390x-gnu": + optional: true + "@rollup/rollup-linux-x64-gnu": + optional: true + "@rollup/rollup-linux-x64-musl": + optional: true + "@rollup/rollup-win32-arm64-msvc": + optional: true + "@rollup/rollup-win32-ia32-msvc": + optional: true + "@rollup/rollup-win32-x64-msvc": + optional: true + fsevents: + optional: true + bin: + rollup: dist/bin/rollup + checksum: 9c26087d3971a166a51a8941a05bf35ab770879aca59b7d24b6fa0dabf87239fc66cc7f07a69fdc4af346877f22d63db5de848a255a685ca5011e83381a0a989 + languageName: node + linkType: hard + "rollup@npm:^4.18.0": version: 4.18.0 resolution: "rollup@npm:4.18.0" @@ -17219,7 +17930,7 @@ __metadata: dependencies: "@faker-js/faker": ^8.4.1 "@types/jest": ^29.5.12 - "@types/lodash": ^4.17.5 + "@types/lodash": ^4.17.7 "@typescript-eslint/eslint-plugin": ^6.21.0 "@typescript-eslint/parser": ^6.21.0 eslint: ^8.57.0 @@ -17233,6 +17944,8 @@ __metadata: tsc: ^2.0.4 tslib: ^2.6.3 typescript: ^4.9.5 + vite-tsconfig-paths: ^4.3.2 + vitest: ^2.0.4 vx: "workspace:*" wait: ^0.4.2 languageName: unknown @@ -17653,6 +18366,13 @@ __metadata: languageName: node linkType: hard +"siginfo@npm:^2.0.0": + version: 2.0.0 + resolution: "siginfo@npm:2.0.0" + checksum: 8aa5a98640ca09fe00d74416eca97551b3e42991614a3d1b824b115fc1401543650914f651ab1311518177e4d297e80b953f4cd4cd7ea1eabe824e8f2091de01 + languageName: node + linkType: hard + "signal-exit@npm:^3.0.2, signal-exit@npm:^3.0.3, signal-exit@npm:^3.0.7": version: 3.0.7 resolution: "signal-exit@npm:3.0.7" @@ -17667,6 +18387,13 @@ __metadata: languageName: node linkType: hard +"signal-exit@npm:^4.1.0": + version: 4.1.0 + resolution: "signal-exit@npm:4.1.0" + checksum: 64c757b498cb8629ffa5f75485340594d2f8189e9b08700e69199069c8e3070fb3e255f7ab873c05dc0b3cec412aea7402e10a5990cb6a050bd33ba062a6c549 + languageName: node + linkType: hard + "sirv@npm:^2.0.3": version: 2.0.3 resolution: "sirv@npm:2.0.3" @@ -17906,6 +18633,13 @@ __metadata: languageName: node linkType: hard +"stackback@npm:0.0.2": + version: 0.0.2 + resolution: "stackback@npm:0.0.2" + checksum: 2d4dc4e64e2db796de4a3c856d5943daccdfa3dd092e452a1ce059c81e9a9c29e0b9badba91b43ef0d5ff5c04ee62feb3bcc559a804e16faf447bac2d883aa99 + languageName: node + linkType: hard + "statuses@npm:2.0.1": version: 2.0.1 resolution: "statuses@npm:2.0.1" @@ -17927,6 +18661,13 @@ __metadata: languageName: node linkType: hard +"std-env@npm:^3.7.0": + version: 3.7.0 + resolution: "std-env@npm:3.7.0" + checksum: 4f489d13ff2ab838c9acd4ed6b786b51aa52ecacdfeaefe9275fcb220ff2ac80c6e95674723508fd29850a694569563a8caaaea738eb82ca16429b3a0b50e510 + languageName: node + linkType: hard + "string-length@npm:^4.0.1": version: 4.0.2 resolution: "string-length@npm:4.0.2" @@ -18077,6 +18818,13 @@ __metadata: languageName: node linkType: hard +"strip-final-newline@npm:^3.0.0": + version: 3.0.0 + resolution: "strip-final-newline@npm:3.0.0" + checksum: 23ee263adfa2070cd0f23d1ac14e2ed2f000c9b44229aec9c799f1367ec001478469560abefd00c5c99ee6f0b31c137d53ec6029c53e9f32a93804e18c201050 + languageName: node + linkType: hard + "strip-json-comments@npm:^3.1.1": version: 3.1.1 resolution: "strip-json-comments@npm:3.1.1" @@ -18377,6 +19125,34 @@ __metadata: languageName: node linkType: hard +"tinybench@npm:^2.8.0": + version: 2.8.0 + resolution: "tinybench@npm:2.8.0" + checksum: 024a307c6a71f6e2903e110952457ee3dfa606093b45d7f49efcfd01d452650e099474080677ff650b0fd76b49074425ac68ff2a70561699a78515a278bf0862 + languageName: node + linkType: hard + +"tinypool@npm:^1.0.0": + version: 1.0.0 + resolution: "tinypool@npm:1.0.0" + checksum: 59dab87b0811da2dc1ecbac9a99cde93d45450744d4a9fca628d805c452bbb5e5f214fd191127f665d062cae9cc159225dea5508d766e40a0c6c33f573e5c3b6 + languageName: node + linkType: hard + +"tinyrainbow@npm:^1.2.0": + version: 1.2.0 + resolution: "tinyrainbow@npm:1.2.0" + checksum: d1e2cb5400032c0092be00e4a3da5450bea8b4fad58bfb5d3c58ca37ff5c5e252f7fcfb9af247914854af79c46014add9d1042fe044358c305a129ed55c8be35 + languageName: node + linkType: hard + +"tinyspy@npm:^3.0.0": + version: 3.0.0 + resolution: "tinyspy@npm:3.0.0" + checksum: b5b686acff2b88de60ff8ecf89a2042320406aaeee2fba1828a7ea8a925fad3ed9f5e4d7a068154a9134473c472aa03da8ca92ee994bc57a741c5ede5fa7de4d + languageName: node + linkType: hard + "tmp@npm:^0.0.33": version: 0.0.33 resolution: "tmp@npm:0.0.33" @@ -18511,6 +19287,20 @@ __metadata: languageName: node linkType: hard +"tsconfck@npm:^3.0.3": + version: 3.1.1 + resolution: "tsconfck@npm:3.1.1" + peerDependencies: + typescript: ^5.0.0 + peerDependenciesMeta: + typescript: + optional: true + bin: + tsconfck: bin/tsconfck.js + checksum: 92941c76f5a996a96b5d92c88d20f67c644bb04cfeb9e5d4d2fed5a8ecce207fc70334a6257e3c146a117aa88b75adabc0989ee8d80a4935745f2774bf3f50fe + languageName: node + linkType: hard + "tsconfig-paths@npm:^3.15.0": version: 3.15.0 resolution: "tsconfig-paths@npm:3.15.0" @@ -19090,6 +19880,126 @@ __metadata: languageName: node linkType: hard +"vite-node@npm:2.0.4": + version: 2.0.4 + resolution: "vite-node@npm:2.0.4" + dependencies: + cac: ^6.7.14 + debug: ^4.3.5 + pathe: ^1.1.2 + tinyrainbow: ^1.2.0 + vite: ^5.0.0 + bin: + vite-node: vite-node.mjs + checksum: 1e40f2a6eb977fdb77a56b4cb71de0c329b9214bff9db2bedca6186626d70a70e2f3878acad3311e28d718b97e804de3e6795aab846bcb74ea66d4cba5ff48cd + languageName: node + linkType: hard + +"vite-tsconfig-paths@npm:^4.3.2": + version: 4.3.2 + resolution: "vite-tsconfig-paths@npm:4.3.2" + dependencies: + debug: ^4.1.1 + globrex: ^0.1.2 + tsconfck: ^3.0.3 + peerDependencies: + vite: "*" + peerDependenciesMeta: + vite: + optional: true + checksum: 7105ff641379f9f7055110f33067b236c8ee71b1390c0e6482412cdcc7a98c2e139c1c2a483d14fe9045d1977c14dc931e1ff302d6257ec919c70379db9d2419 + languageName: node + linkType: hard + +"vite@npm:^5.0.0": + version: 5.3.5 + resolution: "vite@npm:5.3.5" + dependencies: + esbuild: ^0.21.3 + fsevents: ~2.3.3 + postcss: ^8.4.39 + rollup: ^4.13.0 + peerDependencies: + "@types/node": ^18.0.0 || >=20.0.0 + less: "*" + lightningcss: ^1.21.0 + sass: "*" + stylus: "*" + sugarss: "*" + terser: ^5.4.0 + dependenciesMeta: + fsevents: + optional: true + peerDependenciesMeta: + "@types/node": + optional: true + less: + optional: true + lightningcss: + optional: true + sass: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + bin: + vite: bin/vite.js + checksum: 5412700159e8906fc5ec5ac2cbcbee8a11180803b4a7c85494ae024a4f38d77eb5ab19b556a58745d6981361f8d2e181486f115f8abd4dc6ec3761fcd895e1b2 + languageName: node + linkType: hard + +"vitest@npm:^2.0.4": + version: 2.0.4 + resolution: "vitest@npm:2.0.4" + dependencies: + "@ampproject/remapping": ^2.3.0 + "@vitest/expect": 2.0.4 + "@vitest/pretty-format": ^2.0.4 + "@vitest/runner": 2.0.4 + "@vitest/snapshot": 2.0.4 + "@vitest/spy": 2.0.4 + "@vitest/utils": 2.0.4 + chai: ^5.1.1 + debug: ^4.3.5 + execa: ^8.0.1 + magic-string: ^0.30.10 + pathe: ^1.1.2 + std-env: ^3.7.0 + tinybench: ^2.8.0 + tinypool: ^1.0.0 + tinyrainbow: ^1.2.0 + vite: ^5.0.0 + vite-node: 2.0.4 + why-is-node-running: ^2.3.0 + peerDependencies: + "@edge-runtime/vm": "*" + "@types/node": ^18.0.0 || >=20.0.0 + "@vitest/browser": 2.0.4 + "@vitest/ui": 2.0.4 + happy-dom: "*" + jsdom: "*" + peerDependenciesMeta: + "@edge-runtime/vm": + optional: true + "@types/node": + optional: true + "@vitest/browser": + optional: true + "@vitest/ui": + optional: true + happy-dom: + optional: true + jsdom: + optional: true + bin: + vitest: vitest.mjs + checksum: d00015d1518e297283fc939dc2d30e95258bda65cae9146e82380c87ac0cafd8bb892882516a4940d628afc835fc20e55c8be30f30c8bcaba93e20568dbb3744 + languageName: node + linkType: hard + "vx@workspace:*, vx@workspace:vx": version: 0.0.0-use.local resolution: "vx@workspace:vx" @@ -19422,6 +20332,18 @@ __metadata: languageName: node linkType: hard +"why-is-node-running@npm:^2.3.0": + version: 2.3.0 + resolution: "why-is-node-running@npm:2.3.0" + dependencies: + siginfo: ^2.0.0 + stackback: 0.0.2 + bin: + why-is-node-running: cli.js + checksum: 58ebbf406e243ace97083027f0df7ff4c2108baf2595bb29317718ef207cc7a8104e41b711ff65d6fa354f25daa8756b67f2f04931a4fd6ba9d13ae8197496fb + languageName: node + linkType: hard + "wide-align@npm:^1.1.5": version: 1.1.5 resolution: "wide-align@npm:1.1.5" From e2678823270abd20ad2f5344d841244accd3078b Mon Sep 17 00:00:00 2001 From: ealush Date: Sat, 27 Jul 2024 03:05:37 +0300 Subject: [PATCH 02/16] prettier --- .github/PULL_REQUEST_TEMPLATE.md | 6 +- .yarnrc.yml | 2 +- packages/anyone/README.md | 16 ++-- packages/context/README.md | 2 +- .../context/src/__tests__/cascade.test.ts | 16 ++-- packages/context/src/context.ts | 6 +- .../n4s/src/exports/__tests__/date.test.ts | 56 +++++++------- .../n4s/src/exports/__tests__/email.test.ts | 14 ++-- .../n4s/src/exports/__tests__/isUrl.test.ts | 73 ++++++++++++++----- packages/n4s/src/lib/ruleReturn.ts | 6 +- packages/n4s/src/plugins/compounds/anyOf.ts | 2 +- packages/n4s/src/plugins/compounds/noneOf.ts | 2 +- packages/n4s/src/plugins/schema/isArrayOf.ts | 2 +- packages/n4s/src/plugins/schema/optional.ts | 2 +- packages/n4s/src/rules/greaterThanOrEquals.ts | 2 +- packages/n4s/src/runtime/genEnforceLazy.ts | 2 +- packages/vast/README.md | 2 +- packages/vast/src/__tests__/vast.test.ts | 8 +- packages/vast/src/vast.ts | 12 +-- .../vest-utils/src/__tests__/cache.test.ts | 4 +- .../src/__tests__/defaultTo.test.ts | 2 +- .../__tests__/optionalFunctionValue.test.ts | 2 +- packages/vest-utils/src/hasOwnProperty.ts | 2 +- packages/vest-utils/src/isFunction.ts | 2 +- packages/vest-utils/src/mapFirst.ts | 4 +- packages/vest/src/__tests__/isolate.test.ts | 4 +- packages/vest/src/core/Runtime.ts | 13 ++-- .../core/isolate/IsolateSuite/IsolateSuite.ts | 2 +- .../core/isolate/IsolateTest/TestWalker.ts | 2 +- .../cancelOverriddenPendingTest.ts | 3 +- packages/vest/src/core/isolate/VestIsolate.ts | 5 +- .../__tests__/testFunctionPayload.test.ts | 2 +- .../core/test/helpers/matchingFieldName.ts | 2 +- .../core/test/helpers/matchingGroupName.ts | 2 +- .../test/helpers/shouldUseErrorMessage.ts | 2 +- packages/vest/src/core/test/test.memo.ts | 6 +- .../src/hooks/focused/useHasOnliedTests.ts | 2 +- packages/vest/src/hooks/warn.ts | 2 +- .../vest/src/isolates/__tests__/each.test.ts | 2 +- packages/vest/src/isolates/group.ts | 12 +-- packages/vest/src/suite/createSuite.ts | 1 + packages/vest/src/suite/runCallbacks.ts | 2 +- .../vest/src/suiteResult/SummaryFailure.ts | 4 +- .../selectors/useProduceSuiteSummary.ts | 6 +- packages/vest/src/testUtils/partition.ts | 4 +- packages/vest/src/testUtils/testDummy.ts | 34 ++++----- .../vestjs-runtime/src/Isolate/Isolate.ts | 8 +- packages/vestjs-runtime/src/Reconciler.ts | 8 +- .../src/exports/IsolateSerializer.ts | 5 +- vx/cli.js | 4 +- vx/commands/dev/dev.js | 4 +- vx/commands/init/prompt/index.js | 4 +- vx/commands/test/test.js | 2 +- vx/config/jest/jest.config.js | 2 - vx/config/jest/jest.setupAfterEnv.ts | 8 +- vx/config/rollup/format.js | 2 +- vx/config/rollup/getPlugins.js | 4 +- vx/config/rollup/plugins/addCJSPackageJson.js | 2 +- .../rollup/plugins/addModulePackageJson.js | 2 +- vx/config/rollup/plugins/handleExports.js | 16 ++-- vx/exec.js | 2 +- vx/packageExports.js | 2 +- vx/packageNames.js | 2 +- vx/scripts/release/depsTree.js | 4 +- vx/scripts/release/genDiffData.js | 4 +- .../release/github/commitIgnorePattern.js | 2 +- vx/scripts/release/packagesToRelease.js | 10 +-- .../release/steps/commitChangesToGit.js | 6 +- vx/scripts/release/steps/publishPackage.js | 4 +- vx/scripts/release/steps/setNextVersion.js | 6 +- .../release/steps/updateLocalDepsToLatest.js | 4 +- vx/util/pathsPerPackage.js | 8 +- vx/util/rootPackageJson.js | 2 +- vx/util/runOnActivePackages.js | 2 +- vx/util/taggedBranch.js | 2 +- vx/vxPath.js | 8 +- .../builtin-enforce-plugins/compound_rules.md | 2 +- .../builtin-enforce-plugins/schema_rules.md | 2 +- .../docs/enforce/composing_enforce_rules.md | 10 +-- .../advanced_test_features/dynamic_tests.md | 2 +- .../advanced_test_features/grouping_tests.md | 6 +- .../advanced_test_features/test.memo.md | 2 +- website/docs/writing_tests/warn_only_tests.md | 4 +- .../including_and_excluding/omitWhen.md | 5 +- .../including_and_excluding/skipWhen.md | 2 +- .../writing_your_suite/optional_fields.md | 4 +- website/docusaurus.config.js | 6 +- .../builtin-enforce-plugins/compound_rules.md | 2 +- .../builtin-enforce-plugins/schema_rules.md | 2 +- .../enforce/composing_enforce_rules.md | 10 +-- .../version-4.x/upgrade_guide.md | 6 +- .../advanced_test_features/dynamic_tests.md | 2 +- .../advanced_test_features/grouping_tests.md | 8 +- .../advanced_test_features/test.memo.md | 2 +- .../writing_tests/warn_only_tests.md | 4 +- .../including_and_excluding/omitWhen.md | 2 +- .../including_and_excluding/skipWhen.md | 2 +- .../skip_and_only_group.md | 2 +- .../writing_your_suite/optional_fields.md | 4 +- .../writing_your_suite/result_object.md | 4 +- 100 files changed, 314 insertions(+), 279 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 04723ab29..37a00ee6e 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -6,8 +6,8 @@ CONTRIBUTING.md Please fill the following form (leave what's relevant) --> -| Q | A | -| ---------------- | --- | +| Q | A | +| ---------------- | ----- | | Bug fix? | ✔/✖ | | New feature? | ✔/✖ | | Breaking change? | ✔/✖ | @@ -15,6 +15,6 @@ Please fill the following form (leave what's relevant) | Documentation? | ✔/✖ | | Tests added? | ✔/✖ | | Types added? | ✔/✖ | -| Related issues | | +| Related issues | | diff --git a/.yarnrc.yml b/.yarnrc.yml index 223104e17..f7d4bcced 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -4,6 +4,6 @@ nodeLinker: node-modules plugins: - path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs - spec: "@yarnpkg/plugin-interactive-tools" + spec: '@yarnpkg/plugin-interactive-tools' yarnPath: .yarn/releases/yarn-3.5.1.cjs diff --git a/packages/anyone/README.md b/packages/anyone/README.md index ea09fde2d..700455667 100644 --- a/packages/anyone/README.md +++ b/packages/anyone/README.md @@ -31,7 +31,7 @@ if (one(var1, var2, var3)) { all( validateInput1, // returns true validateInput2, // returns false - validateInput3 // no need to run this, we already know our validation failed + validateInput3, // no need to run this, we already know our validation failed ); ``` @@ -60,7 +60,7 @@ import all from 'anyone/all'; any( someFunction, // evaluates to false 1, - someVar // truthy + someVar, // truthy ); // true @@ -69,7 +69,7 @@ any( any( someFunction, // evaluates to false 0, - someVar // falsy + someVar, // falsy ); // false @@ -78,7 +78,7 @@ any( one( someFunction, // evaluates to false 0, - someVar // truthy + someVar, // truthy ); // true @@ -87,7 +87,7 @@ one( none( someFunction, // evaluates to false 1, - someVar // truthy + someVar, // truthy ); // false @@ -96,7 +96,7 @@ none( none( someFunction, // evaluates to false 0, - someVar // falsy + someVar, // falsy ); // true @@ -105,7 +105,7 @@ none( all( someFunction, // evaluates to false 0, - someVar // truthy + someVar, // truthy ); // false @@ -114,7 +114,7 @@ all( all( someFunction, // evaluates to true 1, - someVar // truthy + someVar, // truthy ); // true ``` diff --git a/packages/context/README.md b/packages/context/README.md index 0c61f2ba4..b5b9f59f7 100644 --- a/packages/context/README.md +++ b/packages/context/README.md @@ -146,7 +146,7 @@ import ctx from './ctx'; function handleCart() { const context = ctx.useX( - 'handleCart was called outside of a running context' + 'handleCart was called outside of a running context', ); // { cart: { items: [ 'foo', 'bar' ] } } // This throws an error if we're not within a `run` call. // You should catch this error and handle it somewhere above this function. diff --git a/packages/context/src/__tests__/cascade.test.ts b/packages/context/src/__tests__/cascade.test.ts index bbf756e40..663f83253 100644 --- a/packages/context/src/__tests__/cascade.test.ts +++ b/packages/context/src/__tests__/cascade.test.ts @@ -40,7 +40,7 @@ describe('Cascading Context', () => { () => { expect(ctx.use().id).toBe(55); expect(ctx.use().user).toBe('boomsa'); - } + }, ); }); @@ -52,7 +52,7 @@ describe('Cascading Context', () => { () => { expect(ctx.use().id).toBe(55); expect(ctx.use().user).toBeUndefined(); - } + }, ); }); @@ -93,9 +93,9 @@ describe('Cascading Context', () => { expect(ctx.use().name).toBe('Emanuelle'); expect(ctx.use().color).toBe('blue'); }); - } + }, ); - } + }, ); }); @@ -123,7 +123,7 @@ describe('Cascading Context', () => { "name": "Emanuelle", } `); - } + }, ); expect(ctx.use().id).toBe(99); expect(ctx.use().name).toBe('watermelonbunny'); @@ -133,7 +133,7 @@ describe('Cascading Context', () => { "name": "watermelonbunny", } `); - } + }, ); }); }); @@ -244,7 +244,7 @@ describe('Cascading Context', () => { it('Should allow a custom context message', () => { expect(() => ctx.useX('Custom Failure Message')).toThrow( - 'Custom Failure Message' + 'Custom Failure Message', ); }); }); @@ -260,7 +260,7 @@ describe('Cascading Context', () => { it('Should allow a custom context message', () => { expect(() => ctx.useX('Custom Failure Message')).toThrow( - 'Custom Failure Message' + 'Custom Failure Message', ); }); }); diff --git a/packages/context/src/context.ts b/packages/context/src/context.ts index a51d841e2..973157258 100644 --- a/packages/context/src/context.ts +++ b/packages/context/src/context.ts @@ -29,7 +29,7 @@ export function createContext(defaultContextValue?: T): CtxApi { function useX(errorMessage?: string): T { invariant( isInsideContext(), - defaultTo(errorMessage, USEX_DEFAULT_ERROR_MESSAGE) + defaultTo(errorMessage, USEX_DEFAULT_ERROR_MESSAGE), ); return contextValue as T; } @@ -55,7 +55,7 @@ export function createContext(defaultContextValue?: T): CtxApi { * When nesting context runs, the the values of the current layer merges with the layers above it. */ export function createCascade>( - init?: (value: Partial, parentContext: Maybe) => Nullable + init?: (value: Partial, parentContext: Maybe) => Nullable, ): CtxCascadeApi { const ctx = createContext(); @@ -72,7 +72,7 @@ export function createCascade>( const out = assign( {}, parentContext ? parentContext : {}, - optionalFunctionValue(init, value, parentContext) ?? value + optionalFunctionValue(init, value, parentContext) ?? value, ) as T; return ctx.run(Object.freeze(out), fn) as R; diff --git a/packages/n4s/src/exports/__tests__/date.test.ts b/packages/n4s/src/exports/__tests__/date.test.ts index 4c36f3252..5e221a30a 100644 --- a/packages/n4s/src/exports/__tests__/date.test.ts +++ b/packages/n4s/src/exports/__tests__/date.test.ts @@ -42,34 +42,34 @@ describe('date', () => { */ it('Should pass for valid dates', () => { expect(() => - enforce('2002-07-15').isDate({ format: 'YYYY-MM-DD' }) + enforce('2002-07-15').isDate({ format: 'YYYY-MM-DD' }), ).not.toThrow(); expect(() => - enforce('2002/07/15').isDate({ format: 'YYYY/MM/DD' }) + enforce('2002/07/15').isDate({ format: 'YYYY/MM/DD' }), ).not.toThrow(); expect(() => - enforce('07/15/2002').isDate({ format: 'MM/DD/YYYY' }) + enforce('07/15/2002').isDate({ format: 'MM/DD/YYYY' }), ).not.toThrow(); expect(() => - enforce('07-15-2002').isDate({ format: 'MM-DD-YYYY' }) + enforce('07-15-2002').isDate({ format: 'MM-DD-YYYY' }), ).not.toThrow(); expect(() => - enforce('15/07/2002').isDate({ format: 'DD/MM/YYYY' }) + enforce('15/07/2002').isDate({ format: 'DD/MM/YYYY' }), ).not.toThrow(); expect(() => - enforce('15-07-2002').isDate({ format: 'DD-MM-YYYY' }) + enforce('15-07-2002').isDate({ format: 'DD-MM-YYYY' }), ).not.toThrow(); expect(() => - enforce('02-07-15').isDate({ format: 'YY-MM-DD' }) + enforce('02-07-15').isDate({ format: 'YY-MM-DD' }), ).not.toThrow(); expect(() => - enforce('02/07/15').isDate({ format: 'YY/MM/DD' }) + enforce('02/07/15').isDate({ format: 'YY/MM/DD' }), ).not.toThrow(); expect(() => - enforce('07/15/02').isDate({ format: 'MM/DD/YY' }) + enforce('07/15/02').isDate({ format: 'MM/DD/YY' }), ).not.toThrow(); expect(() => - enforce('07-15-02').isDate({ format: 'MM-DD-YY' }) + enforce('07-15-02').isDate({ format: 'MM-DD-YY' }), ).not.toThrow(); }); @@ -77,7 +77,7 @@ describe('date', () => { expect(() => enforce('2002-07-15').isDate({ format: 'YYYY-MM-DDTHH:mm:ss.SSSZ', - }) + }), ).toThrow(); }); }); @@ -87,7 +87,7 @@ describe('date', () => { enforce('2002-07-15').isDate({ strictMode: true, format: 'YYYY-MM-DD', - }) + }), ).not.toThrow(); }); @@ -96,7 +96,7 @@ describe('date', () => { enforce('2002-07-15').isDate({ strictMode: true, format: 'YYYY/MM/DD', - }) + }), ).toThrow(); }); }); @@ -157,19 +157,19 @@ describe('date', () => { it('Should pass for valid ISO8601 dates', () => { expect(() => - enforce('2020-07-10 15:00:00.000').isISO8601() + enforce('2020-07-10 15:00:00.000').isISO8601(), ).not.toThrow(); expect(() => enforce('2020-07-10').isISO8601()).not.toThrow(); expect(() => - enforce('2020-07-10T15:00:00.000').isISO8601() + enforce('2020-07-10T15:00:00.000').isISO8601(), ).not.toThrow(); expect(() => enforce('2020-07-10T15:00:00Z').isISO8601()).not.toThrow(); expect(() => - enforce('2020-07-10T15:00:00+05:00').isISO8601() + enforce('2020-07-10T15:00:00+05:00').isISO8601(), ).not.toThrow(); }); @@ -182,23 +182,23 @@ describe('date', () => { describe('strict', () => { it('Should pass for valid ISO8601 dates', () => { expect(() => - enforce('2020-07-10 15:00:00.000').isISO8601({ strict: true }) + enforce('2020-07-10 15:00:00.000').isISO8601({ strict: true }), ).not.toThrow(); expect(() => - enforce('2020-07-10').isISO8601({ strict: true }) + enforce('2020-07-10').isISO8601({ strict: true }), ).not.toThrow(); expect(() => - enforce('2020-07-10T15:00:00.000').isISO8601({ strict: true }) + enforce('2020-07-10T15:00:00.000').isISO8601({ strict: true }), ).not.toThrow(); expect(() => - enforce('2020-07-10T15:00:00Z').isISO8601({ strict: true }) + enforce('2020-07-10T15:00:00Z').isISO8601({ strict: true }), ).not.toThrow(); expect(() => - enforce('2020-07-10T15:00:00+05:00').isISO8601({ strict: true }) + enforce('2020-07-10T15:00:00+05:00').isISO8601({ strict: true }), ).not.toThrow(); }); @@ -206,7 +206,7 @@ describe('date', () => { expect(() => enforce(0).isISO8601({ strict: true })).toThrow(); expect(() => enforce(new Date()).isISO8601({ strict: true })).toThrow(); expect(() => - enforce('2020/07/10T15:00:00.000Z').isISO8601({ strict: true }) + enforce('2020/07/10T15:00:00.000Z').isISO8601({ strict: true }), ).toThrow(); }); }); @@ -216,29 +216,29 @@ describe('date', () => { expect(() => enforce('2002-07-15T00:00:00.000Z').isISO8601({ strictSeparator: true, - }) + }), ).not.toThrow(); expect(() => - enforce('2020-07-10').isISO8601({ strictSeparator: true }) + enforce('2020-07-10').isISO8601({ strictSeparator: true }), ).not.toThrow(); expect(() => enforce('2020-07-10T15:00:00.000').isISO8601({ strictSeparator: true, - }) + }), ).not.toThrow(); expect(() => enforce('2020-07-10T15:00:00Z').isISO8601({ strictSeparator: true, - }) + }), ).not.toThrow(); expect(() => enforce('2020-07-10T15:00:00+05:00').isISO8601({ strictSeparator: true, - }) + }), ).not.toThrow(); }); @@ -246,7 +246,7 @@ describe('date', () => { expect(() => enforce('2020/07/10T15:00:00.000Z').isISO8601({ strictSeparator: true, - }) + }), ).toThrow(); }); }); diff --git a/packages/n4s/src/exports/__tests__/email.test.ts b/packages/n4s/src/exports/__tests__/email.test.ts index 3c4ff19dc..370e7fbec 100644 --- a/packages/n4s/src/exports/__tests__/email.test.ts +++ b/packages/n4s/src/exports/__tests__/email.test.ts @@ -8,7 +8,7 @@ describe('isEmail', () => { expect(() => enforce('user@mail.example.com').isEmail()).not.toThrow(); expect(() => enforce('user+tag@mail.example.com').isEmail()).not.toThrow(); expect(() => - enforce('verylongemailaddress1234567890@mail.example.com').isEmail() + enforce('verylongemailaddress1234567890@mail.example.com').isEmail(), ).not.toThrow(); expect(() => enforce('user@example.co').isEmail()).not.toThrow(); expect(() => enforce('user@example.io').isEmail()).not.toThrow(); @@ -30,19 +30,19 @@ describe('isEmail', () => { expect(() => enforce('Display Name ').isEmail({ allow_display_name: true, - }) + }), ).not.toThrow(); expect(() => enforce('Display Name ').isEmail({ allow_display_name: true, require_display_name: true, - }) + }), ).not.toThrow(); expect(() => - enforce('user@192.168.0.1').isEmail({ allow_ip_domain: true }) + enforce('user@192.168.0.1').isEmail({ allow_ip_domain: true }), ).not.toThrow(); expect(() => - enforce('user@example').isEmail({ require_tld: false }) + enforce('user@example').isEmail({ require_tld: false }), ).not.toThrow(); }); @@ -51,10 +51,10 @@ describe('isEmail', () => { enforce('Display Name user@example.com').isEmail({ allow_display_name: true, require_display_name: true, - }) + }), ).toThrow(); expect(() => - enforce('user@192.168.0.1').isEmail({ allow_ip_domain: false }) + enforce('user@192.168.0.1').isEmail({ allow_ip_domain: false }), ).toThrow(); }); }); diff --git a/packages/n4s/src/exports/__tests__/isUrl.test.ts b/packages/n4s/src/exports/__tests__/isUrl.test.ts index 639f0af44..837d14269 100644 --- a/packages/n4s/src/exports/__tests__/isUrl.test.ts +++ b/packages/n4s/src/exports/__tests__/isUrl.test.ts @@ -6,13 +6,23 @@ describe('isURL', () => { expect(() => enforce('http://www.google.com').isURL()).not.toThrow(); expect(() => enforce('https://google.com').isURL()).not.toThrow(); expect(() => enforce('google.com').isURL()).not.toThrow(); - expect(() => enforce('https://www.wikipedia.org/wiki/Main_Page').isURL()).not.toThrow(); + expect(() => + enforce('https://www.wikipedia.org/wiki/Main_Page').isURL(), + ).not.toThrow(); expect(() => enforce('ftp://myserver.net').isURL()).not.toThrow(); - expect(() => enforce('https://www.example.com/query?search=AI').isURL()).not.toThrow(); - expect(() => enforce('https://username:password@hostname.com:8080').isURL()).not.toThrow(); + expect(() => + enforce('https://www.example.com/query?search=AI').isURL(), + ).not.toThrow(); + expect(() => + enforce('https://username:password@hostname.com:8080').isURL(), + ).not.toThrow(); expect(() => enforce('http://233.233.233.233').isURL()).not.toThrow(); - expect(() => enforce('https://www.example.com/foo/?bar=baz&inga=42&quux').isURL()).not.toThrow(); - expect(() => enforce('http://www.example.com/index.html#section1').isURL()).not.toThrow(); + expect(() => + enforce('https://www.example.com/foo/?bar=baz&inga=42&quux').isURL(), + ).not.toThrow(); + expect(() => + enforce('http://www.example.com/index.html#section1').isURL(), + ).not.toThrow(); }); it('Should fail for invalid URLs', () => { @@ -28,24 +38,51 @@ describe('isURL', () => { expect(() => enforce('http://www.goo gle.com').isURL()).toThrow(); expect(() => enforce('://www.google.com').isURL()).toThrow(); expect(() => enforce('http://localhost').isURL()).toThrow(); - expect(() => enforce('www.com').isURL({ require_host: false })).not.toThrow(); - }) + expect(() => + enforce('www.com').isURL({ require_host: false }), + ).not.toThrow(); + }); describe('With options', () => { it('should pass for valid URLs', () => { - expect(() => enforce('myprotocol://customdomain.com').isURL({ protocols: ['myprotocol'] })).not.toThrow(); - expect(() => enforce('http://localhost:8080').isURL({ require_tld: false })).not.toThrow(); - expect(() => enforce('invalid://www.google.com').isURL({ require_valid_protocol: false })).not.toThrow(); - expect(() => enforce('http://my_server.com').isURL({ allow_underscores: true })).not.toThrow(); + expect(() => + enforce('myprotocol://customdomain.com').isURL({ + protocols: ['myprotocol'], + }), + ).not.toThrow(); + expect(() => + enforce('http://localhost:8080').isURL({ require_tld: false }), + ).not.toThrow(); + expect(() => + enforce('invalid://www.google.com').isURL({ + require_valid_protocol: false, + }), + ).not.toThrow(); + expect(() => + enforce('http://my_server.com').isURL({ allow_underscores: true }), + ).not.toThrow(); }); it('should fail for invalid URLs', () => { - expect(() => enforce('myprotocol://customdomain.com').isURL({ protocols: ['http'] })).toThrow(); - expect(() => enforce('http://localhost:8080').isURL({ require_tld: true })).toThrow(); - expect(() => enforce('invalid://www.google.com').isURL({ require_valid_protocol: true })).toThrow(); - expect(() => enforce('http://my_server.com').isURL({ allow_underscores: false })).toThrow(); - expect(() => enforce('http://www.example.com/index.html#section1').isURL({ allow_fragments: false })).toThrow(); + expect(() => + enforce('myprotocol://customdomain.com').isURL({ protocols: ['http'] }), + ).toThrow(); + expect(() => + enforce('http://localhost:8080').isURL({ require_tld: true }), + ).toThrow(); + expect(() => + enforce('invalid://www.google.com').isURL({ + require_valid_protocol: true, + }), + ).toThrow(); + expect(() => + enforce('http://my_server.com').isURL({ allow_underscores: false }), + ).toThrow(); + expect(() => + enforce('http://www.example.com/index.html#section1').isURL({ + allow_fragments: false, + }), + ).toThrow(); }); }); - -}); \ No newline at end of file +}); diff --git a/packages/n4s/src/lib/ruleReturn.ts b/packages/n4s/src/lib/ruleReturn.ts index fef7075ce..5b30d61bc 100644 --- a/packages/n4s/src/lib/ruleReturn.ts +++ b/packages/n4s/src/lib/ruleReturn.ts @@ -3,7 +3,7 @@ import { defaultTo } from 'vest-utils'; export default function ruleReturn( pass: boolean, - message?: string + message?: string, ): RuleDetailedResult { const output: RuleDetailedResult = { pass }; @@ -23,13 +23,13 @@ export function passing(): RuleDetailedResult { } export function defaultToFailing( - callback: (...args: any[]) => RuleDetailedResult + callback: (...args: any[]) => RuleDetailedResult, ): RuleDetailedResult { return defaultTo(callback, failing()); } export function defaultToPassing( - callback: (...args: any[]) => RuleDetailedResult + callback: (...args: any[]) => RuleDetailedResult, ): RuleDetailedResult { return defaultTo(callback, passing()); } diff --git a/packages/n4s/src/plugins/compounds/anyOf.ts b/packages/n4s/src/plugins/compounds/anyOf.ts index 9ee06d685..2e9a94591 100644 --- a/packages/n4s/src/plugins/compounds/anyOf.ts +++ b/packages/n4s/src/plugins/compounds/anyOf.ts @@ -1,9 +1,9 @@ import { mapFirst } from 'vest-utils'; -import type { Lazy } from '@/runtime/genEnforceLazy'; import * as ruleReturn from '@/lib/ruleReturn'; import type { RuleDetailedResult } from '@/lib/ruleReturn'; import runLazyRule from '@/lib/runLazyRule'; +import type { Lazy } from '@/runtime/genEnforceLazy'; export function anyOf(value: unknown, ...rules: Lazy[]): RuleDetailedResult { return ruleReturn.defaultToFailing( diff --git a/packages/n4s/src/plugins/compounds/noneOf.ts b/packages/n4s/src/plugins/compounds/noneOf.ts index cc7c59cde..db8f1a473 100644 --- a/packages/n4s/src/plugins/compounds/noneOf.ts +++ b/packages/n4s/src/plugins/compounds/noneOf.ts @@ -1,9 +1,9 @@ import { mapFirst } from 'vest-utils'; -import type { Lazy } from '@/runtime/genEnforceLazy'; import type { RuleDetailedResult } from '@/lib/ruleReturn'; import * as ruleReturn from '@/lib/ruleReturn'; import runLazyRule from '@/lib/runLazyRule'; +import type { Lazy } from '@/runtime/genEnforceLazy'; export function noneOf(value: unknown, ...rules: Lazy[]): RuleDetailedResult { return ruleReturn.defaultToPassing( diff --git a/packages/n4s/src/plugins/schema/isArrayOf.ts b/packages/n4s/src/plugins/schema/isArrayOf.ts index 9630dd535..5b5c9a33e 100644 --- a/packages/n4s/src/plugins/schema/isArrayOf.ts +++ b/packages/n4s/src/plugins/schema/isArrayOf.ts @@ -1,10 +1,10 @@ import { ctx } from 'n4s'; import { mapFirst } from 'vest-utils'; -import type { LazyRuleRunners } from '@/runtime/genEnforceLazy'; import type { RuleDetailedResult } from '@/lib/ruleReturn'; import * as ruleReturn from '@/lib/ruleReturn'; import runLazyRule from '@/lib/runLazyRule'; +import type { LazyRuleRunners } from '@/runtime/genEnforceLazy'; export function isArrayOf( inputArray: any[], diff --git a/packages/n4s/src/plugins/schema/optional.ts b/packages/n4s/src/plugins/schema/optional.ts index 6eb3ca3ae..b1b1b2db7 100644 --- a/packages/n4s/src/plugins/schema/optional.ts +++ b/packages/n4s/src/plugins/schema/optional.ts @@ -1,9 +1,9 @@ import { isNullish } from 'vest-utils'; -import type { Lazy } from '@/runtime/genEnforceLazy'; import type { RuleDetailedResult } from '@/lib/ruleReturn'; import * as ruleReturn from '@/lib/ruleReturn'; import runLazyRule from '@/lib/runLazyRule'; +import type { Lazy } from '@/runtime/genEnforceLazy'; export function optional(value: any, ruleChain: Lazy): RuleDetailedResult { if (isNullish(value)) { diff --git a/packages/n4s/src/rules/greaterThanOrEquals.ts b/packages/n4s/src/rules/greaterThanOrEquals.ts index c2ee07d7e..43b099cc8 100644 --- a/packages/n4s/src/rules/greaterThanOrEquals.ts +++ b/packages/n4s/src/rules/greaterThanOrEquals.ts @@ -2,7 +2,7 @@ import { greaterThan, numberEquals } from 'vest-utils'; export function greaterThanOrEquals( value: string | number, - gte: string | number + gte: string | number, ): boolean { return numberEquals(value, gte) || greaterThan(value, gte); } diff --git a/packages/n4s/src/runtime/genEnforceLazy.ts b/packages/n4s/src/runtime/genEnforceLazy.ts index 41fa633f2..b443546ad 100644 --- a/packages/n4s/src/runtime/genEnforceLazy.ts +++ b/packages/n4s/src/runtime/genEnforceLazy.ts @@ -1,4 +1,3 @@ -import { ctx } from '@/runtime/enforceContext'; import { mapFirst, optionalFunctionValue, @@ -13,6 +12,7 @@ import ruleReturn, { RuleDetailedResult, } from '@/lib/ruleReturn'; import { transformResult } from '@/lib/transformResult'; +import { ctx } from '@/runtime/enforceContext'; import { RuleValue, Args, getRule } from '@/runtime/runtimeRules'; // eslint-disable-next-line max-lines-per-function diff --git a/packages/vast/README.md b/packages/vast/README.md index 0274aa523..45758925a 100644 --- a/packages/vast/README.md +++ b/packages/vast/README.md @@ -58,7 +58,7 @@ const useColor = state.registerStateKey( 'red', (currentState, previousState) => { console.log(`the color changed from ${previousState} to ${currentState}!`); - } + }, ); ``` diff --git a/packages/vast/src/__tests__/vast.test.ts b/packages/vast/src/__tests__/vast.test.ts index da3d21c3a..ff5c3bb2a 100644 --- a/packages/vast/src/__tests__/vast.test.ts +++ b/packages/vast/src/__tests__/vast.test.ts @@ -26,12 +26,12 @@ describe('vast state', () => { it('Should append another state key on each call', () => { const stateValues = Array.from({ length: 100 }, () => Math.random()); const stateGetters = stateValues.map(value => - state.registerStateKey(value) + state.registerStateKey(value), ); expect( stateGetters.every( - (stateGetter, i) => stateGetter()[0] === stateValues[i] - ) + (stateGetter, i) => stateGetter()[0] === stateValues[i], + ), ).toBe(true); expect(stateGetters).toHaveLength(100); }); @@ -165,7 +165,7 @@ describe('vast state', () => { state.registerStateKey('v1', onUpdate); expect(onUpdate.mock.invocationCallOrder[0]).toBeLessThan( - onChange.mock.invocationCallOrder[0] + onChange.mock.invocationCallOrder[0], ); }); }); diff --git a/packages/vast/src/vast.ts b/packages/vast/src/vast.ts index 6f663b432..f776ca766 100644 --- a/packages/vast/src/vast.ts +++ b/packages/vast/src/vast.ts @@ -8,7 +8,7 @@ import { // eslint-disable-next-line max-lines-per-function export function createState( - onStateChange?: (...args: unknown[]) => unknown + onStateChange?: (...args: unknown[]) => unknown, ): CreateStateReturn { const state: { references: unknown[]; @@ -18,7 +18,7 @@ export function createState( const registrations: [ unknown, - ((currentState: S, prevState: S) => void)? + ((currentState: S, prevState: S) => void)?, ][] = []; return { @@ -41,7 +41,7 @@ export function createState( */ function registerStateKey( initialState?: Maybe>, - onUpdate?: () => void + onUpdate?: () => void, ): CB> { const key = registrations.length; registrations.push([initialState, onUpdate]); @@ -52,14 +52,14 @@ export function createState( const prev = current(); state.references = []; registrations.forEach(([initialValue], index) => - initKey(index, initialValue, prev[index]) + initKey(index, initialValue, prev[index]), ); } function initKey( key: number, initialState?: Maybe>, - prevState?: Maybe + prevState?: Maybe, ) { current().push(); set(key, optionalFunctionValue(initialState, prevState)); @@ -104,6 +104,6 @@ type CreateStateReturn = { reset: () => void; registerStateKey: ( initialState?: Maybe>, - onUpdate?: () => void + onUpdate?: () => void, ) => CB>; }; diff --git a/packages/vest-utils/src/__tests__/cache.test.ts b/packages/vest-utils/src/__tests__/cache.test.ts index d8eae24e1..7cfa4feb7 100644 --- a/packages/vest-utils/src/__tests__/cache.test.ts +++ b/packages/vest-utils/src/__tests__/cache.test.ts @@ -59,7 +59,7 @@ describe('lib: cache', () => { Array.from({ length: callCount }, (_, i) => { const c = cache(/*maxSize*/ cacheSize); const results = Array.from({ length: callCount }, (_, j) => - c([j], Math.random) + c([j], Math.random), ); if (i < diff) { @@ -74,7 +74,7 @@ describe('lib: cache', () => { }); it('Should take into account the deps array in its entirety', () => { const deps = Array.from({ length: 100 }, () => - _.sample([{}, false, Math.random(), true, () => null]) + _.sample([{}, false, Math.random(), true, () => null]), ); const c = cache(); const res = c([...deps], Math.random); diff --git a/packages/vest-utils/src/__tests__/defaultTo.test.ts b/packages/vest-utils/src/__tests__/defaultTo.test.ts index 8886e3d47..0dc823a40 100644 --- a/packages/vest-utils/src/__tests__/defaultTo.test.ts +++ b/packages/vest-utils/src/__tests__/defaultTo.test.ts @@ -34,7 +34,7 @@ describe('defaultTo', () => { 'Should return the same value', value => { expect(defaultTo(value, 'fallback value')).toBe(value); - } + }, ); }); }); diff --git a/packages/vest-utils/src/__tests__/optionalFunctionValue.test.ts b/packages/vest-utils/src/__tests__/optionalFunctionValue.test.ts index ec973a01f..ede97ee76 100644 --- a/packages/vest-utils/src/__tests__/optionalFunctionValue.test.ts +++ b/packages/vest-utils/src/__tests__/optionalFunctionValue.test.ts @@ -6,7 +6,7 @@ describe('optionalFunctionValue', () => { 'Should return the same value', value => { expect(optionalFunctionValue(value)).toBe(value); - } + }, ); }); diff --git a/packages/vest-utils/src/hasOwnProperty.ts b/packages/vest-utils/src/hasOwnProperty.ts index 7f6330e51..f2f9a12dc 100644 --- a/packages/vest-utils/src/hasOwnProperty.ts +++ b/packages/vest-utils/src/hasOwnProperty.ts @@ -3,7 +3,7 @@ */ export default function hasOwnProperty( obj: T, - key: string | number | symbol + key: string | number | symbol, ): key is keyof T { return Object.prototype.hasOwnProperty.call(obj, key); } diff --git a/packages/vest-utils/src/isFunction.ts b/packages/vest-utils/src/isFunction.ts index aafbf70c3..3378daea0 100644 --- a/packages/vest-utils/src/isFunction.ts +++ b/packages/vest-utils/src/isFunction.ts @@ -1,5 +1,5 @@ export default function isFunction( - value: unknown + value: unknown, ): value is (...args: unknown[]) => unknown { return typeof value === 'function'; } diff --git a/packages/vest-utils/src/mapFirst.ts b/packages/vest-utils/src/mapFirst.ts index cd989f8c1..55f42e80f 100644 --- a/packages/vest-utils/src/mapFirst.ts +++ b/packages/vest-utils/src/mapFirst.ts @@ -3,8 +3,8 @@ export default function mapFirst( callback: ( item: T, breakout: (conditional: boolean, value: unknown) => void, - index: number - ) => unknown + index: number, + ) => unknown, ): any { let broke = false; let breakoutValue = null; diff --git a/packages/vest/src/__tests__/isolate.test.ts b/packages/vest/src/__tests__/isolate.test.ts index a90ae4825..81521221b 100644 --- a/packages/vest/src/__tests__/isolate.test.ts +++ b/packages/vest/src/__tests__/isolate.test.ts @@ -259,8 +259,8 @@ describe('isolate', () => { expect(deferThrow).toHaveBeenCalledTimes(1); expect(deferThrow).toHaveBeenCalledWith( expect.stringContaining( - 'Vest Critical Error: Tests called in different order than previous run' - ) + 'Vest Critical Error: Tests called in different order than previous run', + ), ); }); }); diff --git a/packages/vest/src/core/Runtime.ts b/packages/vest/src/core/Runtime.ts index 6557f1f8e..92761a372 100644 --- a/packages/vest/src/core/Runtime.ts +++ b/packages/vest/src/core/Runtime.ts @@ -1,9 +1,3 @@ -import { - SuiteName, - SuiteResult, - TFieldName, - TGroupName, -} from '@/suiteResult/SuiteResultTypes'; import { CB, CacheApi, @@ -19,6 +13,13 @@ import { Severity } from '../suiteResult/Severity'; import { TIsolateSuite } from './isolate/IsolateSuite/IsolateSuite'; +import { + SuiteName, + SuiteResult, + TFieldName, + TGroupName, +} from '@/suiteResult/SuiteResultTypes'; + export type DoneCallback = (res: SuiteResult) => void; type FieldCallbacks = Record; type DoneCallbacks = Array; diff --git a/packages/vest/src/core/isolate/IsolateSuite/IsolateSuite.ts b/packages/vest/src/core/isolate/IsolateSuite/IsolateSuite.ts index 300eb9ed1..38252199e 100644 --- a/packages/vest/src/core/isolate/IsolateSuite/IsolateSuite.ts +++ b/packages/vest/src/core/isolate/IsolateSuite/IsolateSuite.ts @@ -1,12 +1,12 @@ import { CB, assign } from 'vest-utils'; import { Isolate, TIsolate } from 'vestjs-runtime'; +import { VestIsolateType } from '@/core/isolate/VestIsolateType'; import { OptionalFieldDeclaration, OptionalFields, } from '@/hooks/optional/OptionalTypes'; import { TFieldName } from '@/suiteResult/SuiteResultTypes'; -import { VestIsolateType } from '@/core/isolate/VestIsolateType'; export type TIsolateSuite = TIsolate<{ optional: OptionalFields; diff --git a/packages/vest/src/core/isolate/IsolateTest/TestWalker.ts b/packages/vest/src/core/isolate/IsolateTest/TestWalker.ts index 5a148e6e5..3b04b2852 100644 --- a/packages/vest/src/core/isolate/IsolateTest/TestWalker.ts +++ b/packages/vest/src/core/isolate/IsolateTest/TestWalker.ts @@ -2,9 +2,9 @@ import { Nullable } from 'vest-utils'; import { Walker, VestRuntime, TIsolate } from 'vestjs-runtime'; import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; -import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; import matchingFieldName from '@/core/test/helpers/matchingFieldName'; +import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; type MaybeRoot = Nullable; diff --git a/packages/vest/src/core/isolate/IsolateTest/cancelOverriddenPendingTest.ts b/packages/vest/src/core/isolate/IsolateTest/cancelOverriddenPendingTest.ts index ba2d0194c..6b3da314e 100644 --- a/packages/vest/src/core/isolate/IsolateTest/cancelOverriddenPendingTest.ts +++ b/packages/vest/src/core/isolate/IsolateTest/cancelOverriddenPendingTest.ts @@ -1,6 +1,7 @@ +import { isSameProfileTest } from './isSameProfileTest'; + import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; -import { isSameProfileTest } from './isSameProfileTest'; export default function cancelOverriddenPendingTest( prevRunTestObject: TIsolateTest, diff --git a/packages/vest/src/core/isolate/VestIsolate.ts b/packages/vest/src/core/isolate/VestIsolate.ts index cf08fafba..d0056743d 100644 --- a/packages/vest/src/core/isolate/VestIsolate.ts +++ b/packages/vest/src/core/isolate/VestIsolate.ts @@ -1,7 +1,10 @@ import { TStateMachineApi } from 'vest-utils'; import { TIsolate } from 'vestjs-runtime'; -import { CommonStateMachine, CommonStates } from '@/core/StateMachines/CommonStateMachine'; +import { + CommonStateMachine, + CommonStates, +} from '@/core/StateMachines/CommonStateMachine'; export class VestIsolate { static stateMachine: TStateMachineApi = CommonStateMachine; diff --git a/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts b/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts index e34248f8a..f252ffe0a 100644 --- a/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts +++ b/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts @@ -77,7 +77,7 @@ describe('Test Function Payload', () => { function callPayload( fn: jest.Mock, call: number = 0, - arg: number = 0 + arg: number = 0, ) { return fn.mock.calls[call][arg]; } diff --git a/packages/vest/src/core/test/helpers/matchingFieldName.ts b/packages/vest/src/core/test/helpers/matchingFieldName.ts index 426ea7bd9..d68e27b46 100644 --- a/packages/vest/src/core/test/helpers/matchingFieldName.ts +++ b/packages/vest/src/core/test/helpers/matchingFieldName.ts @@ -1,7 +1,7 @@ import { Maybe } from 'vest-utils'; -import { TFieldName } from '@/suiteResult/SuiteResultTypes'; import { WithFieldName } from '@/core/test/TestTypes'; +import { TFieldName } from '@/suiteResult/SuiteResultTypes'; export function nonMatchingFieldName( WithFieldName: WithFieldName, diff --git a/packages/vest/src/core/test/helpers/matchingGroupName.ts b/packages/vest/src/core/test/helpers/matchingGroupName.ts index b156d1058..9487b13f0 100644 --- a/packages/vest/src/core/test/helpers/matchingGroupName.ts +++ b/packages/vest/src/core/test/helpers/matchingGroupName.ts @@ -1,8 +1,8 @@ import { Maybe, bindNot } from 'vest-utils'; import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; -import { TGroupName } from '@/suiteResult/SuiteResultTypes'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { TGroupName } from '@/suiteResult/SuiteResultTypes'; export const nonMatchingGroupName = bindNot(matchingGroupName); diff --git a/packages/vest/src/core/test/helpers/shouldUseErrorMessage.ts b/packages/vest/src/core/test/helpers/shouldUseErrorMessage.ts index c29724f63..aa381d004 100644 --- a/packages/vest/src/core/test/helpers/shouldUseErrorMessage.ts +++ b/packages/vest/src/core/test/helpers/shouldUseErrorMessage.ts @@ -2,7 +2,7 @@ import { Maybe, isStringValue, isUndefined } from 'vest-utils'; export function shouldUseErrorAsMessage( message: Maybe, - error: unknown + error: unknown, ): error is Maybe { // kind of cheating with this safe guard, but it does the job return isUndefined(message) && isStringValue(error); diff --git a/packages/vest/src/core/test/test.memo.ts b/packages/vest/src/core/test/test.memo.ts index 69b180aaa..ff7d2db2a 100644 --- a/packages/vest/src/core/test/test.memo.ts +++ b/packages/vest/src/core/test/test.memo.ts @@ -1,13 +1,13 @@ import { CB, isNull } from 'vest-utils'; import { VestRuntime } from 'vestjs-runtime'; -import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; import * as Runtime from '@/core/Runtime'; import { useTestMemoCache } from '@/core/context/SuiteContext'; -import { TFieldName } from '@/suiteResult/SuiteResultTypes'; -import { TestFn } from '@/core/test/TestTypes'; +import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { TestFn } from '@/core/test/TestTypes'; import { VTest } from '@/core/test/test'; +import { TFieldName } from '@/suiteResult/SuiteResultTypes'; // @vx-allow use-use export function wrapTestMemo(test: VTest): TestMemo { diff --git a/packages/vest/src/hooks/focused/useHasOnliedTests.ts b/packages/vest/src/hooks/focused/useHasOnliedTests.ts index b18784231..a95ccb24e 100644 --- a/packages/vest/src/hooks/focused/useHasOnliedTests.ts +++ b/packages/vest/src/hooks/focused/useHasOnliedTests.ts @@ -2,8 +2,8 @@ import { isNotNullish } from 'vest-utils'; import { TIsolate, Walker } from 'vestjs-runtime'; import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; -import { TFieldName } from '@/suiteResult/SuiteResultTypes'; import { FocusSelectors } from '@/hooks/focused/focused'; +import { TFieldName } from '@/suiteResult/SuiteResultTypes'; /** * Checks if context has included tests diff --git a/packages/vest/src/hooks/warn.ts b/packages/vest/src/hooks/warn.ts index 046d1e978..b09a365a4 100644 --- a/packages/vest/src/hooks/warn.ts +++ b/packages/vest/src/hooks/warn.ts @@ -1,8 +1,8 @@ import { invariant } from 'vest-utils'; -import { ErrorStrings } from '@/errors/ErrorStrings'; import { useCurrentTest } from '@/core/context/SuiteContext'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { ErrorStrings } from '@/errors/ErrorStrings'; const ERROR_OUTSIDE_OF_TEST = ErrorStrings.WARN_MUST_BE_CALLED_FROM_TEST; diff --git a/packages/vest/src/isolates/__tests__/each.test.ts b/packages/vest/src/isolates/__tests__/each.test.ts index d45994078..a260e254d 100644 --- a/packages/vest/src/isolates/__tests__/each.test.ts +++ b/packages/vest/src/isolates/__tests__/each.test.ts @@ -1,4 +1,4 @@ -import { TDeferThrow } from 'vest-utils/src/deferThrow'; +import { TDeferThrow } from 'vest-utils/deferThrow'; import { TVestMock } from '../../testUtils/TVestMock'; import mockThrowError from '../../testUtils/mockThrowError'; diff --git a/packages/vest/src/isolates/group.ts b/packages/vest/src/isolates/group.ts index 5dfce9e81..b3def1a5d 100644 --- a/packages/vest/src/isolates/group.ts +++ b/packages/vest/src/isolates/group.ts @@ -1,14 +1,13 @@ import { CB } from 'vest-utils'; import { TIsolate, Isolate } from 'vestjs-runtime'; - import { SuiteContext } from '@/core/context/SuiteContext'; import { VestIsolateType } from '@/core/isolate/VestIsolateType'; import { TGroupName } from '@/suiteResult/SuiteResultTypes'; export function group( groupName: G, - callback: CB + callback: CB, ): TIsolate; export function group(callback: CB): TIsolate; export function group( @@ -16,10 +15,7 @@ export function group( ): TIsolate { const [callback, groupName] = args.reverse() as [CB, G]; - return Isolate.create( - VestIsolateType.Group, - () => { - return SuiteContext.run({ ...(groupName && { groupName }) }, callback); - }, - ); + return Isolate.create(VestIsolateType.Group, () => { + return SuiteContext.run({ ...(groupName && { groupName }) }, callback); + }); } diff --git a/packages/vest/src/suite/createSuite.ts b/packages/vest/src/suite/createSuite.ts index 101d15989..0fd4f6eff 100644 --- a/packages/vest/src/suite/createSuite.ts +++ b/packages/vest/src/suite/createSuite.ts @@ -22,6 +22,7 @@ import { useSuiteRunResult } from '../suiteResult/suiteRunResult'; import { Suite } from './SuiteTypes'; import { TTypedMethods, getTypedMethods } from './getTypedMethods'; import { validateSuiteCallback } from './validateParams/validateSuiteParams'; +import { VestReconciler } from '@/core/isolate/VestReconciler'; function createSuite< F extends TFieldName = string, diff --git a/packages/vest/src/suite/runCallbacks.ts b/packages/vest/src/suite/runCallbacks.ts index 7454164cf..8db00000f 100644 --- a/packages/vest/src/suite/runCallbacks.ts +++ b/packages/vest/src/suite/runCallbacks.ts @@ -1,8 +1,8 @@ import { isArray, callEach } from 'vest-utils'; import { useDoneCallbacks, useFieldCallbacks } from '@/core/Runtime'; -import { TFieldName } from '@/suiteResult/SuiteResultTypes'; import { SuiteWalker } from '@/suite/SuiteWalker'; +import { TFieldName } from '@/suiteResult/SuiteResultTypes'; /** * Runs done callback per field when async tests are finished running. diff --git a/packages/vest/src/suiteResult/SummaryFailure.ts b/packages/vest/src/suiteResult/SummaryFailure.ts index fd6ef2d84..fbcd27706 100644 --- a/packages/vest/src/suiteResult/SummaryFailure.ts +++ b/packages/vest/src/suiteResult/SummaryFailure.ts @@ -1,7 +1,7 @@ import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; -import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; -import { WithFieldName } from '@/core/test/TestTypes'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; +import { WithFieldName } from '@/core/test/TestTypes'; +import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; export class SummaryFailure implements WithFieldName diff --git a/packages/vest/src/suiteResult/selectors/useProduceSuiteSummary.ts b/packages/vest/src/suiteResult/selectors/useProduceSuiteSummary.ts index 0cd3e5237..ec27fc84e 100644 --- a/packages/vest/src/suiteResult/selectors/useProduceSuiteSummary.ts +++ b/packages/vest/src/suiteResult/selectors/useProduceSuiteSummary.ts @@ -1,6 +1,8 @@ import { Maybe, assign, defaultTo } from 'vest-utils'; import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; +import { TestWalker } from '@/core/isolate/IsolateTest/TestWalker'; +import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; import { countKeyBySeverity, Severity } from '@/suiteResult/Severity'; import { Groups, @@ -12,12 +14,10 @@ import { Tests, } from '@/suiteResult/SuiteResultTypes'; import { SummaryFailure } from '@/suiteResult/SummaryFailure'; -import { TestWalker } from '@/core/isolate/IsolateTest/TestWalker'; -import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; import { useShouldAddValidProperty, useShouldAddValidPropertyInGroup, -} from 'shouldAddValidProperty'; +} from '@/suiteResult/selectors/shouldAddValidProperty'; export function useProduceSuiteSummary< F extends TFieldName, diff --git a/packages/vest/src/testUtils/partition.ts b/packages/vest/src/testUtils/partition.ts index 8af8050db..8dbbcbaed 100644 --- a/packages/vest/src/testUtils/partition.ts +++ b/packages/vest/src/testUtils/partition.ts @@ -1,12 +1,12 @@ export default function partition( array: T[], - predicate: (value: T, _index: number, array: T[]) => boolean + predicate: (value: T, _index: number, array: T[]) => boolean, ): [T[], T[]] { return array.reduce( (partitions: [T[], T[]], value, number) => { partitions[predicate(value, number, array) ? 0 : 1].push(value); return partitions; }, - [[], []] + [[], []], ); } diff --git a/packages/vest/src/testUtils/testDummy.ts b/packages/vest/src/testUtils/testDummy.ts index ab2f1fe85..fa018acaa 100644 --- a/packages/vest/src/testUtils/testDummy.ts +++ b/packages/vest/src/testUtils/testDummy.ts @@ -10,14 +10,14 @@ import { test as vestTest, warn } from 'vest'; const testDummy = () => { const failing = ( name: string = faker.lorem.word(), - message: string = faker.lorem.words() + message: string = faker.lorem.words(), ) => { const to = vestTest( name, message, jest.fn(() => { throw new Error(); - }) + }), ); return to; @@ -25,7 +25,7 @@ const testDummy = () => { const failingWarning = ( name = faker.lorem.word(), - message = faker.lorem.words() + message = faker.lorem.words(), ) => { const to = vestTest( name, @@ -33,7 +33,7 @@ const testDummy = () => { jest.fn(() => { warn(); throw new Error(); - }) + }), ); return to; @@ -41,7 +41,7 @@ const testDummy = () => { const passing = ( name = faker.lorem.word(), - message = faker.lorem.words() + message = faker.lorem.words(), ) => { const to = vestTest(name, message, jest.fn()); @@ -50,21 +50,21 @@ const testDummy = () => { const passingWarning = ( name = faker.lorem.word(), - message = faker.lorem.words() + message = faker.lorem.words(), ) => { const to = vestTest( name, message, jest.fn(() => { warn(); - }) + }), ); return to; }; const failingAsync = ( name = faker.lorem.word(), - { message = faker.lorem.words(), time = 0 } = {} + { message = faker.lorem.words(), time = 0 } = {}, ) => vestTest( name, @@ -73,13 +73,13 @@ const testDummy = () => { () => new Promise((_, reject) => { setTimeout(reject, time); - }) - ) + }), + ), ); const failingWarningAsync = ( name = faker.lorem.word(), - { message = faker.lorem.words(), time = 0 } = {} + { message = faker.lorem.words(), time = 0 } = {}, ) => vestTest( name, @@ -89,12 +89,12 @@ const testDummy = () => { return new Promise((_, reject) => { setTimeout(reject, time); }); - }) + }), ); const passingAsync = ( name = faker.lorem.word(), - { message = faker.lorem.words(), time = 0 } = {} + { message = faker.lorem.words(), time = 0 } = {}, ) => vestTest( name, @@ -103,13 +103,13 @@ const testDummy = () => { () => new Promise(resolve => { setTimeout(resolve, time); - }) - ) + }), + ), ); const passingWarningAsync = ( name = faker.lorem.word(), - { message = faker.lorem.words(), time = 0 } = {} + { message = faker.lorem.words(), time = 0 } = {}, ) => vestTest( name, @@ -119,7 +119,7 @@ const testDummy = () => { return new Promise(resolve => { setTimeout(resolve, time); }); - }) + }), ); return { diff --git a/packages/vestjs-runtime/src/Isolate/Isolate.ts b/packages/vestjs-runtime/src/Isolate/Isolate.ts index f78819607..5c66cff69 100644 --- a/packages/vestjs-runtime/src/Isolate/Isolate.ts +++ b/packages/vestjs-runtime/src/Isolate/Isolate.ts @@ -1,10 +1,12 @@ +import { useEmit } from '@/Bus'; import { CB, Maybe, Nullable, isNotNullish, isPromise } from 'vest-utils'; -import { useEmit } from '../Bus'; import { RuntimeEvents } from '../RuntimeEvents'; -import { IsolateMutator, Reconciler, VestRuntime } from '../vestjs-runtime'; -import { IsolateKeys } from './IsolateKeys'; +import { IsolateKeys } from '@/Isolate/IsolateKeys'; +import { IsolateMutator } from '@/Isolate/IsolateMutator'; +import { Reconciler } from '@/Reconciler'; +import * as VestRuntime from '@/VestRuntime'; export type IsolateKey = Nullable; diff --git a/packages/vestjs-runtime/src/Reconciler.ts b/packages/vestjs-runtime/src/Reconciler.ts index 1b248ea17..ced2aeb7c 100644 --- a/packages/vestjs-runtime/src/Reconciler.ts +++ b/packages/vestjs-runtime/src/Reconciler.ts @@ -7,14 +7,12 @@ import { } from 'vest-utils'; import { ErrorStrings } from './errors/ErrorStrings'; -import { - IsolateInspector, - IsolateMutator, - VestRuntime, -} from './vestjs-runtime'; import { type TIsolate } from '@/Isolate/Isolate'; +import { IsolateInspector } from '@/Isolate/IsolateInspector'; +import { IsolateMutator } from '@/Isolate/IsolateMutator'; import { isSameIsolateType } from '@/Isolate/IsolateSelectors'; +import * as VestRuntime from '@/VestRuntime'; // I would rather not use `any` here, but instead use `Isolate`. // The problem is that it breaks the actual implementation of `Isolate` in `IsolateTest` diff --git a/packages/vestjs-runtime/src/exports/IsolateSerializer.ts b/packages/vestjs-runtime/src/exports/IsolateSerializer.ts index 0d7e1c0af..d327d0893 100644 --- a/packages/vestjs-runtime/src/exports/IsolateSerializer.ts +++ b/packages/vestjs-runtime/src/exports/IsolateSerializer.ts @@ -6,10 +6,7 @@ import { isStringValue, text, } from 'vest-utils'; -import { - expandObject, - minifyObject, -} from 'vest-utils/src/exports/minifyObject'; +import { expandObject, minifyObject } from 'vest-utils/minifyObject'; import { TIsolate } from '../../types/vestjs-runtime'; import { ExcludedFromDump, IsolateKeys } from '../Isolate/IsolateKeys'; diff --git a/vx/cli.js b/vx/cli.js index cdb25d88a..ecb606c08 100755 --- a/vx/cli.js +++ b/vx/cli.js @@ -68,14 +68,14 @@ logger.info( joinTruthy([ `Running command ${command}`, package && `for package ${package}`, - ]) + ]), ); ctx.withPackage(package, () => commands[command]({ fastBuild, cliOptions: cliOptions.join(' '), - }) + }), ); function insidePackageDir() { diff --git a/vx/commands/dev/dev.js b/vx/commands/dev/dev.js index cfa48789e..3efa28a32 100644 --- a/vx/commands/dev/dev.js +++ b/vx/commands/dev/dev.js @@ -5,7 +5,7 @@ module.exports = () => { exec( `${vxPath.vxRoot()}/node_modules/.bin/onchange -d 5000 -i -k ${vxPath.packageSrc( '*', - '**/*.ts' - )} ${vxPath.packageSrc('*', '**/*.ts')} -- vx prepare` + '**/*.ts', + )} ${vxPath.packageSrc('*', '**/*.ts')} -- vx prepare`, ); }; diff --git a/vx/commands/init/prompt/index.js b/vx/commands/init/prompt/index.js index 63aa6af9b..d32a4fbd1 100644 --- a/vx/commands/init/prompt/index.js +++ b/vx/commands/init/prompt/index.js @@ -81,7 +81,7 @@ function writeEntryPoint(packagePath, packageName) { fsExtra.writeFileSync( vxPath.packageSrc(packageName, `${packageName}.ts`), `export const main = () => "${packageName}";`, - 'utf8' + 'utf8', ); } @@ -93,7 +93,7 @@ function updateValues(packagePath, config) { Object.keys(configMapping).forEach(key => { content = content.replace( new RegExp(`{{${key}}}`, 'g'), - config[configMapping[key]] ?? configMapping[key] + config[configMapping[key]] ?? configMapping[key], ); }); diff --git a/vx/commands/test/test.js b/vx/commands/test/test.js index 241cff736..359132096 100644 --- a/vx/commands/test/test.js +++ b/vx/commands/test/test.js @@ -7,7 +7,7 @@ const vxPath = require('vx/vxPath'); const configOpt = `--config ${path.resolve( vxPath.JEST_CONFIG_PATH, - opts.fileNames.JEST_CONFIG + opts.fileNames.JEST_CONFIG, )}`; function test({ cliOptions }) { diff --git a/vx/config/jest/jest.config.js b/vx/config/jest/jest.config.js index 455e91d5d..4b19e3590 100644 --- a/vx/config/jest/jest.config.js +++ b/vx/config/jest/jest.config.js @@ -35,8 +35,6 @@ const projects = packageNames.list.map(packageName => ({ ], })); -console.log(projects); - module.exports = { projects, }; diff --git a/vx/config/jest/jest.setupAfterEnv.ts b/vx/config/jest/jest.setupAfterEnv.ts index 034ac71e4..69b4d5ecf 100644 --- a/vx/config/jest/jest.setupAfterEnv.ts +++ b/vx/config/jest/jest.setupAfterEnv.ts @@ -5,7 +5,7 @@ import './globals.d'; // eslint-disable-next-line complexity const isDeepCopyOf = ( source: any, - clone: any + clone: any, ): { pass: boolean; message: () => string } => { const queue = [[source, clone]]; @@ -29,7 +29,7 @@ const isDeepCopyOf = ( pass: false, message: () => `Source and clone are the same object. Expected a deep copy. ${JSON.stringify( - source + source, )}===${JSON.stringify(clone)}`, }; } @@ -44,7 +44,7 @@ const isDeepCopyOf = ( pass: false, message: () => `Source and clone are not of the same type: ${JSON.stringify( - source + source, )} does not equal ${JSON.stringify(clone)}`, }; } @@ -56,7 +56,7 @@ const isDeepCopyOf = ( pass: false, message: () => `source and clone arrays are not identical. ${JSON.stringify( - source + source, )} does not equal ${JSON.stringify(clone)}`, }; } diff --git a/vx/config/rollup/format.js b/vx/config/rollup/format.js index 2fa630b96..f8945b361 100644 --- a/vx/config/rollup/format.js +++ b/vx/config/rollup/format.js @@ -7,7 +7,7 @@ const format = [].concat( opts.format.CJS, opts.format.ES, opts.format.UMD, - ] + ], ); const disallowExternals = format === opts.format.UMD; diff --git a/vx/config/rollup/getPlugins.js b/vx/config/rollup/getPlugins.js index 1b982fb33..e4b9ddbe7 100644 --- a/vx/config/rollup/getPlugins.js +++ b/vx/config/rollup/getPlugins.js @@ -42,7 +42,7 @@ module.exports = function getPlugins({ packageName, opts.dir.TYPES, namespace, - moduleName + '.d.ts' + moduleName + '.d.ts', ); if (kind === 'declaration') return basePath; @@ -82,7 +82,7 @@ module.exports = function getPlugins({ terser(), handleExports({ namespace }), addModulePackageJson(), - addCJSPackageJson() + addCJSPackageJson(), ); } diff --git a/vx/config/rollup/plugins/addCJSPackageJson.js b/vx/config/rollup/plugins/addCJSPackageJson.js index e68e41019..0b1efb152 100644 --- a/vx/config/rollup/plugins/addCJSPackageJson.js +++ b/vx/config/rollup/plugins/addCJSPackageJson.js @@ -16,7 +16,7 @@ function addEsPackageJson() { const packageJsonPath = path.join( path.dirname(file), - opts.fileNames.PACKAGE_JSON + opts.fileNames.PACKAGE_JSON, ); if (fse.existsSync(packageJsonPath)) { diff --git a/vx/config/rollup/plugins/addModulePackageJson.js b/vx/config/rollup/plugins/addModulePackageJson.js index cbe3be09d..0a1d21030 100644 --- a/vx/config/rollup/plugins/addModulePackageJson.js +++ b/vx/config/rollup/plugins/addModulePackageJson.js @@ -16,7 +16,7 @@ function addEsPackageJson() { const packageJsonPath = path.join( path.dirname(file), - opts.fileNames.PACKAGE_JSON + opts.fileNames.PACKAGE_JSON, ); if (fse.existsSync(packageJsonPath)) { diff --git a/vx/config/rollup/plugins/handleExports.js b/vx/config/rollup/plugins/handleExports.js index 0d5ce6a75..22b992d62 100644 --- a/vx/config/rollup/plugins/handleExports.js +++ b/vx/config/rollup/plugins/handleExports.js @@ -41,12 +41,12 @@ function writeEntry(name, namespace) { if (process.env.NODE_ENV === '${opts.env.PRODUCTION}') { module.exports = require('${prefix}/${path.relative( dist(), - dist(exportName(name, opts.env.PRODUCTION)) + dist(exportName(name, opts.env.PRODUCTION)), )}'); } else { module.exports = require('${prefix}/${path.relative( dist(), - dist(exportName(name, opts.env.DEVELOPMENT)) + dist(exportName(name, opts.env.DEVELOPMENT)), )}'); }`; @@ -77,7 +77,7 @@ function writePackageJson(name, exportPath, { namespace } = {}) { pkgJson, { spaces: 2, - } + }, ); } @@ -183,7 +183,7 @@ function genExportedFilesInMainPackageJson() { currentModule, genMainPackageJSONFileExports(moduleName, { namespace, - }) + }), ); return modules; @@ -192,7 +192,7 @@ function genExportedFilesInMainPackageJson() { function genMainPackageJSONFileExports( moduleName, - { env = opts.env.PRODUCTION, namespace = undefined } + { env = opts.env.PRODUCTION, namespace = undefined }, ) { const prefix = '.'; const cjsPath = genDistPath(moduleName, { @@ -261,7 +261,7 @@ function genDistPath( env = opts.env.PRODUCTION, format = opts.format.CJS, prefix, - } + }, ) { return joinPath( // add nesting level @@ -271,7 +271,7 @@ function genDistPath( format, namespace, exportName(moduleName, env), - ]) + ]), ); } @@ -283,7 +283,7 @@ function genTypesPath(moduleName, { namespace = undefined, prefix }) { opts.dir.TYPES, namespace, fileName(moduleName, 'd.ts'), - ]) + ]), ); } diff --git a/vx/exec.js b/vx/exec.js index df7017e51..52e13c1d8 100644 --- a/vx/exec.js +++ b/vx/exec.js @@ -12,7 +12,7 @@ function exec( throwOnFailure = false, silent = false, raw = false, - } = {} + } = {}, ) { const cmd = joinTruthy(command?.flat?.() ?? command, ' '); diff --git a/vx/packageExports.js b/vx/packageExports.js index 09f730905..e1146942f 100644 --- a/vx/packageExports.js +++ b/vx/packageExports.js @@ -12,5 +12,5 @@ module.exports = packageNames.list.reduce( .sync(vxPath.packageSrcExports(packageName, '*.ts')) .map(packageExport => path.basename(packageExport, '.ts')), }), - {} + {}, ); diff --git a/vx/packageNames.js b/vx/packageNames.js index 6e41cfb42..8d7516a33 100644 --- a/vx/packageNames.js +++ b/vx/packageNames.js @@ -16,7 +16,7 @@ module.exports = Object.defineProperty( get: () => { return usePackage(); }, - } + }, ); packageList.pairs.forEach(([name, path]) => { diff --git a/vx/scripts/release/depsTree.js b/vx/scripts/release/depsTree.js index e1cf50bb3..af8501c6a 100644 --- a/vx/scripts/release/depsTree.js +++ b/vx/scripts/release/depsTree.js @@ -25,7 +25,7 @@ const buildDepsMemo = memoize(function (package, deps) { function buildDepsTree() { return packageList.names.reduce( (deps, packageName) => buildDepsMemo(packageName, deps), - {} + {}, ); } @@ -34,7 +34,7 @@ function sortDependencies(packagesList) { const deps = buildDepsTree(); return packagesList.sort( - (a, b) => countMaxDepth(deps[b]) - countMaxDepth(deps[a]) + (a, b) => countMaxDepth(deps[b]) - countMaxDepth(deps[a]), ); } diff --git a/vx/scripts/release/genDiffData.js b/vx/scripts/release/genDiffData.js index 39cb8f742..bf9a003bf 100644 --- a/vx/scripts/release/genDiffData.js +++ b/vx/scripts/release/genDiffData.js @@ -36,8 +36,8 @@ function genDiffData(commits) { versionToPublish: isReleaseKeepVersionBranch ? version : tag - ? tagId - : nextVersion, + ? tagId + : nextVersion, }; } diff --git a/vx/scripts/release/github/commitIgnorePattern.js b/vx/scripts/release/github/commitIgnorePattern.js index 6683bfc39..450b48458 100644 --- a/vx/scripts/release/github/commitIgnorePattern.js +++ b/vx/scripts/release/github/commitIgnorePattern.js @@ -1,7 +1,7 @@ const IGNORE_KEYWORDS = ['docs', 'conf', 'ci', 'build']; const IGNORE_PATTERN = new RegExp( `${IGNORE_KEYWORDS.join('|')}:|dependabot`, - 'i' + 'i', ); module.exports = IGNORE_PATTERN; diff --git a/vx/scripts/release/packagesToRelease.js b/vx/scripts/release/packagesToRelease.js index 50a3e3fb3..7a6b00238 100644 --- a/vx/scripts/release/packagesToRelease.js +++ b/vx/scripts/release/packagesToRelease.js @@ -30,8 +30,8 @@ function packagesToRelease() { } else { logger.info( `💡 The following packages were changed: \n - ${changedPackagesArray.join( - '\n - ' - )}\n` + '\n - ', + )}\n`, ); } @@ -59,7 +59,7 @@ function packagesToRelease() { logger.info( `🧱 The following packages did not change, but will be released because they are indirectly impacted by changes: \n - ${[ ...unchangedDependents, - ].join('\n - ')} \n` + ].join('\n - ')} \n`, ); } @@ -67,8 +67,8 @@ function packagesToRelease() { logger.info( `✅ The packages will be released in the following order: \n - ${allPackagesToRelease.join( - '\n - ' - )}\n` + '\n - ', + )}\n`, ); return { diff --git a/vx/scripts/release/steps/commitChangesToGit.js b/vx/scripts/release/steps/commitChangesToGit.js index ceea105d3..7b69eee4d 100644 --- a/vx/scripts/release/steps/commitChangesToGit.js +++ b/vx/scripts/release/steps/commitChangesToGit.js @@ -15,12 +15,12 @@ const vxPath = require('vx/vxPath'); const RELEASE_SCRIPTS = path.resolve( vxPath.VX_SCRIPTS_PATH, 'release', - 'steps' + 'steps', ); const PUSH_TO_LATEST_BRANCH = path.resolve( RELEASE_SCRIPTS, - 'push_to_latest_branch.sh' + 'push_to_latest_branch.sh', ); const CREATE_GIT_TAG = path.resolve(RELEASE_SCRIPTS, 'create_git_tag.sh'); @@ -66,7 +66,7 @@ function filterChangedPackages(commits) { function createCommitMessage(changedPackages) { const msg = changedPackages .map( - packageName => `[${packageName}]: (${packageJson(packageName).version})` + packageName => `[${packageName}]: (${packageJson(packageName).version})`, ) .join(', '); diff --git a/vx/scripts/release/steps/publishPackage.js b/vx/scripts/release/steps/publishPackage.js index 07374604b..a2b1ad503 100644 --- a/vx/scripts/release/steps/publishPackage.js +++ b/vx/scripts/release/steps/publishPackage.js @@ -41,14 +41,14 @@ function execCommandWithGitConfig(command) { logger.info( `Setting git config: Email "${EMAIL_ADDRESS}" - Name "${GIT_NAME}"` + Name "${GIT_NAME}"`, ); exec( `git config --global user.email "${EMAIL_ADDRESS}" git config --global user.name "${GIT_NAME}" ${joinTruthy(command, ' ')}`, - { exitOnFailure: false } + { exitOnFailure: false }, ); } diff --git a/vx/scripts/release/steps/setNextVersion.js b/vx/scripts/release/steps/setNextVersion.js index 15aa8fd52..028cbe434 100644 --- a/vx/scripts/release/steps/setNextVersion.js +++ b/vx/scripts/release/steps/setNextVersion.js @@ -27,7 +27,7 @@ function setNextVersion({ changeLevel: ${changeLevel} tagId: ${tagId} tag: ${tag} - versionToPublish: ${versionToPublish}` + versionToPublish: ${versionToPublish}`, ); return; } @@ -39,7 +39,7 @@ function setNextVersion({ existingPkgJson.version = versionToPublish; logger.info( - `🔢 Setting next version for ${usePackage()}. From ${prevVersion} to ${versionToPublish}` + `🔢 Setting next version for ${usePackage()}. From ${prevVersion} to ${versionToPublish}`, ); writeJSONSync(vxPath.packageJson(packageName), nextPackageJson, { @@ -50,7 +50,7 @@ function setNextVersion({ if (updated.version !== versionToPublish) { logger.error( - `🚨 Failed to update ${usePackage()} version to: ` + versionToPublish + `🚨 Failed to update ${usePackage()} version to: ` + versionToPublish, ); return process.exit(1); } diff --git a/vx/scripts/release/steps/updateLocalDepsToLatest.js b/vx/scripts/release/steps/updateLocalDepsToLatest.js index d37cbb2ad..1f64239f8 100644 --- a/vx/scripts/release/steps/updateLocalDepsToLatest.js +++ b/vx/scripts/release/steps/updateLocalDepsToLatest.js @@ -38,8 +38,8 @@ module.exports = function updateLocalDepsToLatest() { deps[name] = isNextBranch ? TAG_NEXT : isIntegrationBranch - ? TAG_DEV - : depPkgJson.version; + ? TAG_DEV + : depPkgJson.version; } else { deps[name] = isNextBranch || isIntegrationBranch diff --git a/vx/util/pathsPerPackage.js b/vx/util/pathsPerPackage.js index cd024647e..fe7908c4b 100644 --- a/vx/util/pathsPerPackage.js +++ b/vx/util/pathsPerPackage.js @@ -65,11 +65,11 @@ function findDuplicates() { const duplicatesPerPackage = []; for (const [packageName, { duplicates }] of Object.entries( - duplicatesContainer + duplicatesContainer, )) { if (duplicates.size > 0) { duplicatesPerPackage.push( - `${packageName}: ${[...duplicates].map(dup => `\n -${dup}`).join('')}` + `${packageName}: ${[...duplicates].map(dup => `\n -${dup}`).join('')}`, ); } } @@ -77,8 +77,8 @@ function findDuplicates() { if (duplicatesPerPackage.length > 0) { throw new Error( `VX: Duplicates found in the following packages:\n\n${duplicatesPerPackage.join( - '\n' - )}\n` + '\n', + )}\n`, ); } } diff --git a/vx/util/rootPackageJson.js b/vx/util/rootPackageJson.js index df0a33c3e..816640901 100644 --- a/vx/util/rootPackageJson.js +++ b/vx/util/rootPackageJson.js @@ -8,7 +8,7 @@ function rootPackageJson() { // Manually reading it instead of requiring to avoid caching const jsonString = fs.readFileSync( path.join(vxPath.ROOT_PATH, opts.fileNames.PACKAGE_JSON), - 'utf8' + 'utf8', ); return JSON.parse(jsonString); } diff --git a/vx/util/runOnActivePackages.js b/vx/util/runOnActivePackages.js index d12c60971..19edd4336 100644 --- a/vx/util/runOnActivePackages.js +++ b/vx/util/runOnActivePackages.js @@ -10,6 +10,6 @@ module.exports = (callback, ...args) => { return callback(...args); } packages.list.forEach(packageName => - ctx.withPackage(packageName, () => callback(...args)) + ctx.withPackage(packageName, () => callback(...args)), ); }; diff --git a/vx/util/taggedBranch.js b/vx/util/taggedBranch.js index 89bf82114..162df56ca 100644 --- a/vx/util/taggedBranch.js +++ b/vx/util/taggedBranch.js @@ -17,7 +17,7 @@ const isLatestBranch = CURRENT_BRANCH.startsWith(LATEST_BRANCH); const isStableBranch = CURRENT_BRANCH.startsWith(STABLE_BRANCH); const isReleaseBranch = CURRENT_BRANCH.startsWith(RELEASE_BRANCH); const isReleaseKeepVersionBranch = CURRENT_BRANCH.startsWith( - RELEASE_KEEP_VERSION_BRANCH + RELEASE_KEEP_VERSION_BRANCH, ); const [, target = undefined] = isIntegrationBranch || isNextBranch || isNightlyBranch diff --git a/vx/vxPath.js b/vx/vxPath.js index 7e132b6ea..5bb6080d6 100644 --- a/vx/vxPath.js +++ b/vx/vxPath.js @@ -27,7 +27,7 @@ vxPath.packageNameFromPath = pathSegment => { const packagesPosition = pathSegment.indexOf(opts.dir.PACKAGES); // 2 const withoutDir = pathSegment.substring( - packagesPosition + opts.dir.PACKAGES.length + packagesPosition + opts.dir.PACKAGES.length, ); // /vest/src/core/isolate/isolates/skipWhen.ts return withoutDir.split(path.sep)[1]; //vest }; @@ -106,19 +106,19 @@ vxPath.VX_COMMANDS_PATH = path.resolve(vxPath.VX_ROOT_PATH, opts.dir.COMMANDS); vxPath.ROLLUP_CONFIG_PATH = path.resolve( vxPath.VX_CONFIG_PATH, opts.dir.ROLLUP, - opts.fileNames.ROLLUP_CONFIG + opts.fileNames.ROLLUP_CONFIG, ); vxPath.JEST_CONFIG_PATH = path.resolve(vxPath.VX_CONFIG_PATH, opts.dir.JEST); vxPath.JEST_CONFIG_FILE_PATH = path.resolve( vxPath.JEST_CONFIG_PATH, - opts.fileNames.JEST_CONFIG + opts.fileNames.JEST_CONFIG, ); vxPath.TSCONFIG_PATH = path.resolve( vxPath.ROOT_PATH, - opts.fileNames.TSCONFIG_JSON + opts.fileNames.TSCONFIG_JSON, ); vxPath.PACKAGES_PATH = path.resolve(vxPath.ROOT_PATH, opts.dir.PACKAGES); diff --git a/website/docs/enforce/builtin-enforce-plugins/compound_rules.md b/website/docs/enforce/builtin-enforce-plugins/compound_rules.md index f14169e75..ede1dc9d2 100644 --- a/website/docs/enforce/builtin-enforce-plugins/compound_rules.md +++ b/website/docs/enforce/builtin-enforce-plugins/compound_rules.md @@ -48,7 +48,7 @@ enforce.oneOf can be used to determine if _exactly_ one of the rules applies. It enforce(value).oneOf( enforce.isString(), enforce.isNumber(), - enforce.longerThan(1) + enforce.longerThan(1), ); /* diff --git a/website/docs/enforce/builtin-enforce-plugins/schema_rules.md b/website/docs/enforce/builtin-enforce-plugins/schema_rules.md index 983ba1c70..221a48c47 100644 --- a/website/docs/enforce/builtin-enforce-plugins/schema_rules.md +++ b/website/docs/enforce/builtin-enforce-plugins/schema_rules.md @@ -105,7 +105,7 @@ enforce({}).shape( partial({ firstName: enforce.isString(), lastName: enforce.isString(), - }) + }), ); ``` diff --git a/website/docs/enforce/composing_enforce_rules.md b/website/docs/enforce/composing_enforce_rules.md index 02fcf669f..d74e5a432 100644 --- a/website/docs/enforce/composing_enforce_rules.md +++ b/website/docs/enforce/composing_enforce_rules.md @@ -45,8 +45,8 @@ enforce(userObj).shape({ middle: enforce.optional(enforce.string()), last: enforce.string(), }), - }) - ) + }), + ), ), }); ``` @@ -60,7 +60,7 @@ import 'vest/enforce/schema'; // for the schema rules const Entity = compose( enforce.loose({ id: enforce.number(), - }) + }), ); const Person = compose( @@ -70,7 +70,7 @@ const Person = compose( middle: enforce.optional(enforce.string()), last: enforce.string(), }), - }) + }), ); const User = compose( @@ -79,7 +79,7 @@ const User = compose( enforce.loose({ username: enforce.string(), friends: enforce.optional(enforce.arrayOf(User)), - }) + }), ); ``` diff --git a/website/docs/writing_tests/advanced_test_features/dynamic_tests.md b/website/docs/writing_tests/advanced_test_features/dynamic_tests.md index 279eb562c..8926f5a2f 100644 --- a/website/docs/writing_tests/advanced_test_features/dynamic_tests.md +++ b/website/docs/writing_tests/advanced_test_features/dynamic_tests.md @@ -48,7 +48,7 @@ const suite = create((data = {}) => { () => { enforce(field.price).isNumeric().greaterThan(0); }, - field.id // the key is used to guarantee state persistence on reordering + field.id, // the key is used to guarantee state persistence on reordering ); }); }); diff --git a/website/docs/writing_tests/advanced_test_features/grouping_tests.md b/website/docs/writing_tests/advanced_test_features/grouping_tests.md index 3af0b0563..623a2fbc6 100644 --- a/website/docs/writing_tests/advanced_test_features/grouping_tests.md +++ b/website/docs/writing_tests/advanced_test_features/grouping_tests.md @@ -63,7 +63,7 @@ create(data => { test( 'userName', 'User not found. Please check if you typed it correctly.', - findUserName(data.username) + findUserName(data.username), ); }); @@ -150,13 +150,13 @@ const suite = create(data => { 'promo code purchases are limited to one item only', () => { enforce(data.quantity).equals(1); - } + }, ); test( 'promoCode', 'Promo code can only be used once', - isPromoCodeUsed(data.usedPromo) + isPromoCodeUsed(data.usedPromo), ); }); }); diff --git a/website/docs/writing_tests/advanced_test_features/test.memo.md b/website/docs/writing_tests/advanced_test_features/test.memo.md index fd20757f0..884b0ac86 100644 --- a/website/docs/writing_tests/advanced_test_features/test.memo.md +++ b/website/docs/writing_tests/advanced_test_features/test.memo.md @@ -28,7 +28,7 @@ export default create(data => { 'username', 'username already exists', () => doesUserExist(data.username), - [data.username] + [data.username], ); }); ``` diff --git a/website/docs/writing_tests/warn_only_tests.md b/website/docs/writing_tests/warn_only_tests.md index 6e673e15d..3d66e2d89 100644 --- a/website/docs/writing_tests/warn_only_tests.md +++ b/website/docs/writing_tests/warn_only_tests.md @@ -23,7 +23,7 @@ const suite = create(data => { warn(); enforce(data.password).matches( - /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]$/ + /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]$/, ); }); // this test has a severity level of `warn` @@ -31,7 +31,7 @@ const suite = create(data => { warn(); enforce(data.password).matches( - /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]$/ + /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]$/, ); }); // this test has a severity level of `warn` }); diff --git a/website/docs/writing_your_suite/including_and_excluding/omitWhen.md b/website/docs/writing_your_suite/including_and_excluding/omitWhen.md index ace08d6c7..6c0e8bbe6 100644 --- a/website/docs/writing_your_suite/including_and_excluding/omitWhen.md +++ b/website/docs/writing_your_suite/including_and_excluding/omitWhen.md @@ -72,7 +72,7 @@ omitWhen( // this is an example for a server call return doesUserExist(data.username); }); - } + }, ); ``` @@ -98,6 +98,7 @@ omitWhen( 'You need at least one option', ); ``` + :::caution IMPORTANT The code within omitWhen will always run, regardless of whether the condition is met or not. `omitWhen` only affects the validation result, but if you call a function within `omitWhen`, it will run regardless of the condition. @@ -107,4 +108,4 @@ omitWhen(true, () => { }); ``` -::: \ No newline at end of file +::: diff --git a/website/docs/writing_your_suite/including_and_excluding/skipWhen.md b/website/docs/writing_your_suite/including_and_excluding/skipWhen.md index dd92d7f31..37f760cdb 100644 --- a/website/docs/writing_your_suite/including_and_excluding/skipWhen.md +++ b/website/docs/writing_your_suite/including_and_excluding/skipWhen.md @@ -44,7 +44,7 @@ export default create((data = {}) => { // this is an example for a server call return doesUserExist(data.username); }); - } + }, ); }); ``` diff --git a/website/docs/writing_your_suite/optional_fields.md b/website/docs/writing_your_suite/optional_fields.md index 93f9ab7f1..a174e9274 100644 --- a/website/docs/writing_your_suite/optional_fields.md +++ b/website/docs/writing_your_suite/optional_fields.md @@ -126,7 +126,7 @@ const suite = create(data => { 'Pet Name may be left empty only if owner name is supplied', () => { enforce(data.pet_name).isNotEmpty(); - } + }, ); test( @@ -134,7 +134,7 @@ const suite = create(data => { 'Owner Name may be left empty only if pet name is supplied', () => { enforce(data.owner_name).isNotEmpty(); - } + }, ); }); ``` diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 348312d0e..ba94e8431 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -124,7 +124,7 @@ const config = { value: badgeLink( 'https://www.npmjs.com/package/vest', 'https://badgen.net/npm/v/vest?icon=npm&scale=1.2&color=red&label', - 'npm-badge' + 'npm-badge', ), }, { @@ -133,7 +133,7 @@ const config = { value: badgeLink( 'https://github.com/ealush/vest', 'https://badgen.net/github/stars/ealush/vest?scale=1.2&color=yellow&icon=github', - 'github-badge' + 'github-badge', ), }, { @@ -142,7 +142,7 @@ const config = { value: badgeLink( 'https://discord.gg/WmADZpJnSe', 'https://badgen.net/discord/online-members/WmADZpJnSe?icon=discord&scale=1.2&label=Discord', - 'discord-badge' + 'discord-badge', ), }, { diff --git a/website/versioned_docs/version-4.x/enforce/builtin-enforce-plugins/compound_rules.md b/website/versioned_docs/version-4.x/enforce/builtin-enforce-plugins/compound_rules.md index 8abab9539..93ad2ccbf 100644 --- a/website/versioned_docs/version-4.x/enforce/builtin-enforce-plugins/compound_rules.md +++ b/website/versioned_docs/version-4.x/enforce/builtin-enforce-plugins/compound_rules.md @@ -48,7 +48,7 @@ enforce.oneOf can be used to determine if _exactly_ one of the rules applies. It enforce(value).oneOf( enforce.isString(), enforce.isNumber(), - enforce.longerThan(1) + enforce.longerThan(1), ); /* diff --git a/website/versioned_docs/version-4.x/enforce/builtin-enforce-plugins/schema_rules.md b/website/versioned_docs/version-4.x/enforce/builtin-enforce-plugins/schema_rules.md index aa556e0f3..791a1835b 100644 --- a/website/versioned_docs/version-4.x/enforce/builtin-enforce-plugins/schema_rules.md +++ b/website/versioned_docs/version-4.x/enforce/builtin-enforce-plugins/schema_rules.md @@ -105,7 +105,7 @@ enforce({}).shape( partial({ firstName: enforce.isString(), lastName: enforce.isString(), - }) + }), ); ``` diff --git a/website/versioned_docs/version-4.x/enforce/composing_enforce_rules.md b/website/versioned_docs/version-4.x/enforce/composing_enforce_rules.md index 02fcf669f..d74e5a432 100644 --- a/website/versioned_docs/version-4.x/enforce/composing_enforce_rules.md +++ b/website/versioned_docs/version-4.x/enforce/composing_enforce_rules.md @@ -45,8 +45,8 @@ enforce(userObj).shape({ middle: enforce.optional(enforce.string()), last: enforce.string(), }), - }) - ) + }), + ), ), }); ``` @@ -60,7 +60,7 @@ import 'vest/enforce/schema'; // for the schema rules const Entity = compose( enforce.loose({ id: enforce.number(), - }) + }), ); const Person = compose( @@ -70,7 +70,7 @@ const Person = compose( middle: enforce.optional(enforce.string()), last: enforce.string(), }), - }) + }), ); const User = compose( @@ -79,7 +79,7 @@ const User = compose( enforce.loose({ username: enforce.string(), friends: enforce.optional(enforce.arrayOf(User)), - }) + }), ); ``` diff --git a/website/versioned_docs/version-4.x/upgrade_guide.md b/website/versioned_docs/version-4.x/upgrade_guide.md index bf752e27f..7ff3a5829 100644 --- a/website/versioned_docs/version-4.x/upgrade_guide.md +++ b/website/versioned_docs/version-4.x/upgrade_guide.md @@ -72,7 +72,7 @@ skipWhen( test('confirm', 'passwords do not match', () => { /*...*/ }); - } + }, ); // ... @@ -104,7 +104,7 @@ each(fields, field => { () => { enforce(field.value).isNotEmpty(); }, - field.id + field.id, ); }); ``` @@ -191,7 +191,7 @@ const suite = create('user_form', () => { res => res.hasErrors('username'), () => { /* ... */ - } + }, ); }); ``` diff --git a/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/dynamic_tests.md b/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/dynamic_tests.md index 279eb562c..8926f5a2f 100644 --- a/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/dynamic_tests.md +++ b/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/dynamic_tests.md @@ -48,7 +48,7 @@ const suite = create((data = {}) => { () => { enforce(field.price).isNumeric().greaterThan(0); }, - field.id // the key is used to guarantee state persistence on reordering + field.id, // the key is used to guarantee state persistence on reordering ); }); }); diff --git a/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/grouping_tests.md b/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/grouping_tests.md index a17312d4a..2b143b15b 100644 --- a/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/grouping_tests.md +++ b/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/grouping_tests.md @@ -29,7 +29,7 @@ create(data => { test( 'userName', 'User not found. Please check if you typed it correctly.', - findUserName(data.username) + findUserName(data.username), ); }); @@ -107,7 +107,7 @@ const suite = create(data => { test( 'balance', 'Balance is lower than product price', - hasSufficientFunds(data.productId) + hasSufficientFunds(data.productId), ); test('quantity', `Quantity on this item is limited to ${data.limit}`, () => { @@ -120,13 +120,13 @@ const suite = create(data => { 'promo code purchases are limited to one item only', () => { enforce(data.quantity).equals(1); - } + }, ); test( 'promoCode', 'Promo code can only be used once', - isPromoCodeUsed(data.usedPromo) + isPromoCodeUsed(data.usedPromo), ); }); }); diff --git a/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/test.memo.md b/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/test.memo.md index fd20757f0..884b0ac86 100644 --- a/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/test.memo.md +++ b/website/versioned_docs/version-4.x/writing_tests/advanced_test_features/test.memo.md @@ -28,7 +28,7 @@ export default create(data => { 'username', 'username already exists', () => doesUserExist(data.username), - [data.username] + [data.username], ); }); ``` diff --git a/website/versioned_docs/version-4.x/writing_tests/warn_only_tests.md b/website/versioned_docs/version-4.x/writing_tests/warn_only_tests.md index 3b761ebed..ddeeac92e 100644 --- a/website/versioned_docs/version-4.x/writing_tests/warn_only_tests.md +++ b/website/versioned_docs/version-4.x/writing_tests/warn_only_tests.md @@ -23,7 +23,7 @@ const suite = create(data => { warn(); enforce(data.password).matches( - /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]$/ + /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]$/, ); }); // this test has a severity level of `warn` @@ -31,7 +31,7 @@ const suite = create(data => { warn(); enforce(data.password).matches( - /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]$/ + /^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]$/, ); }); // this test has a severity level of `warn` }); diff --git a/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/omitWhen.md b/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/omitWhen.md index c44a9d879..9f07b7302 100644 --- a/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/omitWhen.md +++ b/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/omitWhen.md @@ -62,6 +62,6 @@ omitWhen( // this is an example for a server call return doesUserExist(data.username); }); - } + }, ); ``` diff --git a/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/skipWhen.md b/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/skipWhen.md index c3d5a488e..85aa281e1 100644 --- a/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/skipWhen.md +++ b/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/skipWhen.md @@ -42,7 +42,7 @@ export default create((data = {}) => { // this is an example for a server call return doesUserExist(data.username); }); - } + }, ); }); ``` diff --git a/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/skip_and_only_group.md b/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/skip_and_only_group.md index 87124d607..ea98f2eb0 100644 --- a/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/skip_and_only_group.md +++ b/website/versioned_docs/version-4.x/writing_your_suite/including_and_excluding/skip_and_only_group.md @@ -28,7 +28,7 @@ create(data => { test( 'userName', 'User not found. Please check if you typed it correctly.', - findUserName(data.username) + findUserName(data.username), ); }); diff --git a/website/versioned_docs/version-4.x/writing_your_suite/optional_fields.md b/website/versioned_docs/version-4.x/writing_your_suite/optional_fields.md index 74177becb..112e080c1 100644 --- a/website/versioned_docs/version-4.x/writing_your_suite/optional_fields.md +++ b/website/versioned_docs/version-4.x/writing_your_suite/optional_fields.md @@ -96,7 +96,7 @@ const suite = create(data => { 'Pet Name may be left empty only if owner name is supplied', () => { enforce(data.pet_name).isNotEmpty(); - } + }, ); test( @@ -104,7 +104,7 @@ const suite = create(data => { 'Owner Name may be left empty only if pet name is supplied', () => { enforce(data.owner_name).isNotEmpty(); - } + }, ); }); ``` diff --git a/website/versioned_docs/version-4.x/writing_your_suite/result_object.md b/website/versioned_docs/version-4.x/writing_your_suite/result_object.md index 99d15689d..c01cb421d 100644 --- a/website/versioned_docs/version-4.x/writing_your_suite/result_object.md +++ b/website/versioned_docs/version-4.x/writing_your_suite/result_object.md @@ -230,13 +230,13 @@ const suite = create(data => { test( 'UserEmail', 'Marked as spam address', - async () => await isKnownSpammer(data.address) + async () => await isKnownSpammer(data.address), ); test( 'UserName', 'must not be blacklisted', - async () => await isBlacklistedUser(data.username) + async () => await isBlacklistedUser(data.username), ); }); From 80594f0f6cbf9ff437200447a2c902d4c2af0580 Mon Sep 17 00:00:00 2001 From: ealush Date: Sat, 27 Jul 2024 03:06:53 +0300 Subject: [PATCH 03/16] fix anyone --- packages/anyone/src/anyone.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/anyone/src/anyone.ts b/packages/anyone/src/anyone.ts index 760c1eae3..9056a27ed 100644 --- a/packages/anyone/src/anyone.ts +++ b/packages/anyone/src/anyone.ts @@ -1,4 +1,4 @@ -export { default as all } from 'all'; -export { default as any } from 'any'; -export { default as none } from 'none'; -export { default as one } from 'one'; +export { default as all } from '@/exports/all'; +export { default as any } from '@/exports/any'; +export { default as none } from '@/exports/none'; +export { default as one } from '@/exports/one'; From d82873d7b866abff9eb791d8b676cc3769f198c9 Mon Sep 17 00:00:00 2001 From: ealush Date: Sat, 27 Jul 2024 03:53:40 +0300 Subject: [PATCH 04/16] Current state is not workingpp --- vitest.config.ts | 3 +++ vitest.workspace.ts | 1 + 2 files changed, 4 insertions(+) create mode 100644 vitest.workspace.ts diff --git a/vitest.config.ts b/vitest.config.ts index e586ae0a2..1a98232c6 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -4,9 +4,12 @@ import { defineConfig } from 'vitest/config'; export default defineConfig({ test: { globals: true, + include: ['packages/*/**/__tests__/*.test.ts'], }, + root: __dirname, plugins: [ tsconfigPaths({ + loose: true, projects: [ 'packages/vest', 'packages/n4s', diff --git a/vitest.workspace.ts b/vitest.workspace.ts new file mode 100644 index 000000000..a971dee23 --- /dev/null +++ b/vitest.workspace.ts @@ -0,0 +1 @@ +export default ['packages/*']; From ebbb627c3a57d0faad374c89e787c9aee21fd309 Mon Sep 17 00:00:00 2001 From: ealush Date: Sat, 27 Jul 2024 16:19:37 +0300 Subject: [PATCH 05/16] vest-utils --- .eslintrc.js | 1 + .../context/src/__tests__/cascade.test.ts | 10 +-- .../src/rules/__tests__/ruleCondition.test.ts | 2 +- .../runtime/__tests__/enforceContext.test.ts | 4 +- .../n4s/src/runtime/__tests__/message.test.ts | 4 +- packages/vast/src/__tests__/vast.test.ts | 10 +-- .../src/__tests__/Predicates.test.ts | 4 +- .../vest-utils/src/__tests__/bindNot.test.ts | 8 +- packages/vest-utils/src/__tests__/bus.test.ts | 34 ++++----- .../vest-utils/src/__tests__/cache.test.ts | 8 +- .../vest-utils/src/__tests__/callEach.test.ts | 6 +- .../src/__tests__/defaultTo.test.ts | 6 +- .../src/__tests__/deferThrow.test.ts | 4 +- .../src/__tests__/invariant.test.ts | 2 +- .../vest-utils/src/__tests__/isEmpty.test.ts | 2 +- .../vest-utils/src/__tests__/mapFirst.test.ts | 2 +- .../__tests__/optionalFunctionValue.test.ts | 6 +- .../vest-utils/src/exports/minifyObject.ts | 2 +- .../__tests__/integration.async-tests.test.ts | 18 ++--- .../src/__tests__/integration.base.test.ts | 4 +- .../integration.stateful-async.test.ts | 22 +++--- .../integration.stateful-tests.test.ts | 2 +- packages/vest/src/__tests__/isolate.test.ts | 4 +- .../__tests__/hasRemainingTests.test.ts | 3 +- .../core/test/__tests__/IsolateTest.test.ts | 4 +- .../vest/src/core/test/__tests__/memo.test.ts | 8 +- .../merging_of_previous_test_runs.test.ts | 2 +- .../core/test/__tests__/runAsyncTest.test.ts | 18 ++--- .../vest/src/core/test/__tests__/test.test.ts | 4 +- .../__tests__/testFunctionPayload.test.ts | 14 ++-- .../vest/src/hooks/__tests__/include.test.ts | 18 ++--- .../vest/src/hooks/__tests__/warn.test.ts | 2 +- .../hooks/optional/__tests__/optional.test.ts | 4 +- .../vest/src/isolates/__tests__/each.test.ts | 4 +- .../vest/src/isolates/__tests__/group.test.ts | 74 +++++++++---------- .../src/isolates/__tests__/omitWhen.test.ts | 20 ++--- .../src/isolates/__tests__/skipWhen.test.ts | 8 +- .../vest/src/suite/__tests__/create.test.ts | 16 ++-- .../src/suite/__tests__/subscribe.test.ts | 4 +- .../suiteResult/done/__tests__/done.test.ts | 36 ++++----- .../src/Isolate/__tests__/Isolate.test.ts | 2 +- .../Isolate/__tests__/IsolateMutator.test.ts | 4 +- .../Isolate/__tests__/asyncIsolate.test.ts | 2 +- tsconfig.json | 3 +- vx/scripts/genTsConfig.js | 1 + 45 files changed, 209 insertions(+), 207 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 5e966ce44..ad9f758b7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -16,6 +16,7 @@ module.exports = { __DEV__: true, __LIB_VERSION__: true, ENV_DEVELOPMENT: true, + vi: true, }, ignorePatterns: ['*.d.ts', '/website/'], overrides: [ diff --git a/packages/context/src/__tests__/cascade.test.ts b/packages/context/src/__tests__/cascade.test.ts index 663f83253..412b2bae8 100644 --- a/packages/context/src/__tests__/cascade.test.ts +++ b/packages/context/src/__tests__/cascade.test.ts @@ -141,7 +141,7 @@ describe('Cascading Context', () => { describe('context.bind', () => { it('Returns a function', () => { - expect(typeof ctx.bind({}, jest.fn())).toBe('function'); + expect(typeof ctx.bind({}, vi.fn())).toBe('function'); }); it('Wraps the function with context', () => { @@ -160,7 +160,7 @@ describe('Cascading Context', () => { }); it('Passes runtime arguments to bound function', () => { - const fn = jest.fn(); + const fn = vi.fn(); const args = Array.from({ length: 100 }, (_, i) => `${i}`); // 1-100 ctx.bind({}, fn)(...args); @@ -269,7 +269,7 @@ describe('Cascading Context', () => { describe('init argument', () => { it('Should run init function on every context.run', () => { - const init = jest.fn(); + const init = vi.fn(); const ctx = createCascade(init); @@ -293,7 +293,7 @@ describe('Cascading Context', () => { }); it('Should accept ctxRef as first argument', () => { - const init = jest.fn(); + const init = vi.fn(); const ctx = createCascade(init); const ref1 = { a: 1, b: 2 }; @@ -307,7 +307,7 @@ describe('Cascading Context', () => { }); it('Should accept parentContext as second argument', () => { - const init = jest.fn(); + const init = vi.fn(); const ctx = createCascade(init); let p1; diff --git a/packages/n4s/src/rules/__tests__/ruleCondition.test.ts b/packages/n4s/src/rules/__tests__/ruleCondition.test.ts index 29af80c74..4720dcf68 100644 --- a/packages/n4s/src/rules/__tests__/ruleCondition.test.ts +++ b/packages/n4s/src/rules/__tests__/ruleCondition.test.ts @@ -3,7 +3,7 @@ import ruleReturn, { failing, passing } from '@/lib/ruleReturn'; describe('enforce.condition', () => { it('Should pass down enforced value to condition as the first argument', () => { - const condition = jest.fn(() => true); + const condition = vi.fn(() => true); enforce(1).condition(condition); expect(condition).toHaveBeenCalledWith(1); diff --git a/packages/n4s/src/runtime/__tests__/enforceContext.test.ts b/packages/n4s/src/runtime/__tests__/enforceContext.test.ts index a31f80d6c..9e89125d2 100644 --- a/packages/n4s/src/runtime/__tests__/enforceContext.test.ts +++ b/packages/n4s/src/runtime/__tests__/enforceContext.test.ts @@ -3,11 +3,11 @@ import * as ruleReturn from '@/lib/ruleReturn'; import 'schema'; import 'compounds'; -let keepContext = jest.fn(); +let keepContext = vi.fn(); describe('enforce.context', () => { beforeEach(() => { - keepContext = jest.fn(); + keepContext = vi.fn(); }); describe('base structure', () => { diff --git a/packages/n4s/src/runtime/__tests__/message.test.ts b/packages/n4s/src/runtime/__tests__/message.test.ts index 6d1fc3925..597dd23a5 100644 --- a/packages/n4s/src/runtime/__tests__/message.test.ts +++ b/packages/n4s/src/runtime/__tests__/message.test.ts @@ -30,7 +30,7 @@ describe('enforce..message()', () => { describe('.message callback', () => { it('Should be passed the rule value as the first argument', () => { - const msg = jest.fn(() => 'some message'); + const msg = vi.fn(() => 'some message'); const arg = {}; expect(enforce.equals(false).message(msg).run(arg)).toEqual( ruleReturn(false, 'some message'), @@ -39,7 +39,7 @@ describe('enforce..message()', () => { }); it('Should pass original messages the second argument if exists', () => { - const msg = jest.fn(() => 'some message'); + const msg = vi.fn(() => 'some message'); const arg = {}; expect( enforce.ruleWithFailureMessage(false).message(msg).run(arg), diff --git a/packages/vast/src/__tests__/vast.test.ts b/packages/vast/src/__tests__/vast.test.ts index ff5c3bb2a..dc29f6f11 100644 --- a/packages/vast/src/__tests__/vast.test.ts +++ b/packages/vast/src/__tests__/vast.test.ts @@ -120,7 +120,7 @@ describe('vast state', () => { describe('onStateChange and onUpdate handlers', () => { it('Should run onStateChange handler when updating the state', () => { - const onStateChange = jest.fn(); + const onStateChange = vi.fn(); state = createState(onStateChange); const useKey1 = state.registerStateKey('v1'); @@ -134,8 +134,8 @@ describe('vast state', () => { }); it('Should run onUpdate handler when updating the key', () => { - const onUpdate1 = jest.fn(); - const onUpdate2 = jest.fn(); + const onUpdate1 = vi.fn(); + const onUpdate2 = vi.fn(); state = createState(); const useKey1 = state.registerStateKey('v1', onUpdate1); @@ -159,8 +159,8 @@ describe('vast state', () => { }); it('Should first run onUpdate and then onStateChange', () => { - const onUpdate = jest.fn(); - const onChange = jest.fn(); + const onUpdate = vi.fn(); + const onChange = vi.fn(); state = createState(onChange); state.registerStateKey('v1', onUpdate); diff --git a/packages/vest-utils/src/__tests__/Predicates.test.ts b/packages/vest-utils/src/__tests__/Predicates.test.ts index b4ad5fa33..44e72e4ee 100644 --- a/packages/vest-utils/src/__tests__/Predicates.test.ts +++ b/packages/vest-utils/src/__tests__/Predicates.test.ts @@ -42,8 +42,8 @@ describe('Predicates', () => { }); it('Should pass each predicate the value', () => { - const spy1 = jest.fn(value => value > 0); - const spy2 = jest.fn(value => value < 10); + const spy1 = vi.fn(value => value > 0); + const spy2 = vi.fn(value => value < 10); const predicate = all(spy1, spy2); diff --git a/packages/vest-utils/src/__tests__/bindNot.test.ts b/packages/vest-utils/src/__tests__/bindNot.test.ts index 2a1bb00b9..d8d62416d 100644 --- a/packages/vest-utils/src/__tests__/bindNot.test.ts +++ b/packages/vest-utils/src/__tests__/bindNot.test.ts @@ -1,12 +1,12 @@ -import { bindNot } from 'vest-utils'; +import { bindNot } from '@/vest-utils'; describe('bindNot', () => { it('Should return return a function', () => { - expect(typeof bindNot(jest.fn())).toBe('function'); + expect(typeof bindNot(vi.fn())).toBe('function'); }); test('calling returned function runs accepted function', () => { - const fn = jest.fn(); + const fn = vi.fn(); expect(fn).not.toHaveBeenCalled(); const not = bindNot(fn); @@ -16,7 +16,7 @@ describe('bindNot', () => { }); it('Should pass arguments to accepted function', () => { - const fn = jest.fn(); + const fn = vi.fn(); const not = bindNot(fn); not(1, 2, 3, 4); diff --git a/packages/vest-utils/src/__tests__/bus.test.ts b/packages/vest-utils/src/__tests__/bus.test.ts index 55e878ade..a907a22be 100644 --- a/packages/vest-utils/src/__tests__/bus.test.ts +++ b/packages/vest-utils/src/__tests__/bus.test.ts @@ -14,7 +14,7 @@ describe('bus', () => { it('should emit events', () => { const bus = createBus(); - const spy = jest.fn(); + const spy = vi.fn(); bus.on('test', spy); bus.emit('test'); expect(spy).toHaveBeenCalled(); @@ -22,7 +22,7 @@ describe('bus', () => { it('should emit events with data', () => { const bus = createBus(); - const spy = jest.fn(); + const spy = vi.fn(); bus.on('test', spy); bus.emit('test', 'testData'); expect(spy).toHaveBeenCalledWith('testData'); @@ -30,8 +30,8 @@ describe('bus', () => { it('should emit events with multiple listeners', () => { const bus = createBus(); - const spy1 = jest.fn(); - const spy2 = jest.fn(); + const spy1 = vi.fn(); + const spy2 = vi.fn(); bus.on('test', spy1); bus.on('test', spy2); bus.emit('test'); @@ -41,8 +41,8 @@ describe('bus', () => { it('should emit events with multiple listeners and data', () => { const bus = createBus(); - const spy1 = jest.fn(); - const spy2 = jest.fn(); + const spy1 = vi.fn(); + const spy2 = vi.fn(); bus.on('test', spy1); bus.on('test', spy2); bus.emit('test', 'test1'); @@ -52,7 +52,7 @@ describe('bus', () => { test('on returns an object with an `off` function', () => { const bus = createBus(); - const spy = jest.fn(); + const spy = vi.fn(); const off = bus.on('test', spy); expect(off).toBeInstanceOf(Object); expect(off.off).toBeInstanceOf(Function); @@ -60,7 +60,7 @@ describe('bus', () => { test('off should remove a listener', () => { const bus = createBus(); - const spy = jest.fn(); + const spy = vi.fn(); const off = bus.on('test', spy); off.off(); bus.emit('test'); @@ -69,8 +69,8 @@ describe('bus', () => { test('off should only remove specific handler', () => { const bus = createBus(); - const spy1 = jest.fn(); - const spy2 = jest.fn(); + const spy1 = vi.fn(); + const spy2 = vi.fn(); const off = bus.on('test', spy1); bus.on('test', spy2); off.off(); @@ -82,9 +82,9 @@ describe('bus', () => { describe('"ANY" wildcard (*)', () => { it('Should run the wildcard handler on any event', () => { const bus = createBus(); - const spy1 = jest.fn(); - const spy2 = jest.fn(); - const spy3 = jest.fn(); + const spy1 = vi.fn(); + const spy2 = vi.fn(); + const spy3 = vi.fn(); bus.on('t1', spy1); bus.on('t2', spy2); bus.on('*', spy3); @@ -103,10 +103,10 @@ describe('bus', () => { it('Should call the wildcard last, regardless of when it was defined', () => { const bus = createBus(); - const spy1 = jest.fn(); - const spy2 = jest.fn(); - const spy3 = jest.fn(); - const spy4 = jest.fn(); + const spy1 = vi.fn(); + const spy2 = vi.fn(); + const spy3 = vi.fn(); + const spy4 = vi.fn(); bus.on('t1', spy1); bus.on('*', spy4); bus.on('t1', spy2); diff --git a/packages/vest-utils/src/__tests__/cache.test.ts b/packages/vest-utils/src/__tests__/cache.test.ts index 7cfa4feb7..84bf349a8 100644 --- a/packages/vest-utils/src/__tests__/cache.test.ts +++ b/packages/vest-utils/src/__tests__/cache.test.ts @@ -1,6 +1,6 @@ import _ from 'lodash'; -import { cache } from 'vest-utils'; +import { cache } from '@/vest-utils'; describe('lib: cache', () => { let c: ReturnType; @@ -18,7 +18,7 @@ describe('lib: cache', () => { describe('on cache miss', () => { it('Should call passed cache action function and return its value', () => { - const cacheAction = jest.fn(() => ({})); + const cacheAction = vi.fn(() => ({})); const res = c([{}], cacheAction); expect(cacheAction).toHaveBeenCalledTimes(1); expect(res).toBe(cacheAction.mock.results[0].value); @@ -27,7 +27,7 @@ describe('lib: cache', () => { describe('On cache hit', () => { it('Should return cached result', () => { - const cacheAction = jest.fn(() => { + const cacheAction = vi.fn(() => { Math.random(); }); const depsArray = [true, false, {}]; @@ -38,7 +38,7 @@ describe('lib: cache', () => { }); it('Should return without calling the cache action', () => { - const cacheAction = jest.fn(); + const cacheAction = vi.fn(); const depsArray = [Math.random()]; c(depsArray, cacheAction); expect(cacheAction).toHaveBeenCalledTimes(1); diff --git a/packages/vest-utils/src/__tests__/callEach.test.ts b/packages/vest-utils/src/__tests__/callEach.test.ts index 4b432e1ba..51951d014 100644 --- a/packages/vest-utils/src/__tests__/callEach.test.ts +++ b/packages/vest-utils/src/__tests__/callEach.test.ts @@ -2,9 +2,9 @@ import callEach from '@/callEach'; describe('callEach', () => { it('should call all functions in the array', () => { - const mockFn1 = jest.fn(); - const mockFn2 = jest.fn(); - const mockFn3 = jest.fn(); + const mockFn1 = vi.fn(); + const mockFn2 = vi.fn(); + const mockFn3 = vi.fn(); callEach([mockFn1, mockFn2, mockFn3]); diff --git a/packages/vest-utils/src/__tests__/defaultTo.test.ts b/packages/vest-utils/src/__tests__/defaultTo.test.ts index 0dc823a40..c5694aafd 100644 --- a/packages/vest-utils/src/__tests__/defaultTo.test.ts +++ b/packages/vest-utils/src/__tests__/defaultTo.test.ts @@ -1,9 +1,9 @@ -import { defaultTo } from 'vest-utils'; +import { defaultTo } from '@/vest-utils'; describe('defaultTo', () => { describe('When value is a function', () => { it('Should call the function', () => { - const value = jest.fn(() => 'return value'); + const value = vi.fn(() => 'return value'); expect(defaultTo(value, 'fallback value')).toBe('return value'); expect(value).toHaveBeenCalled(); @@ -41,7 +41,7 @@ describe('defaultTo', () => { describe('When the fallback value is a function', () => { it('Should call the function and return its return value', () => { - const fallbackValue = jest.fn(() => 'fallback value'); + const fallbackValue = vi.fn(() => 'fallback value'); expect(defaultTo(null, fallbackValue)).toBe('fallback value'); expect(fallbackValue).toHaveBeenCalled(); diff --git a/packages/vest-utils/src/__tests__/deferThrow.test.ts b/packages/vest-utils/src/__tests__/deferThrow.test.ts index 875ad3e79..87f5b4e18 100644 --- a/packages/vest-utils/src/__tests__/deferThrow.test.ts +++ b/packages/vest-utils/src/__tests__/deferThrow.test.ts @@ -1,11 +1,11 @@ -import { deferThrow } from 'vest-utils'; +import { deferThrow } from '@/vest-utils'; // @ts-ignore const _to = global.setTimeout; describe('deferThrow', () => { beforeEach(() => { // @ts-ignore - global.setTimeout = jest.fn(); + global.setTimeout = vi.fn(); }); afterEach(() => { diff --git a/packages/vest-utils/src/__tests__/invariant.test.ts b/packages/vest-utils/src/__tests__/invariant.test.ts index 4ac8e0972..0b538ed95 100644 --- a/packages/vest-utils/src/__tests__/invariant.test.ts +++ b/packages/vest-utils/src/__tests__/invariant.test.ts @@ -1,4 +1,4 @@ -import { invariant } from 'vest-utils'; +import { invariant } from '@/vest-utils'; describe('invariant', () => { it('should throw an error when condition is false', () => { diff --git a/packages/vest-utils/src/__tests__/isEmpty.test.ts b/packages/vest-utils/src/__tests__/isEmpty.test.ts index 297661ac9..7b1f07816 100644 --- a/packages/vest-utils/src/__tests__/isEmpty.test.ts +++ b/packages/vest-utils/src/__tests__/isEmpty.test.ts @@ -1,4 +1,4 @@ -import { isEmpty } from 'vest-utils'; +import { isEmpty } from '@/vest-utils'; describe('Tests isEmpty rule', () => { describe('Expect true', () => { diff --git a/packages/vest-utils/src/__tests__/mapFirst.test.ts b/packages/vest-utils/src/__tests__/mapFirst.test.ts index cca6ba150..3e246aa91 100644 --- a/packages/vest-utils/src/__tests__/mapFirst.test.ts +++ b/packages/vest-utils/src/__tests__/mapFirst.test.ts @@ -1,4 +1,4 @@ -import { mapFirst } from 'vest-utils'; +import { mapFirst } from '@/vest-utils'; describe('mapFirst', () => { it('should return the broken out result', () => { diff --git a/packages/vest-utils/src/__tests__/optionalFunctionValue.test.ts b/packages/vest-utils/src/__tests__/optionalFunctionValue.test.ts index ede97ee76..74ae0e834 100644 --- a/packages/vest-utils/src/__tests__/optionalFunctionValue.test.ts +++ b/packages/vest-utils/src/__tests__/optionalFunctionValue.test.ts @@ -1,4 +1,4 @@ -import { optionalFunctionValue } from 'vest-utils'; +import { optionalFunctionValue } from '@/vest-utils'; describe('optionalFunctionValue', () => { describe('When not a function', () => { @@ -12,13 +12,13 @@ describe('optionalFunctionValue', () => { describe('When value is a function', () => { it('Should call the function and return its return value', () => { - const value = jest.fn(() => 'return value'); + const value = vi.fn(() => 'return value'); expect(optionalFunctionValue(value)).toBe('return value'); expect(value).toHaveBeenCalled(); }); it('Should run with arguments array', () => { - const value = jest.fn((...args) => args.join('|')); + const value = vi.fn((...args) => args.join('|')); const args = [1, 2, 3, 4]; expect(optionalFunctionValue(value, ...args)).toBe('1|2|3|4'); expect(value).toHaveBeenCalledWith(...args); diff --git a/packages/vest-utils/src/exports/minifyObject.ts b/packages/vest-utils/src/exports/minifyObject.ts index f13271696..212532dad 100644 --- a/packages/vest-utils/src/exports/minifyObject.ts +++ b/packages/vest-utils/src/exports/minifyObject.ts @@ -5,7 +5,7 @@ import { isObject, isFunction, isStringValue, -} from 'vest-utils'; +} from '@/vest-utils'; // Basic key generator that generates keys like a, b, c, ... aa, ab, ac, ... function genMinifiedKey() { diff --git a/packages/vest/src/__tests__/integration.async-tests.test.ts b/packages/vest/src/__tests__/integration.async-tests.test.ts index 89bc5725a..4d918a81d 100644 --- a/packages/vest/src/__tests__/integration.async-tests.test.ts +++ b/packages/vest/src/__tests__/integration.async-tests.test.ts @@ -13,7 +13,7 @@ function genSuite() { vest.test('field_2', 'field_statement_2', () => { vest.enforce(2).equals(3); }); - vest.test('field_3', 'field_statement_3', jest.fn()); + vest.test('field_3', 'field_statement_3', vi.fn()); vest.test('field_4', 'field_statement_4', () => { vest.warn(); throw new Error(); @@ -33,20 +33,20 @@ function genSuite() { let suite: TTestSuite; describe('Stateful behavior', () => { let result, - callback_1 = jest.fn(), - callback_2 = jest.fn(), - callback_3 = jest.fn(), - control = jest.fn(); + callback_1 = vi.fn(), + callback_2 = vi.fn(), + callback_3 = vi.fn(), + control = vi.fn(); beforeEach(() => { suite = genSuite(); }); beforeAll(() => { - callback_1 = jest.fn(); - callback_2 = jest.fn(); - callback_3 = jest.fn(); - control = jest.fn(); + callback_1 = vi.fn(); + callback_2 = vi.fn(); + callback_3 = vi.fn(); + control = vi.fn(); }); test('Should have all fields', () => diff --git a/packages/vest/src/__tests__/integration.base.test.ts b/packages/vest/src/__tests__/integration.base.test.ts index 9e780d7ca..a6e51c298 100644 --- a/packages/vest/src/__tests__/integration.base.test.ts +++ b/packages/vest/src/__tests__/integration.base.test.ts @@ -7,7 +7,7 @@ const suite = () => vest.test('field_2', 'field_statement_2', () => { expect(2).toBe(3); }); - vest.test('field_3', 'field_statement_3', jest.fn()); + vest.test('field_3', 'field_statement_3', vi.fn()); vest.test('field_4', 'field_statement_4', () => { vest.warn(); throw new Error(); @@ -37,7 +37,7 @@ describe('Base behavior', () => { }); it('Should run done callbacks immediately', () => { - const callback = jest.fn(); + const callback = vi.fn(); res.done(callback); expect(callback).toHaveBeenCalled(); diff --git a/packages/vest/src/__tests__/integration.stateful-async.test.ts b/packages/vest/src/__tests__/integration.stateful-async.test.ts index aaeda4dc0..8857a75ca 100644 --- a/packages/vest/src/__tests__/integration.stateful-async.test.ts +++ b/packages/vest/src/__tests__/integration.stateful-async.test.ts @@ -41,19 +41,19 @@ let validate: vest.Suite< TGroupName, ({ skip, skipGroup }: SuiteParams) => void >; -let callback_1 = jest.fn(), - callback_2 = jest.fn(), - callback_3 = jest.fn(), - callback_4 = jest.fn(), - control = jest.fn(); +let callback_1 = vi.fn(), + callback_2 = vi.fn(), + callback_3 = vi.fn(), + callback_4 = vi.fn(), + control = vi.fn(); describe('Stateful async tests', () => { beforeEach(() => { - callback_1 = jest.fn(); - callback_2 = jest.fn(); - callback_3 = jest.fn(); - callback_4 = jest.fn(); - control = jest.fn(); + callback_1 = vi.fn(); + callback_2 = vi.fn(); + callback_3 = vi.fn(); + callback_4 = vi.fn(); + control = vi.fn(); validate = suite(); }); @@ -121,7 +121,7 @@ describe('Stateful async tests', () => { it('Should discard of re-tested async tests', async () => { const tests: Array = []; - const control = jest.fn(); + const control = vi.fn(); const suite = vest.create(() => { tests.push( vest.test('field_1', tests.length.toString(), async () => { diff --git a/packages/vest/src/__tests__/integration.stateful-tests.test.ts b/packages/vest/src/__tests__/integration.stateful-tests.test.ts index 612d894e6..d23f7ae90 100644 --- a/packages/vest/src/__tests__/integration.stateful-tests.test.ts +++ b/packages/vest/src/__tests__/integration.stateful-tests.test.ts @@ -147,7 +147,7 @@ function genSuite() { vest.test('field_2', 'field_statement_2', () => { enforce(2).equals(3); }); - vest.test('field_3', 'field_statement_3', jest.fn()); + vest.test('field_3', 'field_statement_3', vi.fn()); vest.test('field_4', 'field_statement_4', () => { vest.warn(); throw new Error(); diff --git a/packages/vest/src/__tests__/isolate.test.ts b/packages/vest/src/__tests__/isolate.test.ts index 81521221b..99894fc7d 100644 --- a/packages/vest/src/__tests__/isolate.test.ts +++ b/packages/vest/src/__tests__/isolate.test.ts @@ -40,8 +40,8 @@ describe('isolate', () => { }); it('Should retain test results between runs', () => { - const f1 = jest.fn(() => false); - const f2 = jest.fn(() => false); + const f1 = vi.fn(() => false); + const f2 = vi.fn(() => false); const suite = genSuite(() => { vest.skipWhen(!firstRun, () => { vest.test('f1', f1); diff --git a/packages/vest/src/core/isolate/IsolateTest/__tests__/hasRemainingTests.test.ts b/packages/vest/src/core/isolate/IsolateTest/__tests__/hasRemainingTests.test.ts index 0de4578d6..3e2f337ee 100644 --- a/packages/vest/src/core/isolate/IsolateTest/__tests__/hasRemainingTests.test.ts +++ b/packages/vest/src/core/isolate/IsolateTest/__tests__/hasRemainingTests.test.ts @@ -1,7 +1,6 @@ import wait from 'wait'; -import { SuiteWalker } from '@/suite/SuiteWalker'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('SuiteWalker.useHasRemainingWithTestNameMatching', () => { let hasRemaining: boolean | null = null; diff --git a/packages/vest/src/core/test/__tests__/IsolateTest.test.ts b/packages/vest/src/core/test/__tests__/IsolateTest.test.ts index 91a2ee8dd..2ad7c1278 100644 --- a/packages/vest/src/core/test/__tests__/IsolateTest.test.ts +++ b/packages/vest/src/core/test/__tests__/IsolateTest.test.ts @@ -70,9 +70,9 @@ describe('IsolateTest', () => { }); describe('final statuses', () => { - let control = jest.fn(); + let control = vi.fn(); beforeEach(() => { - control = jest.fn(); + control = vi.fn(); }); it('keep status unchanged when `failed`', () => { vest.create(() => { diff --git a/packages/vest/src/core/test/__tests__/memo.test.ts b/packages/vest/src/core/test/__tests__/memo.test.ts index af56a6b82..f8195ef43 100644 --- a/packages/vest/src/core/test/__tests__/memo.test.ts +++ b/packages/vest/src/core/test/__tests__/memo.test.ts @@ -12,8 +12,8 @@ import { test as vestTest, enforce } from 'vest'; describe('test.memo', () => { describe('cache hit', () => { it('Should return without calling callback', () => { - const cb1 = jest.fn(); - const cb2 = jest.fn(() => TestPromise(() => undefined)); + const cb1 = vi.fn(); + const cb2 = vi.fn(() => TestPromise(() => undefined)); const suite = vest.create(() => { vestTest.memo('f1', cb1, [1]); vestTest.memo('f1', cb2, [2]); @@ -150,8 +150,8 @@ describe('test.memo', () => { describe('cache miss', () => { it('Should run test normally', () => { - const cb1 = jest.fn(res => res); - const cb2 = jest.fn( + const cb1 = vi.fn(res => res); + const cb2 = vi.fn( res => new Promise((resolve, rej) => (res ? resolve() : rej())), ); const suite = vest.create((key, res) => { diff --git a/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts b/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts index 7e01a9902..e65d78520 100644 --- a/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts +++ b/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts @@ -91,7 +91,7 @@ describe('Merging of previous test runs', () => { suite = vest.create(() => { testContainer.push([ counter === 0 - ? vest.test('f1', jest.fn()) + ? vest.test('f1', vi.fn()) : vest.test('f2', () => false), ]); counter++; diff --git a/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts b/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts index 843bfda94..047080894 100644 --- a/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts +++ b/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts @@ -26,9 +26,9 @@ describe('runAsyncTest', () => { describe('Callbacks', () => { describe('When there are no remaining pending tests', () => { it('Should run all callbacks', async () => { - const cb1 = jest.fn(); - const cb2 = jest.fn(); - const cb3 = jest.fn(); + const cb1 = vi.fn(); + const cb2 = vi.fn(); + const cb3 = vi.fn(); const suite = vest.create(() => { vest.test('field_1', async () => { @@ -58,9 +58,9 @@ describe('runAsyncTest', () => { describe('When there are remaining pending tests', () => { it('Should only run callbacks for completed tests', async () => { - const cb1 = jest.fn(); - const cb2 = jest.fn(); - const cb3 = jest.fn(); + const cb1 = vi.fn(); + const cb2 = vi.fn(); + const cb3 = vi.fn(); const suite = vest.create(() => { vest.test('field_1', async () => { @@ -89,9 +89,9 @@ describe('runAsyncTest', () => { describe('When the test run was canceled', () => { it('Should not run the callbacks', async () => { - const cb1 = jest.fn(); - const cb2 = jest.fn(); - const cb3 = jest.fn(); + const cb1 = vi.fn(); + const cb2 = vi.fn(); + const cb3 = vi.fn(); const testObject: Array = []; diff --git a/packages/vest/src/core/test/__tests__/test.test.ts b/packages/vest/src/core/test/__tests__/test.test.ts index cb9e1a32a..56dccb342 100644 --- a/packages/vest/src/core/test/__tests__/test.test.ts +++ b/packages/vest/src/core/test/__tests__/test.test.ts @@ -196,7 +196,7 @@ describe("Test Vest's `test` function", () => { }); it('throws when field name is not a string', () => { - const control = jest.fn(); + const control = vi.fn(); vest.create(() => { // @ts-ignore expect(() => vest.test(undefined, () => undefined)).toThrow( @@ -230,7 +230,7 @@ describe("Test Vest's `test` function", () => { }); it('throws when callback is not a function', () => { - const control = jest.fn(); + const control = vi.fn(); vest.create(() => { // @ts-expect-error expect(() => vest.test('x')).toThrow( diff --git a/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts b/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts index f252ffe0a..d656dbd59 100644 --- a/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts +++ b/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts @@ -3,8 +3,8 @@ import * as vest from 'vest'; describe('Test Function Payload', () => { describe('AbortSignal', () => { it('Should pass abort signal to test functions', () => { - const testFnSync = jest.fn(); - const testFnAsync = jest.fn().mockResolvedValue(undefined); + const testFnSync = vi.fn(); + const testFnAsync = vi.fn().mockResolvedValue(undefined); const suite = vest.create(() => { vest.test('field_1', testFnSync); vest.test('field_2', testFnAsync); @@ -17,7 +17,7 @@ describe('Test Function Payload', () => { describe('When test is not canceled', () => { it('Should proceed without aborting the test', async () => { - const testFn = jest.fn().mockResolvedValue(undefined); + const testFn = vi.fn().mockResolvedValue(undefined); const suite = vest.create(() => { vest.test('field_1', testFn); }); @@ -29,7 +29,7 @@ describe('Test Function Payload', () => { describe('When test is canceled', () => { it('Should abort the test', async () => { - const testFn = jest.fn().mockResolvedValue(undefined); + const testFn = vi.fn().mockResolvedValue(undefined); const suite = vest.create(() => { vest.test('field_1', testFn); }); @@ -41,7 +41,7 @@ describe('Test Function Payload', () => { }); it('Should set the reason to `canceled`', async () => { - const testFn = jest.fn().mockResolvedValue(undefined); + const testFn = vi.fn().mockResolvedValue(undefined); const suite = vest.create(() => { vest.test('field_1', testFn); }); @@ -54,8 +54,8 @@ describe('Test Function Payload', () => { describe('Multiple async tests', () => { it('Should abort only the canceled test', async () => { - const testFn1 = jest.fn().mockResolvedValue(undefined); - const testFn2 = jest.fn().mockResolvedValue(undefined); + const testFn1 = vi.fn().mockResolvedValue(undefined); + const testFn2 = vi.fn().mockResolvedValue(undefined); const suite = vest.create((only?: string) => { vest.only(only); diff --git a/packages/vest/src/hooks/__tests__/include.test.ts b/packages/vest/src/hooks/__tests__/include.test.ts index 25c946e8c..632b7aeed 100644 --- a/packages/vest/src/hooks/__tests__/include.test.ts +++ b/packages/vest/src/hooks/__tests__/include.test.ts @@ -2,12 +2,12 @@ import { Modes } from '@/hooks/optional/Modes'; import * as vest from 'vest'; describe('include', () => { - let cb1 = jest.fn(), - cb2 = jest.fn(); + let cb1 = vi.fn(), + cb2 = vi.fn(); beforeEach(() => { - cb1 = jest.fn(() => false); - cb2 = jest.fn(() => false); + cb1 = vi.fn(() => false); + cb2 = vi.fn(() => false); }); describe('When not passing a string fieldName', () => { @@ -196,7 +196,7 @@ describe('include', () => { describe('Callback evaluation', () => { it('Should run the callback for each matching test', () => { - const cb = jest.fn(() => true); + const cb = vi.fn(() => true); const suite = vest.create(() => { vest.mode(Modes.ALL); vest.only('field_1'); @@ -216,10 +216,10 @@ describe('include', () => { expect(cb).toHaveBeenCalledTimes(2); }); it('Should evaluate per test run', () => { - const cb1 = jest.fn(() => false); - const cb2 = jest.fn(() => false); - const cb3 = jest.fn(() => false); - const cb4 = jest.fn(() => false); + const cb1 = vi.fn(() => false); + const cb2 = vi.fn(() => false); + const cb3 = vi.fn(() => false); + const cb4 = vi.fn(() => false); const suite = vest.create(() => { let shouldRun = false; diff --git a/packages/vest/src/hooks/__tests__/warn.test.ts b/packages/vest/src/hooks/__tests__/warn.test.ts index 6559b895b..a14ae7c2c 100644 --- a/packages/vest/src/hooks/__tests__/warn.test.ts +++ b/packages/vest/src/hooks/__tests__/warn.test.ts @@ -22,7 +22,7 @@ describe('warn hook', () => { describe('Error handling', () => { it('Should throw error when currentTest is not present', () => { - const done = jest.fn(); + const done = vi.fn(); create(() => { expect(warn).toThrow(ErrorStrings.WARN_MUST_BE_CALLED_FROM_TEST); done(); diff --git a/packages/vest/src/hooks/optional/__tests__/optional.test.ts b/packages/vest/src/hooks/optional/__tests__/optional.test.ts index 430b447f0..7f9acafdf 100644 --- a/packages/vest/src/hooks/optional/__tests__/optional.test.ts +++ b/packages/vest/src/hooks/optional/__tests__/optional.test.ts @@ -126,7 +126,7 @@ describe('optional hook', () => { }); it('Should run the test but omit anyway', () => { - const fn = jest.fn(() => false); + const fn = vi.fn(() => false); const suite = vest.create(() => { vest.optional({ f1: () => true, @@ -201,7 +201,7 @@ describe('optional hook', () => { }); it('Should avoid running the test to begin with', () => { - const fn = jest.fn(); + const fn = vi.fn(); const suite = vest.create(() => { vest.optional({ field_1: true, diff --git a/packages/vest/src/isolates/__tests__/each.test.ts b/packages/vest/src/isolates/__tests__/each.test.ts index a260e254d..f0be1aa33 100644 --- a/packages/vest/src/isolates/__tests__/each.test.ts +++ b/packages/vest/src/isolates/__tests__/each.test.ts @@ -8,7 +8,7 @@ import * as vest from 'vest'; describe('each', () => { describe('When callback is not a function', () => { it('should throw', () => { - const control = jest.fn(); + const control = vi.fn(); const suite = vest.create(() => { expect(() => { // @ts-expect-error @@ -23,7 +23,7 @@ describe('each', () => { }); it('Should pass to callback the current list item and index', () => { - const cb = jest.fn(); + const cb = vi.fn(); const suite = vest.create(() => { vest.each([1, 2, 3, 'str'], cb); }); diff --git a/packages/vest/src/isolates/__tests__/group.test.ts b/packages/vest/src/isolates/__tests__/group.test.ts index dfdbaee75..072d8e1aa 100644 --- a/packages/vest/src/isolates/__tests__/group.test.ts +++ b/packages/vest/src/isolates/__tests__/group.test.ts @@ -15,7 +15,7 @@ enum FieldNames { describe('named group', () => { it('should run group callback', () => { const groupName = 'groupName'; - const callback = jest.fn(); + const callback = vi.fn(); vest.create(() => { vest.group(groupName, callback); })(); @@ -23,9 +23,9 @@ describe('named group', () => { }); it('Should run the tests within the group', () => { - const cb1 = jest.fn(() => false); - const cb2 = jest.fn(() => false); - const cb3 = jest.fn(() => {}); + const cb1 = vi.fn(() => false); + const cb2 = vi.fn(() => false); + const cb3 = vi.fn(() => {}); const suite = vest.create(() => { vest.mode(vest.Modes.ALL); vest.test(FieldNames.F1, () => false); @@ -76,9 +76,9 @@ describe('named group', () => { describe('Multiple groups', () => { it('Should run the tests within the groups', () => { - const cb1 = jest.fn(() => false); - const cb2 = jest.fn(() => false); - const cb3 = jest.fn(() => {}); + const cb1 = vi.fn(() => false); + const cb2 = vi.fn(() => false); + const cb3 = vi.fn(() => {}); const suite = vest.create(() => { vest.mode(vest.Modes.ALL); vest.test(FieldNames.F1, () => false); @@ -146,8 +146,8 @@ describe('named group', () => { describe('Focus', () => { describe('skip outside of group', () => { it('Should skip `skipped` tests both inside and outside the group', () => { - const cb1 = jest.fn(() => false); - const cb2 = jest.fn(() => false); + const cb1 = vi.fn(() => false); + const cb2 = vi.fn(() => false); const suite = vest.create(() => { vest.mode(vest.Modes.ALL); @@ -178,9 +178,9 @@ describe('named group', () => { describe('skip inside the group', () => { it('should skip only within the group', () => { - const cb1 = jest.fn(() => false); - const cb2 = jest.fn(() => false); - const cb3 = jest.fn(() => false); + const cb1 = vi.fn(() => false); + const cb2 = vi.fn(() => false); + const cb3 = vi.fn(() => false); const suite = vest.create(() => { vest.mode(vest.Modes.ALL); @@ -210,9 +210,9 @@ describe('named group', () => { }); it('should skip only within the group, not the next group', () => { - const cb1 = jest.fn(() => false); - const cb2 = jest.fn(() => false); - const cb3 = jest.fn(() => false); + const cb1 = vi.fn(() => false); + const cb2 = vi.fn(() => false); + const cb3 = vi.fn(() => false); const suite = vest.create(() => { vest.mode(vest.Modes.ALL); @@ -248,9 +248,9 @@ describe('named group', () => { describe('skip(true)', () => { it('should skip only within the group', () => { - const cb1 = jest.fn(() => false); - const cb2 = jest.fn(() => false); - const cb3 = jest.fn(() => false); + const cb1 = vi.fn(() => false); + const cb2 = vi.fn(() => false); + const cb3 = vi.fn(() => false); const suite = vest.create(() => { vest.mode(vest.Modes.ALL); @@ -297,10 +297,10 @@ describe('named group', () => { describe('only', () => { describe('top level only', () => { it('should skip all tests except `only` tests', () => { - const cb1 = jest.fn(() => false); - const cb2 = jest.fn(() => false); - const cb3 = jest.fn(() => false); - const cb4 = jest.fn(() => false); + const cb1 = vi.fn(() => false); + const cb2 = vi.fn(() => false); + const cb3 = vi.fn(() => false); + const cb4 = vi.fn(() => false); const suite = vest.create(() => { vest.mode(vest.Modes.ALL); @@ -353,9 +353,9 @@ describe('named group', () => { describe('group only', () => { it('Should skip all tests except `only` tests within the group', () => { - const cb1 = jest.fn(() => false); - const cb2 = jest.fn(() => false); - const cb3 = jest.fn(() => false); + const cb1 = vi.fn(() => false); + const cb2 = vi.fn(() => false); + const cb3 = vi.fn(() => false); const suite = vest.create(() => { vest.mode(vest.Modes.ALL); @@ -406,9 +406,9 @@ describe('named group', () => { describe('unnamed groups', () => { it('Should run tests normally', () => { - const cb1 = jest.fn(() => false); - const cb2 = jest.fn(() => false); - const cb3 = jest.fn(() => false); + const cb1 = vi.fn(() => false); + const cb2 = vi.fn(() => false); + const cb3 = vi.fn(() => false); const suite = vest.create(() => { vest.mode(vest.Modes.ALL); @@ -448,9 +448,9 @@ describe('unnamed groups', () => { describe('with only', () => { it('Should only run the tests specified by only', () => { - const cb1 = jest.fn(() => false); - const cb2 = jest.fn(() => false); - const cb3 = jest.fn(() => false); + const cb1 = vi.fn(() => false); + const cb2 = vi.fn(() => false); + const cb3 = vi.fn(() => false); const suite = vest.create(() => { vest.mode(vest.Modes.ALL); @@ -478,9 +478,9 @@ describe('unnamed groups', () => { describe('with skip', () => { it('Should skip the tests specified by skip', () => { - const cb1 = jest.fn(() => false); - const cb2 = jest.fn(() => false); - const cb3 = jest.fn(() => false); + const cb1 = vi.fn(() => false); + const cb2 = vi.fn(() => false); + const cb3 = vi.fn(() => false); const suite = vest.create(() => { vest.mode(vest.Modes.ALL); @@ -508,9 +508,9 @@ describe('unnamed groups', () => { describe('With skip(true)', () => { it('Should skip all tests in group', () => { - const cb1 = jest.fn(() => false); - const cb2 = jest.fn(() => false); - const cb3 = jest.fn(() => false); + const cb1 = vi.fn(() => false); + const cb2 = vi.fn(() => false); + const cb3 = vi.fn(() => false); const suite = vest.create(() => { vest.mode(vest.Modes.ALL); diff --git a/packages/vest/src/isolates/__tests__/omitWhen.test.ts b/packages/vest/src/isolates/__tests__/omitWhen.test.ts index f0256448a..eea498f6b 100644 --- a/packages/vest/src/isolates/__tests__/omitWhen.test.ts +++ b/packages/vest/src/isolates/__tests__/omitWhen.test.ts @@ -6,19 +6,19 @@ import { omitWhen, only } from 'vest'; describe('omitWhen', () => { let suite: TTestSuite; - let cb1 = jest.fn(), - cb2 = jest.fn(), - cb3 = jest.fn(), - cb4 = jest.fn(), - cb5 = jest.fn(), + let cb1 = vi.fn(), + cb2 = vi.fn(), + cb3 = vi.fn(), + cb4 = vi.fn(), + cb5 = vi.fn(), allFieldsPass: Maybe; beforeEach(() => { - cb1 = jest.fn(); - cb2 = jest.fn(() => (allFieldsPass ? undefined : false)); - cb3 = jest.fn(() => (allFieldsPass ? undefined : false)); - cb4 = jest.fn(() => (allFieldsPass ? undefined : false)); - cb5 = jest.fn(); + cb1 = vi.fn(); + cb2 = vi.fn(() => (allFieldsPass ? undefined : false)); + cb3 = vi.fn(() => (allFieldsPass ? undefined : false)); + cb4 = vi.fn(() => (allFieldsPass ? undefined : false)); + cb5 = vi.fn(); suite = vest.create((omitConditional, currentField) => { only(currentField); diff --git a/packages/vest/src/isolates/__tests__/skipWhen.test.ts b/packages/vest/src/isolates/__tests__/skipWhen.test.ts index cd85b5f66..08da91510 100644 --- a/packages/vest/src/isolates/__tests__/skipWhen.test.ts +++ b/packages/vest/src/isolates/__tests__/skipWhen.test.ts @@ -5,9 +5,9 @@ import { dummyTest } from '../../testUtils/testDummy'; import * as vest from 'vest'; describe('skipWhen', () => { - let fn = jest.fn(); + let fn = vi.fn(); beforeEach(() => { - fn = jest.fn(); + fn = vi.fn(); suite.reset(); }); it('Should run callback both when condition is true or false', () => { @@ -38,8 +38,8 @@ describe('skipWhen', () => { }); it('Should pass result draft to the functional condition', () => { - const f = jest.fn(); - const control = jest.fn(); + const f = vi.fn(); + const control = vi.fn(); vest.create(() => { vest.skipWhen(draft => { diff --git a/packages/vest/src/suite/__tests__/create.test.ts b/packages/vest/src/suite/__tests__/create.test.ts index ec54ae97b..60f4889a0 100644 --- a/packages/vest/src/suite/__tests__/create.test.ts +++ b/packages/vest/src/suite/__tests__/create.test.ts @@ -10,11 +10,11 @@ import { create } from 'vest'; describe('Test createSuite module', () => { describe('Test suite Arguments', () => { it('allows omitting suite name', () => { - expect(typeof create(jest.fn())).toBe('function'); - expect(typeof create(jest.fn()).get).toBe('function'); - expect(typeof create(jest.fn()).reset).toBe('function'); - expect(typeof create(jest.fn()).remove).toBe('function'); - expect(create(jest.fn()).get()).toMatchSnapshot(); + expect(typeof create(vi.fn())).toBe('function'); + expect(typeof create(vi.fn()).get).toBe('function'); + expect(typeof create(vi.fn()).reset).toBe('function'); + expect(typeof create(vi.fn()).remove).toBe('function'); + expect(create(vi.fn()).get()).toMatchSnapshot(); }); it.each([faker.lorem.word(), null, undefined, 0, 1, true, false, NaN, ''])( @@ -52,7 +52,7 @@ describe('Test createSuite module', () => { })); it('Passes all arguments over to tests callback', () => { - const testsCallback = jest.fn(); + const testsCallback = vi.fn(); const params = [ 1, 2, @@ -68,7 +68,7 @@ describe('Test createSuite module', () => { }); describe('Initial run', () => { - const testsCb = jest.fn(); + const testsCb = vi.fn(); const genValidate = () => create(testsCb); it('Should initialize with an empty result object', () => { @@ -84,7 +84,7 @@ describe('Test createSuite module', () => { }); it('Should be able to get the suite from the result of createSuite', () => { - const testsCb = jest.fn(); + const testsCb = vi.fn(); expect(create(testsCb).get()).toMatchSnapshot(); }); diff --git a/packages/vest/src/suite/__tests__/subscribe.test.ts b/packages/vest/src/suite/__tests__/subscribe.test.ts index be6f27e55..60a0418c2 100644 --- a/packages/vest/src/suite/__tests__/subscribe.test.ts +++ b/packages/vest/src/suite/__tests__/subscribe.test.ts @@ -12,7 +12,7 @@ describe('suite.subscribe', () => { }); it('Should call the callback on suite updates', async () => { - const cb = jest.fn(() => { + const cb = vi.fn(() => { dumps.push(SuiteSerializer.serialize(suite)); }); let callCount = cb.mock.calls.length; @@ -53,7 +53,7 @@ describe('suite.subscribe', () => { describe('unsubscribe', () => { it('Should unsubscribe future events', () => { - const cb = jest.fn(); + const cb = vi.fn(); const suite = vest.create('suite', () => { vest.test('field', () => {}); }); diff --git a/packages/vest/src/suiteResult/done/__tests__/done.test.ts b/packages/vest/src/suiteResult/done/__tests__/done.test.ts index fa0edf7b7..31fc2be0d 100644 --- a/packages/vest/src/suiteResult/done/__tests__/done.test.ts +++ b/packages/vest/src/suiteResult/done/__tests__/done.test.ts @@ -17,8 +17,8 @@ describe('done', () => { dummyTest.failingWarning('field_2'); })(); - const doneCallback = jest.fn(); - const fieldDoneCallback = jest.fn(); + const doneCallback = vi.fn(); + const fieldDoneCallback = vi.fn(); result.done(doneCallback).done('field_2', fieldDoneCallback); @@ -34,10 +34,10 @@ describe('done', () => { test.push(dummyTest.failingAsync('test', { time: 100 })); }); - const doneCallback1 = jest.fn(); - const fieldDoneCallback1 = jest.fn(); - const doneCallback2 = jest.fn(); - const fieldDoneCallback2 = jest.fn(); + const doneCallback1 = vi.fn(); + const fieldDoneCallback1 = vi.fn(); + const doneCallback2 = vi.fn(); + const fieldDoneCallback2 = vi.fn(); suite().done(doneCallback1).done('test', fieldDoneCallback1); await wait(10); @@ -53,11 +53,11 @@ describe('done', () => { describe('When there are async tests', () => { describe('When field name is not passed', () => { it('Should run the done callback after all the fields finished running', () => { - const check1 = jest.fn(); - const check2 = jest.fn(); - const check3 = jest.fn(); + const check1 = vi.fn(); + const check2 = vi.fn(); + const check3 = vi.fn(); return TestPromise(done => { - const doneCallback = jest.fn(() => { + const doneCallback = vi.fn(() => { expect(check1).toHaveBeenCalled(); expect(check2).toHaveBeenCalled(); expect(check3).toHaveBeenCalled(); @@ -289,8 +289,8 @@ describe('done', () => { describe('When suite re-runs and a pending test is now skipped', () => { it('Should immediately call the second done callback, omit the first', async () => { - const done_0 = jest.fn(); - const done_1 = jest.fn(); + const done_0 = vi.fn(); + const done_1 = vi.fn(); const suite = vest.create(username => { vest.test('username', () => { @@ -320,7 +320,7 @@ describe('done', () => { describe('Passing a field that does not exist', () => { it('Should avoid calling the callback', () => { - const cb = jest.fn(); + const cb = vi.fn(); const suite = vest.create(() => { vest.test('test', () => {}); @@ -334,7 +334,7 @@ describe('done', () => { describe('When no tests are run', () => { it('Should run the callback', () => { - const cb = jest.fn(); + const cb = vi.fn(); const suite = vest.create(() => {}); @@ -345,7 +345,7 @@ describe('done', () => { describe('When tests are omitted', () => { it('Should run the callback', () => { - const cb = jest.fn(); + const cb = vi.fn(); const suite = vest.create(() => { vest.optional({ f1: true }); @@ -362,7 +362,7 @@ describe('done', () => { describe('When focused done call does not match executed tests', () => { it('Should not call the callback', () => { - const cb = jest.fn(); + const cb = vi.fn(); const suite = vest.create(() => { vest.test('test', () => false); @@ -377,7 +377,7 @@ describe('done', () => { describe('Async Isolate', () => { describe('When async isolate is pending', () => { it('Should not call the callback', () => { - const cb = jest.fn(); + const cb = vi.fn(); const suite = vest.create(() => { vest.test('test', () => false); @@ -395,7 +395,7 @@ describe('done', () => { describe('When async isolate is completed', () => { it('Should call the callback', async () => { - const cb = jest.fn(); + const cb = vi.fn(); const suite = vest.create(() => { vest.test('test', () => false); diff --git a/packages/vestjs-runtime/src/Isolate/__tests__/Isolate.test.ts b/packages/vestjs-runtime/src/Isolate/__tests__/Isolate.test.ts index 0c9f1bce8..dbbd3dc18 100644 --- a/packages/vestjs-runtime/src/Isolate/__tests__/Isolate.test.ts +++ b/packages/vestjs-runtime/src/Isolate/__tests__/Isolate.test.ts @@ -25,7 +25,7 @@ describe('Isolate', () => { }); it('Should run the passed callback', () => { - const spy = jest.fn(); + const spy = vi.fn(); withRunTime(() => { Isolate.create(IsolateType.Isolate, spy); }); diff --git a/packages/vestjs-runtime/src/Isolate/__tests__/IsolateMutator.test.ts b/packages/vestjs-runtime/src/Isolate/__tests__/IsolateMutator.test.ts index 27c42cd77..0d1f52ca7 100644 --- a/packages/vestjs-runtime/src/Isolate/__tests__/IsolateMutator.test.ts +++ b/packages/vestjs-runtime/src/Isolate/__tests__/IsolateMutator.test.ts @@ -121,7 +121,7 @@ describe('IsolateMutator', () => { describe('abort', () => { it('Should abort the controller', () => { const isolate = { - abortController: { abort: jest.fn() }, + abortController: { abort: vi.fn() }, } as unknown as TIsolate; expect(isolate.abortController.abort).not.toHaveBeenCalled(); @@ -141,7 +141,7 @@ describe('IsolateMutator', () => { it('Should abort the controller with the passed reason', () => { const isolate = { - abortController: { abort: jest.fn() }, + abortController: { abort: vi.fn() }, } as unknown as TIsolate; expect(isolate.abortController.abort).not.toHaveBeenCalled(); diff --git a/packages/vestjs-runtime/src/Isolate/__tests__/asyncIsolate.test.ts b/packages/vestjs-runtime/src/Isolate/__tests__/asyncIsolate.test.ts index 4b551da7d..dbe1bb82c 100644 --- a/packages/vestjs-runtime/src/Isolate/__tests__/asyncIsolate.test.ts +++ b/packages/vestjs-runtime/src/Isolate/__tests__/asyncIsolate.test.ts @@ -49,7 +49,7 @@ describe('AsyncIsolate', () => { }); it('Should emit an event when an async isolate is done running', () => { - const cb = jest.fn(); + const cb = vi.fn(); return new Promise(async done => { let child = {} as TIsolate; withRunTime(() => { diff --git a/tsconfig.json b/tsconfig.json index 77e202ad9..191d85821 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,7 +18,8 @@ "skipLibCheck": true, "sourceMap": true, "strict": true, - "target": "ES2015" + "target": "ES2015", + "types": ["vitest/globals"] }, "files": ["./vx/config/jest/globals.d.ts"], "include": ["./packages/*/src/**/*.ts"] diff --git a/vx/scripts/genTsConfig.js b/vx/scripts/genTsConfig.js index 72db4cb0b..73996b372 100644 --- a/vx/scripts/genTsConfig.js +++ b/vx/scripts/genTsConfig.js @@ -97,6 +97,7 @@ function rootTsConfigTemplate() { sourceMap: true, strict: true, target: 'ES2015', + types: ['vitest/globals'], }, files: [`${vxPath.rel(vxPath.JEST_CONFIG_PATH)}/globals.d.ts`], include: [vxPath.rel(vxPath.packageSrc('*', '**/*.ts'))], From 15406b507fd74844f7ba4b052115d68630edd1ca Mon Sep 17 00:00:00 2001 From: ealush Date: Sat, 27 Jul 2024 16:36:54 +0300 Subject: [PATCH 06/16] vestjs-runtime --- .../__snapshots__/cascade.test.ts.snap | 24 ++++++- .../n4s/src/exports/__tests__/date.test.ts | 4 +- packages/n4s/src/exports/compounds.ts | 3 +- packages/n4s/src/exports/date.ts | 3 +- packages/n4s/src/exports/schema.ts | 4 +- .../runtime/__tests__/enforceContext.test.ts | 6 +- .../src/Isolate/__tests__/Isolate.test.ts | 4 +- .../__snapshots__/asyncIsolate.test.ts.snap | 62 ++++++++++++++++++- .../IsolateSerializer.test.ts.snap | 6 +- packages/vestjs-runtime/src/vestjs-runtime.ts | 1 - 10 files changed, 101 insertions(+), 16 deletions(-) diff --git a/packages/context/src/__tests__/__snapshots__/cascade.test.ts.snap b/packages/context/src/__tests__/__snapshots__/cascade.test.ts.snap index e8e84c468..61ba7841b 100644 --- a/packages/context/src/__tests__/__snapshots__/cascade.test.ts.snap +++ b/packages/context/src/__tests__/__snapshots__/cascade.test.ts.snap @@ -1,4 +1,26 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`Cascading Context > context.run > Should clear context after callback run 1`] = ` +{ + "a": 1, +} +`; + +exports[`Cascading Context > context.run > Should clear context after callback run 2`] = ` +{ + "a": 1, + "b": 2, +} +`; + +exports[`Cascading Context > createCascade > Should return all methods 1`] = ` +{ + "bind": [Function], + "run": [Function], + "use": [Function], + "useX": [Function], +} +`; exports[`Cascading Context context.run Should clear context after callback run 1`] = ` { diff --git a/packages/n4s/src/exports/__tests__/date.test.ts b/packages/n4s/src/exports/__tests__/date.test.ts index 5e221a30a..3f00b4b13 100644 --- a/packages/n4s/src/exports/__tests__/date.test.ts +++ b/packages/n4s/src/exports/__tests__/date.test.ts @@ -1,5 +1,5 @@ -import { enforce } from 'n4s'; -import 'date'; +import { enforce } from '@/n4s'; +import '../date'; describe('date', () => { describe('isDate', () => { diff --git a/packages/n4s/src/exports/compounds.ts b/packages/n4s/src/exports/compounds.ts index a6137b3c6..eef44e0ee 100644 --- a/packages/n4s/src/exports/compounds.ts +++ b/packages/n4s/src/exports/compounds.ts @@ -1,7 +1,6 @@ -import { enforce } from 'n4s'; - import { EnforceCustomMatcher } from '@/lib/enforceUtilityTypes'; import { RuleDetailedResult } from '@/lib/ruleReturn'; +import { enforce } from '@/n4s'; import { allOf } from '@/plugins/compounds/allOf'; import { anyOf } from '@/plugins/compounds/anyOf'; import { noneOf } from '@/plugins/compounds/noneOf'; diff --git a/packages/n4s/src/exports/date.ts b/packages/n4s/src/exports/date.ts index e90356e67..5340665a9 100644 --- a/packages/n4s/src/exports/date.ts +++ b/packages/n4s/src/exports/date.ts @@ -1,4 +1,3 @@ -import { enforce } from 'n4s'; import isAfter from 'validator/es/lib/isAfter'; import isBefore from 'validator/es/lib/isBefore'; import isDate from 'validator/es/lib/isDate'; @@ -6,6 +5,8 @@ import isISO8601 from 'validator/es/lib/isISO8601'; import { EnforceCustomMatcher } from '../lib/enforceUtilityTypes'; +import { enforce } from '@/n4s'; + enforce.extend({ isAfter, isBefore, isDate, isISO8601 }); /* eslint-disable @typescript-eslint/no-namespace */ diff --git a/packages/n4s/src/exports/schema.ts b/packages/n4s/src/exports/schema.ts index 7fc0add5e..a33d2a8c9 100644 --- a/packages/n4s/src/exports/schema.ts +++ b/packages/n4s/src/exports/schema.ts @@ -1,11 +1,11 @@ -import { enforce } from 'n4s'; - import { EnforceCustomMatcher } from '../lib/enforceUtilityTypes'; import { isArrayOf } from '../plugins/schema/isArrayOf'; import { loose } from '../plugins/schema/loose'; import { optional } from '../plugins/schema/optional'; import { shape } from '../plugins/schema/shape'; +import { enforce } from '@/n4s'; + enforce.extend({ isArrayOf, loose, optional, shape }); /* eslint-disable @typescript-eslint/no-namespace */ diff --git a/packages/n4s/src/runtime/__tests__/enforceContext.test.ts b/packages/n4s/src/runtime/__tests__/enforceContext.test.ts index 9e89125d2..165895d84 100644 --- a/packages/n4s/src/runtime/__tests__/enforceContext.test.ts +++ b/packages/n4s/src/runtime/__tests__/enforceContext.test.ts @@ -1,7 +1,7 @@ -import { enforce } from '@/runtime/enforce'; import * as ruleReturn from '@/lib/ruleReturn'; -import 'schema'; -import 'compounds'; +import { enforce } from '@/runtime/enforce'; +import '@/exports/schema'; +import '@/exports/compounds'; let keepContext = vi.fn(); diff --git a/packages/vestjs-runtime/src/Isolate/__tests__/Isolate.test.ts b/packages/vestjs-runtime/src/Isolate/__tests__/Isolate.test.ts index dbbd3dc18..986f1f392 100644 --- a/packages/vestjs-runtime/src/Isolate/__tests__/Isolate.test.ts +++ b/packages/vestjs-runtime/src/Isolate/__tests__/Isolate.test.ts @@ -13,7 +13,7 @@ describe('Isolate', () => { let stateRef: StateRefType; beforeEach(() => { - stateRef = VestRuntime.createRef({}); + stateRef = VestRuntime.createRef({}, v => v); }); describe('Isolate.create', () => { @@ -108,7 +108,7 @@ describe('Isolate', () => { const isolate = withRunTime(() => { return Isolate.create(IsolateType.Isolate, () => {}); }); - const spy = jest.spyOn(isolate.abortController, 'abort'); + const spy = vi.spyOn(isolate.abortController, 'abort'); IsolateMutator.abort(isolate, 'foo'); expect(spy).toHaveBeenCalledWith('foo'); }); diff --git a/packages/vestjs-runtime/src/Isolate/__tests__/__snapshots__/asyncIsolate.test.ts.snap b/packages/vestjs-runtime/src/Isolate/__tests__/__snapshots__/asyncIsolate.test.ts.snap index 0629e6442..e6dbc963c 100644 --- a/packages/vestjs-runtime/src/Isolate/__tests__/__snapshots__/asyncIsolate.test.ts.snap +++ b/packages/vestjs-runtime/src/Isolate/__tests__/__snapshots__/asyncIsolate.test.ts.snap @@ -1,4 +1,64 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`AsyncIsolate > It should resolve async isolate into the parent 2`] = ` +{ + "$type": "URoot", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": [ + { + "$type": "UChild_1", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": [ + { + "$type": "UGrandChild_1", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": {}, + "key": null, + "keys": null, + "output": undefined, + "parent": [Circular], + }, + { + "$type": "UGrandChild_2", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": {}, + "key": null, + "keys": null, + "output": undefined, + "parent": [Circular], + }, + { + "$type": "UGrandChild_3", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": {}, + "key": null, + "keys": null, + "output": undefined, + "parent": [Circular], + }, + ], + "data": {}, + "key": null, + "keys": null, + "output": undefined, + "parent": [Circular], + }, + ], + "data": {}, + "key": null, + "keys": null, + "output": Promise {}, + "parent": null, +} +`; exports[`AsyncIsolate It should resolve async isolate into the parent 2`] = ` { diff --git a/packages/vestjs-runtime/src/exports/__tests__/__snapshots__/IsolateSerializer.test.ts.snap b/packages/vestjs-runtime/src/exports/__tests__/__snapshots__/IsolateSerializer.test.ts.snap index bb92986ff..132258ac7 100644 --- a/packages/vestjs-runtime/src/exports/__tests__/__snapshots__/IsolateSerializer.test.ts.snap +++ b/packages/vestjs-runtime/src/exports/__tests__/__snapshots__/IsolateSerializer.test.ts.snap @@ -1,4 +1,8 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`IsolateSerializer > Custom Data Serialization > Should serialize data with custom keys 1`] = `"[{"0":"URoot","1":{"2":"3"},"children":[{"0":"UChild_1","1":{"2":"3"}},{"0":"UChild_2"},{"0":"UChild_3"}]},{"0":"$type","1":"data","2":"some_data","3":true}]"`; + +exports[`IsolateSerializer > serialize > Should produce serialized dump 1`] = `"[{"0":"URoot","1":{"2":"3"},"children":[{"0":"UChild_1","1":{"2":"3"}},{"0":"UChild_2"},{"0":"UChild_3"}]},{"0":"$type","1":"data","2":"some_data","3":true}]"`; exports[`IsolateSerializer Custom Data Serialization Should serialize data with custom keys 1`] = `"[{"0":"URoot","1":{"2":"3"},"children":[{"0":"UChild_1","1":{"2":"3"}},{"0":"UChild_2"},{"0":"UChild_3"}]},{"0":"$type","1":"data","2":"some_data","3":true}]"`; diff --git a/packages/vestjs-runtime/src/vestjs-runtime.ts b/packages/vestjs-runtime/src/vestjs-runtime.ts index 992282acf..db39719b0 100644 --- a/packages/vestjs-runtime/src/vestjs-runtime.ts +++ b/packages/vestjs-runtime/src/vestjs-runtime.ts @@ -7,4 +7,3 @@ export { IsolateInspector } from '@/Isolate/IsolateInspector'; export { IsolateMutator } from '@/Isolate/IsolateMutator'; export * as Bus from '@/Bus'; export * as IsolateSelectors from '@/Isolate/IsolateSelectors'; -export { IsolateSerializer } from '@exports/IsolateSerializer'; From fde7c43f75dd04fb3a2fe1d3e140b0544fdce1b0 Mon Sep 17 00:00:00 2001 From: ealush Date: Sat, 27 Jul 2024 16:37:46 +0300 Subject: [PATCH 07/16] jest -> vi --- packages/n4s/src/__tests__/enforce.test.ts | 4 ++-- packages/vest/src/__tests__/isolate.test.ts | 4 ++-- packages/vest/src/core/test/__tests__/IsolateTest.test.ts | 2 +- packages/vest/src/core/test/__tests__/key.test.ts | 8 ++++---- .../test/__tests__/merging_of_previous_test_runs.test.ts | 2 +- .../src/core/test/__tests__/testFunctionPayload.test.ts | 2 +- .../vest/src/hooks/optional/__tests__/optional.test.ts | 8 ++++---- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/n4s/src/__tests__/enforce.test.ts b/packages/n4s/src/__tests__/enforce.test.ts index 08d069ba0..dc76454e9 100644 --- a/packages/n4s/src/__tests__/enforce.test.ts +++ b/packages/n4s/src/__tests__/enforce.test.ts @@ -7,12 +7,12 @@ let enforce: TEnforceMock; describe(`enforce`, () => { beforeEach(() => { - jest.resetModules(); + vi.resetModules(); enforce = require('enforce').enforce as TEnforceMock; }); afterEach(() => { - jest.resetModules(); + vi.resetModules(); global.Proxy = _proxy; }); diff --git a/packages/vest/src/__tests__/isolate.test.ts b/packages/vest/src/__tests__/isolate.test.ts index 99894fc7d..84b9a9046 100644 --- a/packages/vest/src/__tests__/isolate.test.ts +++ b/packages/vest/src/__tests__/isolate.test.ts @@ -29,8 +29,8 @@ describe('isolate', () => { }); afterEach(() => { - jest.resetModules(); - jest.resetAllMocks(); + vi.resetModules(); + vi.resetAllMocks(); }); describe('Base behavior', () => { diff --git a/packages/vest/src/core/test/__tests__/IsolateTest.test.ts b/packages/vest/src/core/test/__tests__/IsolateTest.test.ts index 2ad7c1278..1857e5a27 100644 --- a/packages/vest/src/core/test/__tests__/IsolateTest.test.ts +++ b/packages/vest/src/core/test/__tests__/IsolateTest.test.ts @@ -39,7 +39,7 @@ describe('IsolateTest', () => { }); afterEach(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); }); it('Should set status to failed', () => { diff --git a/packages/vest/src/core/test/__tests__/key.test.ts b/packages/vest/src/core/test/__tests__/key.test.ts index ae511fb05..184d83483 100644 --- a/packages/vest/src/core/test/__tests__/key.test.ts +++ b/packages/vest/src/core/test/__tests__/key.test.ts @@ -82,8 +82,8 @@ describe('key', () => { vest = mockThrowError().vest; }); afterEach(() => { - jest.resetModules(); - jest.resetAllMocks(); + vi.resetModules(); + vi.resetAllMocks(); }); it('Should retain keyd tests', () => { const calls: TIsolateTest[][] = []; @@ -208,8 +208,8 @@ describe('key', () => { }); afterEach(() => { - jest.resetAllMocks(); - jest.resetModules(); + vi.resetAllMocks(); + vi.resetModules(); }); it('Should throw a deferred error', () => { diff --git a/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts b/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts index e65d78520..542d99481 100644 --- a/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts +++ b/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts @@ -84,7 +84,7 @@ describe('Merging of previous test runs', () => { }); afterAll(() => { - jest.resetAllMocks(); + vi.resetAllMocks(); }); it('Should defer-throw an error', () => { diff --git a/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts b/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts index d656dbd59..120147913 100644 --- a/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts +++ b/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts @@ -75,7 +75,7 @@ describe('Test Function Payload', () => { }); function callPayload( - fn: jest.Mock, + fn: vi.Mock, call: number = 0, arg: number = 0, ) { diff --git a/packages/vest/src/hooks/optional/__tests__/optional.test.ts b/packages/vest/src/hooks/optional/__tests__/optional.test.ts index 7f9acafdf..e48acb6bc 100644 --- a/packages/vest/src/hooks/optional/__tests__/optional.test.ts +++ b/packages/vest/src/hooks/optional/__tests__/optional.test.ts @@ -4,7 +4,7 @@ import wait from 'wait'; import * as vest from 'vest'; -jest.useFakeTimers(); +vi.useFakeTimers(); describe('optional hook', () => { describe('Auto Optional Interface', () => { @@ -394,7 +394,7 @@ describe('optional hook', () => { describe('After the test completed', () => { it('Should be considered as non-valid', () => { const res = suite(); - jest.runAllTimers(); + vi.runAllTimers(); expect(res.isValid()).toBe(false); expect(res.isValid('field_1')).toBe(false); }); @@ -425,7 +425,7 @@ describe('optional hook', () => { describe('After the test completed', () => { it('Should be considered as valid', async () => { suite(); - await jest.runAllTimersAsync(); + await vi.runAllTimersAsync(); expect(suite.isValid()).toBe(true); expect(suite.isValid('field_1')).toBe(true); }); @@ -463,7 +463,7 @@ describe('optional hook', () => { describe('After the test completed', () => { it('Should be considered as valid', async () => { suite(); - await jest.runAllTimersAsync(); + await vi.runAllTimersAsync(); expect(suite.isValid('field_2')).toBe(true); expect(suite.isValid()).toBe(true); expect(suite.isValid('field_1')).toBe(true); From 3b009c631e29b2b60f46261d4b6de328d2f2cf6c Mon Sep 17 00:00:00 2001 From: ealush Date: Sat, 27 Jul 2024 17:45:46 +0300 Subject: [PATCH 08/16] update tests --- .../integration.async-tests.test.ts.snap | 79 +- .../integration.base.test.ts.snap | 102 +- .../integration.stateful-async.test.ts.snap | 329 ++++- .../integration.stateful-tests.test.ts.snap | 518 ++++++- .../__tests__/integration.async-tests.test.ts | 2 +- .../src/__tests__/integration.base.test.ts | 2 +- .../__tests__/integration.exclusive.test.ts | 2 +- .../integration.stateful-async.test.ts | 2 +- .../integration.stateful-tests.test.ts | 2 +- packages/vest/src/__tests__/isolate.test.ts | 13 +- .../vest/src/__tests__/state_refill.test.ts | 2 +- .../__snapshots__/runtime.test.ts.snap | 502 ++++++- .../vest/src/core/__tests__/runtime.test.ts | 2 +- .../core/test/__tests__/IsolateTest.test.ts | 2 +- .../__snapshots__/IsolateTest.test.ts.snap | 40 +- .../__tests__/__snapshots__/test.test.ts.snap | 220 ++- .../vest/src/core/test/__tests__/key.test.ts | 2 +- .../vest/src/core/test/__tests__/memo.test.ts | 4 +- .../merging_of_previous_test_runs.test.ts | 2 +- .../core/test/__tests__/runAsyncTest.test.ts | 2 +- .../vest/src/core/test/__tests__/test.test.ts | 4 +- .../__tests__/testFunctionPayload.test.ts | 2 +- .../exports/__tests__/SuiteSerializer.test.ts | 2 +- .../SuiteSerializer.test.ts.snap | 15 +- .../src/exports/__tests__/classnames.test.ts | 6 +- .../src/exports/__tests__/debounce.test.ts | 22 +- .../vest/src/exports/__tests__/parser.test.ts | 2 +- .../src/exports/__tests__/promisify.test.ts | 11 +- packages/vest/src/exports/debounce.ts | 2 +- packages/vest/src/exports/parser.ts | 3 +- .../__snapshots__/include.test.ts.snap | 1067 +++++++++++++- .../vest/src/hooks/__tests__/include.test.ts | 2 +- .../vest/src/hooks/__tests__/mode.test.ts | 4 +- .../vest/src/hooks/__tests__/warn.test.ts | 2 +- .../__snapshots__/focused.test.ts.snap | 166 ++- .../hooks/focused/__tests__/focused.test.ts | 2 +- .../hooks/optional/__tests__/optional.test.ts | 2 +- .../__tests__/__snapshots__/each.test.ts.snap | 4 +- .../__snapshots__/group.test.ts.snap | 1259 ++++++++++++++++- .../__snapshots__/omitWhen.test.ts.snap | 540 ++++++- .../__snapshots__/skipWhen.test.ts.snap | 144 +- .../vest/src/isolates/__tests__/each.test.ts | 2 +- .../vest/src/isolates/__tests__/group.test.ts | 2 +- .../src/isolates/__tests__/omitWhen.test.ts | 4 +- .../src/isolates/__tests__/skipWhen.test.ts | 2 +- .../__snapshots__/create.test.ts.snap | 92 +- .../vest/src/suite/__tests__/create.test.ts | 2 +- .../vest/src/suite/__tests__/remove.test.ts | 2 +- .../src/suite/__tests__/resetField.test.ts | 2 +- .../src/suite/__tests__/staticSuite.test.ts | 4 +- .../src/suite/__tests__/subscribe.test.ts | 2 +- .../vest/src/suite/__tests__/suite.dump.ts | 2 +- .../__tests__/suiteSelectorsOnSuite.test.ts | 2 +- .../src/suite/__tests__/typedSuite.test.ts | 2 +- packages/vest/src/suite/createSuite.ts | 1 + .../useProduceSuiteSummary.test.ts.snap | 133 +- .../__tests__/useProduceSuiteSummary.test.ts | 2 +- .../suiteResult/done/__tests__/done.test.ts | 2 +- .../collectFailureMessages.test.ts.snap | 90 +- .../__tests__/collectFailureMessages.test.ts | 4 +- .../selectors/__tests__/getFailure.test.ts | 2 +- .../selectors/__tests__/getFailures.test.ts | 2 +- .../__tests__/getFailuresByGroup.test.ts | 4 +- .../selectors/__tests__/hasFailures.test.ts | 2 +- .../__tests__/hasFailuresByGroup.test.ts | 2 +- .../selectors/__tests__/isPending.test.ts | 2 +- .../selectors/__tests__/isTested.test.ts | 2 +- .../selectors/__tests__/isValid.test.ts | 2 +- .../__tests__/isValidByGroup.test.ts | 4 +- .../__tests__/summaryFailures.test.ts | 2 +- packages/vest/src/testUtils/TVestMock.ts | 2 +- packages/vest/src/testUtils/mockThrowError.ts | 8 +- packages/vest/src/testUtils/suiteDummy.ts | 2 +- packages/vest/src/testUtils/testDummy.ts | 18 +- packages/vest/src/testUtils/vestMocks.ts | 2 +- vx/getFailures | 0 76 files changed, 5374 insertions(+), 124 deletions(-) create mode 100644 vx/getFailures diff --git a/packages/vest/src/__tests__/__snapshots__/integration.async-tests.test.ts.snap b/packages/vest/src/__tests__/__snapshots__/integration.async-tests.test.ts.snap index 419afc8d7..c19491937 100644 --- a/packages/vest/src/__tests__/__snapshots__/integration.async-tests.test.ts.snap +++ b/packages/vest/src/__tests__/__snapshots__/integration.async-tests.test.ts.snap @@ -1,4 +1,81 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`Stateful behavior > Should have all fields 1`] = ` +{ + "field_1": SummaryBase { + "errorCount": 1, + "errors": [ + "field_statement_1", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 1, + "errors": [ + "field_statement_2", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "field_4": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": true, + "warnCount": 1, + "warnings": [ + "field_statement_4", + ], + }, + "field_5": { + "errorCount": 2, + "errors": [ + "field_statement_5", + "field_statement_6", + ], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_6": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 1, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_7": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 1, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, +} +`; exports[`Stateful behavior Should have all fields 1`] = ` { diff --git a/packages/vest/src/__tests__/__snapshots__/integration.base.test.ts.snap b/packages/vest/src/__tests__/__snapshots__/integration.base.test.ts.snap index 8a3f0265f..d6390bded 100644 --- a/packages/vest/src/__tests__/__snapshots__/integration.base.test.ts.snap +++ b/packages/vest/src/__tests__/__snapshots__/integration.base.test.ts.snap @@ -1,4 +1,104 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`Base behavior > Should produce correct validation result 1`] = ` +{ + "done": [Function], + "errorCount": 2, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": "field_statement_1", + }, + SummaryFailure { + "fieldName": "field_2", + "groupName": undefined, + "message": "field_statement_2", + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 5, + "tests": { + "field_1": SummaryBase { + "errorCount": 1, + "errors": [ + "field_statement_1", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 1, + "errors": [ + "field_statement_2", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "field_4": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": true, + "warnCount": 1, + "warnings": [ + "field_statement_4", + ], + }, + "field_5": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 1, + "warnings": [ + SummaryFailure { + "fieldName": "field_4", + "groupName": undefined, + "message": "field_statement_4", + }, + ], +} +`; exports[`Base behavior Should produce correct validation result 1`] = ` { diff --git a/packages/vest/src/__tests__/__snapshots__/integration.stateful-async.test.ts.snap b/packages/vest/src/__tests__/__snapshots__/integration.stateful-async.test.ts.snap index 2548791fa..71c401e04 100644 --- a/packages/vest/src/__tests__/__snapshots__/integration.stateful-async.test.ts.snap +++ b/packages/vest/src/__tests__/__snapshots__/integration.stateful-async.test.ts.snap @@ -1,4 +1,331 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`Stateful async tests > Merges skipped validations from previous suite 1`] = ` +{ + "done": [Function], + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": "field_message_1", + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": { + "group": { + "field_1": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_4": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + }, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 1, + "suiteName": undefined, + "testCount": 3, + "tests": { + "field_1": { + "errorCount": 1, + "errors": [ + "field_message_1", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": { + "errorCount": 0, + "errors": [], + "pendingCount": 1, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_4": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`Stateful async tests > Merges skipped validations from previous suite 2`] = ` +SuiteSummary { + "errorCount": 2, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": "field_message_1", + }, + SummaryFailure { + "fieldName": "field_2", + "groupName": undefined, + "message": "rejection_message_1", + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": { + "group": { + "field_1": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_4": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + }, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 3, + "tests": { + "field_1": { + "errorCount": 1, + "errors": [ + "field_message_1", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": { + "errorCount": 1, + "errors": [ + "rejection_message_1", + ], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_4": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`Stateful async tests > Merges skipped validations from previous suite 3`] = ` +SuiteSummary { + "errorCount": 5, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": "group", + "message": "field_1_group_message", + }, + SummaryFailure { + "fieldName": "field_4", + "groupName": "group", + "message": "field_4_group_message", + }, + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": "field_message_1", + }, + SummaryFailure { + "fieldName": "field_2", + "groupName": undefined, + "message": "rejection_message_1", + }, + SummaryFailure { + "fieldName": "field_3", + "groupName": undefined, + "message": "field_message_3", + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": { + "group": { + "field_1": SummaryBase { + "errorCount": 1, + "errors": [ + "field_1_group_message", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_4": SummaryBase { + "errorCount": 1, + "errors": [ + "field_4_group_message", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + }, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 7, + "tests": { + "field_1": { + "errorCount": 2, + "errors": [ + "field_1_group_message", + "field_message_1", + ], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": { + "errorCount": 1, + "errors": [ + "rejection_message_1", + ], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": { + "errorCount": 1, + "errors": [ + "field_message_3", + ], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_4": SummaryBase { + "errorCount": 1, + "errors": [ + "field_4_group_message", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; exports[`Stateful async tests Merges skipped validations from previous suite 1`] = ` { diff --git a/packages/vest/src/__tests__/__snapshots__/integration.stateful-tests.test.ts.snap b/packages/vest/src/__tests__/__snapshots__/integration.stateful-tests.test.ts.snap index 4ce52ac93..e2632f50d 100644 --- a/packages/vest/src/__tests__/__snapshots__/integration.stateful-tests.test.ts.snap +++ b/packages/vest/src/__tests__/__snapshots__/integration.stateful-tests.test.ts.snap @@ -1,4 +1,300 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`Stateful behavior > Should merge skipped fields with previous values 1`] = ` +{ + "done": [Function], + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": "field_statement_1", + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 1, + "tests": { + "field_1": SummaryBase { + "errorCount": 1, + "errors": [ + "field_statement_1", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_4": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_5": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`Stateful behavior > Should merge skipped fields with previous values 2`] = ` +{ + "done": [Function], + "errorCount": 3, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": "field_statement_1", + }, + SummaryFailure { + "fieldName": "field_5", + "groupName": undefined, + "message": "field_statement_5", + }, + SummaryFailure { + "fieldName": "field_5", + "groupName": undefined, + "message": "field_statement_6", + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 3, + "tests": { + "field_1": SummaryBase { + "errorCount": 1, + "errors": [ + "field_statement_1", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_4": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_5": { + "errorCount": 2, + "errors": [ + "field_statement_5", + "field_statement_6", + ], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`Stateful behavior > Should merge skipped fields with previous values 3`] = ` +{ + "done": [Function], + "errorCount": 4, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": "field_statement_1", + }, + SummaryFailure { + "fieldName": "field_2", + "groupName": undefined, + "message": "field_statement_2", + }, + SummaryFailure { + "fieldName": "field_5", + "groupName": undefined, + "message": "field_statement_5", + }, + SummaryFailure { + "fieldName": "field_5", + "groupName": undefined, + "message": "field_statement_6", + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 7, + "tests": { + "field_1": SummaryBase { + "errorCount": 1, + "errors": [ + "field_statement_1", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 1, + "errors": [ + "field_statement_2", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "field_4": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": true, + "warnCount": 1, + "warnings": [ + "field_statement_4", + ], + }, + "field_5": { + "errorCount": 2, + "errors": [ + "field_statement_5", + "field_statement_6", + ], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 1, + "warnings": [ + SummaryFailure { + "fieldName": "field_4", + "groupName": undefined, + "message": "field_statement_4", + }, + ], +} +`; exports[`Stateful behavior Should merge skipped fields with previous values 1`] = ` { @@ -296,6 +592,226 @@ exports[`Stateful behavior Should merge skipped fields with previous values 3`] } `; +exports[`more complex > Should run correctly 1`] = ` +SuiteSummary { + "errorCount": 0, + "errors": [], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 0, + "tests": {}, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`more complex > Should run correctly 2`] = ` +SuiteSummary { + "errorCount": 0, + "errors": [], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 2, + "tests": { + "confirm": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "password": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "username": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`more complex > Should run correctly 4`] = ` +SuiteSummary { + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "password", + "groupName": undefined, + "message": "password is required", + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 3, + "tests": { + "confirm": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "password": SummaryBase { + "errorCount": 1, + "errors": [ + "password is required", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "username": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`more complex > Should run correctly 6`] = ` +SuiteSummary { + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "password", + "groupName": undefined, + "message": "password is required", + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 3, + "tests": { + "confirm": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "password": SummaryBase { + "errorCount": 1, + "errors": [ + "password is required", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "username": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + exports[`more complex Should run correctly 1`] = ` SuiteSummary { "errorCount": 0, diff --git a/packages/vest/src/__tests__/integration.async-tests.test.ts b/packages/vest/src/__tests__/integration.async-tests.test.ts index 4d918a81d..c4d370b05 100644 --- a/packages/vest/src/__tests__/integration.async-tests.test.ts +++ b/packages/vest/src/__tests__/integration.async-tests.test.ts @@ -4,7 +4,7 @@ import { TestPromise } from '../testUtils/testPromise'; import { Modes } from '@/hooks/optional/Modes'; import { TTestSuite } from '@/testUtils/TVestMock'; -import * as vest from 'vest'; +import * as vest from '@/vest'; function genSuite() { return vest.create(() => { diff --git a/packages/vest/src/__tests__/integration.base.test.ts b/packages/vest/src/__tests__/integration.base.test.ts index a6e51c298..b56e680ba 100644 --- a/packages/vest/src/__tests__/integration.base.test.ts +++ b/packages/vest/src/__tests__/integration.base.test.ts @@ -1,4 +1,4 @@ -import * as vest from 'vest'; +import * as vest from '@/vest'; const suite = () => vest.create(() => { diff --git a/packages/vest/src/__tests__/integration.exclusive.test.ts b/packages/vest/src/__tests__/integration.exclusive.test.ts index 6f8fd57c8..3e4f7dffe 100644 --- a/packages/vest/src/__tests__/integration.exclusive.test.ts +++ b/packages/vest/src/__tests__/integration.exclusive.test.ts @@ -1,5 +1,5 @@ import { TTestSuite } from '@/testUtils/TVestMock'; -import * as vest from 'vest'; +import * as vest from '@/vest'; let suite: TTestSuite; diff --git a/packages/vest/src/__tests__/integration.stateful-async.test.ts b/packages/vest/src/__tests__/integration.stateful-async.test.ts index 8857a75ca..fb16cbb25 100644 --- a/packages/vest/src/__tests__/integration.stateful-async.test.ts +++ b/packages/vest/src/__tests__/integration.stateful-async.test.ts @@ -7,7 +7,7 @@ import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; import { Modes } from '@/hooks/optional/Modes'; import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; -import * as vest from 'vest'; +import * as vest from '@/vest'; type SuiteParams = { skip?: string; skipGroup?: true }; diff --git a/packages/vest/src/__tests__/integration.stateful-tests.test.ts b/packages/vest/src/__tests__/integration.stateful-tests.test.ts index d23f7ae90..522c37e33 100644 --- a/packages/vest/src/__tests__/integration.stateful-tests.test.ts +++ b/packages/vest/src/__tests__/integration.stateful-tests.test.ts @@ -1,7 +1,7 @@ import { enforce } from 'n4s'; import { Modes } from '@/hooks/optional/Modes'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('Stateful behavior', () => { let result; diff --git a/packages/vest/src/__tests__/isolate.test.ts b/packages/vest/src/__tests__/isolate.test.ts index 84b9a9046..57833e1b5 100644 --- a/packages/vest/src/__tests__/isolate.test.ts +++ b/packages/vest/src/__tests__/isolate.test.ts @@ -9,10 +9,8 @@ import { TDummyTest } from '../testUtils/testDummy'; describe('isolate', () => { let vest: TVestMock; let firstRun = true; - // eslint-disable-next-line no-unused-expressions - require('IsolateTest').IsolateTest; - // eslint-disable-next-line no-unused-expressions - require('IsolateEach').IsolateEach; + vi.importActual('@/core/isolate/IsolateTest/IsolateTest'); + vi.importActual('@/core/isolate/IsolateTest/IsolateEach'); let dummyTest: TDummyTest; let deferThrow: TDeferThrow; @@ -20,10 +18,9 @@ describe('isolate', () => { firstRun = true; const mock = mockThrowError(); deferThrow = mock.deferThrow; - // eslint-disable-next-line no-unused-expressions - require('IsolateTest').IsolateTest; - // eslint-disable-next-line no-unused-expressions - require('IsolateEach').IsolateEach; + + vi.importActual('@/core/isolate/IsolateTest/IsolateTest'); + vi.importActual('@/core/isolate/IsolateTest/IsolateEach'); vest = mock.vest; dummyTest = require('../testUtils/testDummy').dummyTest; }); diff --git a/packages/vest/src/__tests__/state_refill.test.ts b/packages/vest/src/__tests__/state_refill.test.ts index 92df7640f..9e1f99b62 100644 --- a/packages/vest/src/__tests__/state_refill.test.ts +++ b/packages/vest/src/__tests__/state_refill.test.ts @@ -1,5 +1,5 @@ import { Modes } from '@/hooks/optional/Modes'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('state refill', () => { it('Should refill test state according to the execution order', () => { diff --git a/packages/vest/src/core/__tests__/__snapshots__/runtime.test.ts.snap b/packages/vest/src/core/__tests__/__snapshots__/runtime.test.ts.snap index 7f6d7f260..428845f01 100644 --- a/packages/vest/src/core/__tests__/__snapshots__/runtime.test.ts.snap +++ b/packages/vest/src/core/__tests__/__snapshots__/runtime.test.ts.snap @@ -1,4 +1,504 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`useLoadSuite > Calling useLoadSuite should resume from loaded state 1`] = ` +{ + "$type": "Suite", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": [ + { + "$type": "Focused", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": { + "focusMode": 1, + "match": [ + "t5", + ], + "matchAll": false, + }, + "key": null, + "keys": null, + "output": undefined, + "parent": [Circular], + "status": "DONE", + }, + { + "$type": "Test", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": { + "fieldName": "t1", + "severity": "error", + "testFn": [Function], + }, + "key": null, + "keys": null, + "output": undefined, + "parent": [Circular], + "status": "FAILED", + }, + { + "$type": "Group", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": [ + { + "$type": "Test", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": { + "fieldName": "t2", + "groupName": "g1", + "message": "t2 message", + "severity": "error", + "testFn": [Function], + }, + "key": null, + "keys": null, + "output": undefined, + "parent": [Circular], + "status": "FAILED", + }, + { + "$type": "Test", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": { + "fieldName": "t3", + "groupName": "g1", + "severity": "error", + "testFn": [Function], + }, + "key": null, + "keys": null, + "output": undefined, + "parent": [Circular], + "status": "PASSING", + }, + { + "$type": "Test", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": { + "fieldName": "t4", + "groupName": "g1", + "severity": "warning", + "testFn": [Function], + }, + "key": null, + "keys": null, + "output": undefined, + "parent": [Circular], + "status": "WARNING", + }, + ], + "data": {}, + "key": null, + "keys": null, + "output": undefined, + "parent": [Circular], + "status": "DONE", + }, + { + "$type": "Test", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": { + "fieldName": "t5", + "severity": "error", + "testFn": [Function], + }, + "key": null, + "keys": null, + "output": undefined, + "parent": [Circular], + "status": "SKIPPED", + }, + { + "$type": "Each", + "abortController": AbortController {}, + "allowReorder": true, + "children": [ + { + "$type": "Test", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": { + "fieldName": "t6", + "severity": "error", + "testFn": [Function], + }, + "key": "a", + "keys": null, + "output": undefined, + "parent": [Circular], + "status": "FAILED", + }, + { + "$type": "Test", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": { + "fieldName": "t6", + "severity": "error", + "testFn": [Function], + }, + "key": "b", + "keys": null, + "output": undefined, + "parent": [Circular], + "status": "FAILED", + }, + ], + "data": {}, + "key": null, + "keys": { + "a": { + "$type": "Test", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": { + "fieldName": "t6", + "severity": "error", + "testFn": [Function], + }, + "key": "a", + "keys": null, + "output": undefined, + "parent": [Circular], + "status": "FAILED", + }, + "b": { + "$type": "Test", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": { + "fieldName": "t6", + "severity": "error", + "testFn": [Function], + }, + "key": "b", + "keys": null, + "output": undefined, + "parent": [Circular], + "status": "FAILED", + }, + }, + "output": undefined, + "parent": [Circular], + "status": "DONE", + }, + ], + "data": { + "optional": {}, + }, + "key": null, + "keys": null, + "output": { + "done": [Function], + "errorCount": 4, + "errors": [ + SummaryFailure { + "fieldName": "t1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "t2", + "groupName": "g1", + "message": "t2 message", + }, + SummaryFailure { + "fieldName": "t6", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "t6", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": { + "g1": { + "t2": SummaryBase { + "errorCount": 1, + "errors": [ + "t2 message", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "t3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "t4": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 1, + "warnings": [], + }, + }, + }, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 6, + "tests": { + "t1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "t2": SummaryBase { + "errorCount": 1, + "errors": [ + "t2 message", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "t3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "t4": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 1, + "warnings": [], + }, + "t5": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "t6": { + "errorCount": 2, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 1, + "warnings": [ + SummaryFailure { + "fieldName": "t4", + "groupName": "g1", + "message": undefined, + }, + ], + }, + "parent": null, + "status": "DONE", +} +`; + +exports[`useLoadSuite > Calling useLoadSuite should resume from loaded state 2`] = ` +SuiteSummary { + "errorCount": 4, + "errors": [ + SummaryFailure { + "fieldName": "t1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "t2", + "groupName": "g1", + "message": "t2 message", + }, + SummaryFailure { + "fieldName": "t6", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "t6", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": { + "g1": { + "t2": SummaryBase { + "errorCount": 1, + "errors": [ + "t2 message", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "t3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "t4": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 1, + "warnings": [], + }, + }, + }, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 6, + "tests": { + "t1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "t2": SummaryBase { + "errorCount": 1, + "errors": [ + "t2 message", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "t3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "t4": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 1, + "warnings": [], + }, + "t5": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "t6": { + "errorCount": 2, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 1, + "warnings": [ + SummaryFailure { + "fieldName": "t4", + "groupName": "g1", + "message": undefined, + }, + ], +} +`; exports[`useLoadSuite Calling useLoadSuite should resume from loaded state 1`] = ` { diff --git a/packages/vest/src/core/__tests__/runtime.test.ts b/packages/vest/src/core/__tests__/runtime.test.ts index 3738151be..2e6d523ab 100644 --- a/packages/vest/src/core/__tests__/runtime.test.ts +++ b/packages/vest/src/core/__tests__/runtime.test.ts @@ -1,4 +1,4 @@ -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('useLoadSuite', () => { it('Calling useLoadSuite should resume from loaded state', () => { diff --git a/packages/vest/src/core/test/__tests__/IsolateTest.test.ts b/packages/vest/src/core/test/__tests__/IsolateTest.test.ts index 1857e5a27..77a2130c3 100644 --- a/packages/vest/src/core/test/__tests__/IsolateTest.test.ts +++ b/packages/vest/src/core/test/__tests__/IsolateTest.test.ts @@ -4,7 +4,7 @@ import { TestPromise } from '../../../testUtils/testPromise'; import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; -import * as vest from 'vest'; +import * as vest from '@/vest'; import { mockIsolateTest } from '@/testUtils/vestMocks'; const fieldName = 'unicycle'; diff --git a/packages/vest/src/core/test/__tests__/__snapshots__/IsolateTest.test.ts.snap b/packages/vest/src/core/test/__tests__/__snapshots__/IsolateTest.test.ts.snap index cca6b3055..5c1505986 100644 --- a/packages/vest/src/core/test/__tests__/__snapshots__/IsolateTest.test.ts.snap +++ b/packages/vest/src/core/test/__tests__/__snapshots__/IsolateTest.test.ts.snap @@ -1,4 +1,42 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`IsolateTest > TestObject constructor 1`] = ` +{ + "$type": "UnitTest", + "children": [], + "data": { + "fieldName": "unicycle", + "message": "I am Root.", + "severity": "error", + "testFn": [MockFunction spy], + "type": "Test", + }, + "key": null, + "keys": {}, + "output": null, + "parent": null, + "status": "UNTESTED", +} +`; + +exports[`IsolateTest > testObject.warn > Should mark the test as warning 1`] = ` +{ + "$type": "UnitTest", + "children": [], + "data": { + "fieldName": "unicycle", + "message": "I am Root.", + "severity": "warning", + "testFn": [MockFunction spy], + "type": "Test", + }, + "key": null, + "keys": {}, + "output": null, + "parent": null, + "status": "UNTESTED", +} +`; exports[`IsolateTest TestObject constructor 1`] = ` { diff --git a/packages/vest/src/core/test/__tests__/__snapshots__/test.test.ts.snap b/packages/vest/src/core/test/__tests__/__snapshots__/test.test.ts.snap index 405ce559f..6f5c24f21 100644 --- a/packages/vest/src/core/test/__tests__/__snapshots__/test.test.ts.snap +++ b/packages/vest/src/core/test/__tests__/__snapshots__/test.test.ts.snap @@ -1,4 +1,222 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`Test Vest's \`test\` function > test params > creates a test with a message and with a key 1`] = `"[{"$type":"Test","data":{"severity":"error","fieldName":"field_name","message":"failure message"},"status":"PASSING","key":"keyboardcat"},{}]"`; + +exports[`Test Vest's \`test\` function > test params > creates a test without a key 1`] = ` +{ + "$type": "Test", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": { + "fieldName": "field_name", + "message": "failure message", + "severity": "error", + "testFn": [Function], + }, + "key": null, + "keys": null, + "output": undefined, + "parent": { + "$type": "Suite", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": [ + [Circular], + ], + "data": { + "optional": {}, + }, + "key": null, + "keys": null, + "output": { + "done": [Function], + "errorCount": 0, + "errors": [], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 1, + "tests": { + "field_name": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "parent": null, + "status": "DONE", + }, + "status": "PASSING", +} +`; + +exports[`Test Vest's \`test\` function > test params > creates a test without a message and with a key 1`] = ` +{ + "$type": "Test", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": { + "fieldName": "field_name", + "severity": "error", + "testFn": [Function], + }, + "key": "keyboardcat", + "keys": null, + "output": undefined, + "parent": { + "$type": "Suite", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": [ + [Circular], + ], + "data": { + "optional": {}, + }, + "key": null, + "keys": { + "keyboardcat": [Circular], + }, + "output": { + "done": [Function], + "errorCount": 0, + "errors": [], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 1, + "tests": { + "field_name": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "parent": null, + "status": "DONE", + }, + "status": "PASSING", +} +`; + +exports[`Test Vest's \`test\` function > test params > creates a test without a message and without a key 1`] = ` +{ + "$type": "Test", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": { + "fieldName": "field_name", + "severity": "error", + "testFn": [Function], + }, + "key": null, + "keys": null, + "output": undefined, + "parent": { + "$type": "Suite", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": [ + [Circular], + ], + "data": { + "optional": {}, + }, + "key": null, + "keys": null, + "output": { + "done": [Function], + "errorCount": 0, + "errors": [], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 1, + "tests": { + "field_name": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "parent": null, + "status": "DONE", + }, + "status": "PASSING", +} +`; exports[`Test Vest's \`test\` function test params creates a test with a message and with a key 1`] = `"[{"$type":"Test","data":{"severity":"error","fieldName":"field_name","message":"failure message"},"status":"PASSING","key":"keyboardcat"},{}]"`; diff --git a/packages/vest/src/core/test/__tests__/key.test.ts b/packages/vest/src/core/test/__tests__/key.test.ts index 184d83483..af727a167 100644 --- a/packages/vest/src/core/test/__tests__/key.test.ts +++ b/packages/vest/src/core/test/__tests__/key.test.ts @@ -4,7 +4,7 @@ import { TVestMock } from '../../../testUtils/TVestMock'; import mockThrowError from '../../../testUtils/mockThrowError'; import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('key', () => { describe('When key is provided', () => { diff --git a/packages/vest/src/core/test/__tests__/memo.test.ts b/packages/vest/src/core/test/__tests__/memo.test.ts index f8195ef43..ac6aa9c53 100644 --- a/packages/vest/src/core/test/__tests__/memo.test.ts +++ b/packages/vest/src/core/test/__tests__/memo.test.ts @@ -6,8 +6,8 @@ import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; import { Modes } from '@/hooks/optional/Modes'; import promisify from '@exports/promisify'; -import * as vest from 'vest'; -import { test as vestTest, enforce } from 'vest'; +import * as vest from '@/vest'; +import { test as vestTest, enforce } from '@/vest'; describe('test.memo', () => { describe('cache hit', () => { diff --git a/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts b/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts index 542d99481..9a94773e4 100644 --- a/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts +++ b/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts @@ -4,7 +4,7 @@ import { dummyTest } from '../../../testUtils/testDummy'; import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; import { Modes } from '@/hooks/optional/Modes'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('Merging of previous test runs', () => { let suite: TTestSuite; diff --git a/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts b/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts index 047080894..99298de48 100644 --- a/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts +++ b/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts @@ -2,7 +2,7 @@ import wait from 'wait'; import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('runAsyncTest', () => { describe('State Updates', () => { diff --git a/packages/vest/src/core/test/__tests__/test.test.ts b/packages/vest/src/core/test/__tests__/test.test.ts index 56dccb342..dd815ee85 100644 --- a/packages/vest/src/core/test/__tests__/test.test.ts +++ b/packages/vest/src/core/test/__tests__/test.test.ts @@ -7,8 +7,8 @@ import { TestPromise } from '../../../testUtils/testPromise'; import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; import { ErrorStrings } from '@/errors/ErrorStrings'; -import { enforce } from 'vest'; -import * as vest from 'vest'; +import { enforce } from '@/vest'; +import * as vest from '@/vest'; let testObject: TIsolateTest; diff --git a/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts b/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts index 120147913..fe4c0387d 100644 --- a/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts +++ b/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts @@ -1,4 +1,4 @@ -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('Test Function Payload', () => { describe('AbortSignal', () => { diff --git a/packages/vest/src/exports/__tests__/SuiteSerializer.test.ts b/packages/vest/src/exports/__tests__/SuiteSerializer.test.ts index 04edf66f5..65b40dfa8 100644 --- a/packages/vest/src/exports/__tests__/SuiteSerializer.test.ts +++ b/packages/vest/src/exports/__tests__/SuiteSerializer.test.ts @@ -1,6 +1,6 @@ import { SuiteSerializer } from '../SuiteSerializer'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('SuiteSerializer', () => { it('Should produce a valid serialized dump', () => { diff --git a/packages/vest/src/exports/__tests__/__snapshots__/SuiteSerializer.test.ts.snap b/packages/vest/src/exports/__tests__/__snapshots__/SuiteSerializer.test.ts.snap index de6445f54..dbc781ba3 100644 --- a/packages/vest/src/exports/__tests__/__snapshots__/SuiteSerializer.test.ts.snap +++ b/packages/vest/src/exports/__tests__/__snapshots__/SuiteSerializer.test.ts.snap @@ -1,7 +1,20 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`SuiteSerializer > Should produce a valid serialized dump 1`] = `"[{"0":"Suite","1":"9","2":{},"a":[{"0":"Focused","1":"9","2":{"focusMode":0,"match":["d"],"matchAll":false}},{"0":"3","1":"FAILED","2":{"4":"5","6":"d","7":"field_1_message"}},{"0":"3","1":"8","2":{"4":"5","6":"field_2","7":"field_2_message"}},{"0":"Group","1":"9","a":[{"0":"3","1":"8","2":{"4":"5","6":"e","7":"field_3_message_1","b":"c"}},{"0":"3","1":"8","2":{"4":"5","6":"e","7":"field_3_message_2","b":"c"}},{"0":"3","1":"8","2":{"4":"5","6":"field_4","7":"field_4_message","b":"c"}}]},{"0":"SkipWhen","1":"9","a":[{"0":"3","1":"8","2":{"4":"5","6":"field_5","7":"field_5_message"}}]}]},{"0":"$type","1":"status","2":"data","3":"Test","4":"severity","5":"error","6":"fieldName","7":"message","8":"SKIPPED","9":"DONE","a":"children","b":"groupName","c":"group_1","d":"field_1","e":"field_3"}]"`; exports[`SuiteSerializer Should produce a valid serialized dump 1`] = `"[{"0":"Suite","1":"9","2":{},"a":[{"0":"Focused","1":"9","2":{"focusMode":0,"match":["d"],"matchAll":false}},{"0":"3","1":"FAILED","2":{"4":"5","6":"d","7":"field_1_message"}},{"0":"3","1":"8","2":{"4":"5","6":"field_2","7":"field_2_message"}},{"0":"Group","1":"9","a":[{"0":"3","1":"8","2":{"4":"5","6":"e","7":"field_3_message_1","b":"c"}},{"0":"3","1":"8","2":{"4":"5","6":"e","7":"field_3_message_2","b":"c"}},{"0":"3","1":"8","2":{"4":"5","6":"field_4","7":"field_4_message","b":"c"}}]},{"0":"SkipWhen","1":"9","a":[{"0":"3","1":"8","2":{"4":"5","6":"field_5","7":"field_5_message"}}]}]},{"0":"$type","1":"status","2":"data","3":"Test","4":"severity","5":"error","6":"fieldName","7":"message","8":"SKIPPED","9":"DONE","a":"children","b":"groupName","c":"group_1","d":"field_1","e":"field_3"}]"`; +exports[`suite.resume > Running the suite after resuming > Sanity - suite should run as expected > Should have correct state after resuming 1`] = ` +{ + "field_1": [ + "field_1_message", + ], + "field_2": [ + "field_2_message", + ], +} +`; + exports[`suite.resume Running the suite after resuming Sanity - suite should run as expected Should have correct state after resuming 1`] = ` { "field_1": [ diff --git a/packages/vest/src/exports/__tests__/classnames.test.ts b/packages/vest/src/exports/__tests__/classnames.test.ts index 615692c7c..9f7a0110c 100644 --- a/packages/vest/src/exports/__tests__/classnames.test.ts +++ b/packages/vest/src/exports/__tests__/classnames.test.ts @@ -3,7 +3,7 @@ import classnames from '../classnames'; import promisify from '../promisify'; import { Modes } from '@/hooks/optional/Modes'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('Utility: classnames', () => { describe('When called without a vest result object', () => { @@ -21,14 +21,14 @@ describe('Utility: classnames', () => { describe('When called with a vest result object', () => { it('Should return a function', async () => { const validate = vest.create( - jest.fn(() => { + vi.fn(() => { dummyTest.failing('field_0'); }), ); expect(typeof classnames(validate())).toBe('function'); const promisifed = await promisify( vest.create( - jest.fn(() => { + vi.fn(() => { dummyTest.failing('field_0'); }), ), diff --git a/packages/vest/src/exports/__tests__/debounce.test.ts b/packages/vest/src/exports/__tests__/debounce.test.ts index 14a3073ae..d0b381ac1 100644 --- a/packages/vest/src/exports/__tests__/debounce.test.ts +++ b/packages/vest/src/exports/__tests__/debounce.test.ts @@ -1,14 +1,14 @@ import wait from 'wait'; import { TestFnPayload } from '@/core/test/TestTypes'; -import * as vest from 'vest'; -import debounce from 'vest/debounce'; +import * as vest from '@/vest'; +import debounce from '@exports/debounce'; describe('debounce', () => { describe('Sync test', () => { describe('Returning false', () => { it('Should debounce test function calls when used', () => { - const test = jest.fn(() => { + const test = vi.fn(() => { return false; }); @@ -34,7 +34,7 @@ describe('debounce', () => { describe('Throwing an error', () => { it('Should debounce test function calls when used', () => { - const test = jest.fn(() => { + const test = vi.fn(() => { throw new Error(); }); @@ -61,7 +61,7 @@ describe('debounce', () => { describe('Async test', () => { it('Should complete the async test after the delay', async () => { - const t = jest.fn(async () => { + const t = vi.fn(async () => { await wait(1000); vest.enforce(1).equals(2); }); @@ -85,7 +85,7 @@ describe('debounce', () => { describe('When delay met multiple times', () => { it('Should call once per completed delay', async () => { - const test = jest.fn(() => { + const test = vi.fn(() => { return false; }); @@ -116,7 +116,7 @@ describe('debounce', () => { describe('Debounced tests with non-debounced tests', () => { it('Should complete non-debounced tests immediately', () => { - const test = jest.fn(() => { + const test = vi.fn(() => { return false; }); @@ -141,7 +141,7 @@ describe('debounce', () => { describe('Multiple debounced fields', () => { it('Should conclude them on their own time', () => { - const t = jest.fn(() => { + const t = vi.fn(() => { return false; }); @@ -151,7 +151,7 @@ describe('debounce', () => { vest.test('test3', 'message', debounce(t, 2000)); }); - const control = jest.fn(); + const control = vi.fn(); return new Promise(done => { suite(); @@ -196,10 +196,10 @@ describe('debounce', () => { describe('Test payload', () => { describe('AbortSignal', () => { it('Should abort the test when signal is aborted', async () => { - const control = jest.fn(); + const control = vi.fn(); let run = 0; - const test = jest.fn(async (payload: TestFnPayload) => { + const test = vi.fn(async (payload: TestFnPayload) => { expect(payload.signal.aborted).toBe(false); await wait(50); // We should only abort on the first run because diff --git a/packages/vest/src/exports/__tests__/parser.test.ts b/packages/vest/src/exports/__tests__/parser.test.ts index 4fe6892fd..a1584a9c7 100644 --- a/packages/vest/src/exports/__tests__/parser.test.ts +++ b/packages/vest/src/exports/__tests__/parser.test.ts @@ -2,7 +2,7 @@ import * as suiteDummy from '../../testUtils/suiteDummy'; import { ser } from '../../testUtils/suiteDummy'; import { parse } from '../parser'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('parser.parse', () => { describe('parse().invalid', () => { diff --git a/packages/vest/src/exports/__tests__/promisify.test.ts b/packages/vest/src/exports/__tests__/promisify.test.ts index 409b743e2..e48386a46 100644 --- a/packages/vest/src/exports/__tests__/promisify.test.ts +++ b/packages/vest/src/exports/__tests__/promisify.test.ts @@ -1,22 +1,23 @@ import { faker } from '@faker-js/faker'; +import { Mock } from 'vitest'; import { dummyTest } from '../../testUtils/testDummy'; import { TestPromise } from '../../testUtils/testPromise'; import promisify from '../promisify'; import { TFieldName } from '@/suiteResult/SuiteResultTypes'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('Utility: promisify', () => { - let validatorFn: jest.Mock, any>; + let validatorFn: Mock; let validateAsync: ( ...args: any[] ) => Promise>; beforeEach(() => { - validatorFn = jest.fn( + validatorFn = vi.fn( vest.create( - jest.fn(() => { + vi.fn(() => { dummyTest.failing('field_0'); }), ), @@ -34,7 +35,7 @@ describe('Utility: promisify', () => { describe('Return value', () => { it('should be a function', () => { - expect(typeof promisify(jest.fn())).toBe('function'); + expect(typeof promisify(vi.fn())).toBe('function'); }); it('should be a promise', () => diff --git a/packages/vest/src/exports/debounce.ts b/packages/vest/src/exports/debounce.ts index d48288136..c31130cf7 100644 --- a/packages/vest/src/exports/debounce.ts +++ b/packages/vest/src/exports/debounce.ts @@ -1,8 +1,8 @@ -import { registerReconciler } from 'vest'; import { CB, isPromise, Nullable } from 'vest-utils'; import { Isolate, TIsolate, IsolateSelectors } from 'vestjs-runtime'; import { TestFn, TestFnPayload } from '@/core/test/TestTypes'; +import { registerReconciler } from '@/vest'; const isolateType = 'Debounce'; diff --git a/packages/vest/src/exports/parser.ts b/packages/vest/src/exports/parser.ts index 19ddf8aa4..beecf4d59 100644 --- a/packages/vest/src/exports/parser.ts +++ b/packages/vest/src/exports/parser.ts @@ -1,9 +1,10 @@ -import { suiteSelectors, SuiteSummary } from 'vest'; import { hasOwnProperty, invariant, isNullish, isPositive } from 'vest-utils'; import { ErrorStrings } from '../errors/ErrorStrings'; import { TFieldName, TGroupName } from '../suiteResult/SuiteResultTypes'; +import { suiteSelectors, SuiteSummary } from '@/vest'; + export function parse( summary: SuiteSummary, ): ParsedVestObject { diff --git a/packages/vest/src/hooks/__tests__/__snapshots__/include.test.ts.snap b/packages/vest/src/hooks/__tests__/__snapshots__/include.test.ts.snap index a36650933..2bd1ee47e 100644 --- a/packages/vest/src/hooks/__tests__/__snapshots__/include.test.ts.snap +++ b/packages/vest/src/hooks/__tests__/__snapshots__/include.test.ts.snap @@ -1,4 +1,1069 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`include > Field is excluded via \`skip\` > Should disregard \`include.when\` and avoid running the test 1`] = ` +{ + "done": [Function], + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "field_2", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 1, + "tests": { + "field_1": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`include > Field is excluded via \`skip\` > Should disregard \`include\` and avoid running the test 1`] = ` +{ + "done": [Function], + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "field_2", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 1, + "tests": { + "field_1": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`include > Test is excluded via \`skip.group\` > Should disregard \`include.when\` and avoid running the test 1`] = ` +{ + "done": [Function], + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": { + "g1": { + "field_1": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + }, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 1, + "tests": { + "field_1": { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`include > Test is excluded via \`skip.group\` > Should disregard \`include\` and avoid running the test 1`] = ` +{ + "done": [Function], + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": { + "g1": { + "field_1": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + }, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 1, + "tests": { + "field_1": { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`include > Test is excluded via \`skipWhen\` > Should disregard \`include.when\` and avoid running the matching tests 1`] = ` +{ + "done": [Function], + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 1, + "tests": { + "field_1": { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`include > Test is excluded via \`skipWhen\` > Should disregard \`include\` and avoid running the matching tests 1`] = ` +{ + "done": [Function], + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 1, + "tests": { + "field_1": { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`include > There is an \`onlyd\` field > \`include\` is run as-is without modifiers > Should run the included test along with the onlyd test 1`] = ` +{ + "done": [Function], + "errorCount": 2, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "field_2", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 2, + "tests": { + "field_1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`include > There is an \`onlyd\` field > include().when() > \`when\` param is a boolean > when \`false\` > Should skip run included field 1`] = ` +{ + "done": [Function], + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 1, + "tests": { + "field_1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`include > There is an \`onlyd\` field > include().when() > \`when\` param is a boolean > when \`true\` > Should run included field 1`] = ` +{ + "done": [Function], + "errorCount": 2, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "field_2", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 2, + "tests": { + "field_1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`include > There is an \`onlyd\` field > include().when() > \`when\` param is a function > Callback evaluation > Should evaluate per test run 1`] = ` +{ + "done": [Function], + "errorCount": 2, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 2, + "tests": { + "field_1": { + "errorCount": 2, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`include > There is an \`onlyd\` field > include().when() > \`when\` param is a function > when returning\`false\` > Should skip run included field 1`] = ` +{ + "done": [Function], + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 1, + "tests": { + "field_1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`include > There is an \`onlyd\` field > include().when() > \`when\` param is a function > when returning \`true\` > Should run included field 1`] = ` +{ + "done": [Function], + "errorCount": 2, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "field_2", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 2, + "tests": { + "field_1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`include > There is an \`onlyd\` field > include().when() > \`when\` param is a string > \`when\` param is a name of a non-included field > Should avoid running the included field 1`] = ` +{ + "done": [Function], + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 1, + "tests": { + "field_1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`include > There is an \`onlyd\` field > include().when() > \`when\` param is a string > \`when\` param is a name of a skipped field > Should avoid running the included field 1`] = ` +{ + "done": [Function], + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 1, + "tests": { + "field_1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`include > There is an \`onlyd\` field > include().when() > \`when\` param is a string > \`when\` param is a name of an onlyd field > Should run included field along with the onlyd field 1`] = ` +{ + "done": [Function], + "errorCount": 2, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "field_2", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 2, + "tests": { + "field_1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`include > When no \`skip\` or \`only\` > include has no effect 1`] = ` +{ + "done": [Function], + "errorCount": 2, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "field_2", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 2, + "tests": { + "field_1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`include > When no \`skip\` or \`only\` > include().when has no effect 1`] = ` +{ + "done": [Function], + "errorCount": 2, + "errors": [ + SummaryFailure { + "fieldName": "field_1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "field_2", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 2, + "tests": { + "field_1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; exports[`include Field is excluded via \`skip\` Should disregard \`include.when\` and avoid running the test 1`] = ` { diff --git a/packages/vest/src/hooks/__tests__/include.test.ts b/packages/vest/src/hooks/__tests__/include.test.ts index 632b7aeed..6f345f53a 100644 --- a/packages/vest/src/hooks/__tests__/include.test.ts +++ b/packages/vest/src/hooks/__tests__/include.test.ts @@ -1,5 +1,5 @@ import { Modes } from '@/hooks/optional/Modes'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('include', () => { let cb1 = vi.fn(), diff --git a/packages/vest/src/hooks/__tests__/mode.test.ts b/packages/vest/src/hooks/__tests__/mode.test.ts index 6eda320bb..06b930e35 100644 --- a/packages/vest/src/hooks/__tests__/mode.test.ts +++ b/packages/vest/src/hooks/__tests__/mode.test.ts @@ -4,8 +4,8 @@ import wait from 'wait'; import { dummyTest } from '../../testUtils/testDummy'; import { Modes } from '@/hooks/optional/Modes'; -import { create, only, group, mode } from 'vest'; -import * as Vest from 'vest'; +import { create, only, group, mode } from '@/vest'; +import * as Vest from '@/vest'; describe('mode', () => { let suite: TTestSuite; diff --git a/packages/vest/src/hooks/__tests__/warn.test.ts b/packages/vest/src/hooks/__tests__/warn.test.ts index a14ae7c2c..32d6362ba 100644 --- a/packages/vest/src/hooks/__tests__/warn.test.ts +++ b/packages/vest/src/hooks/__tests__/warn.test.ts @@ -2,7 +2,7 @@ import { faker } from '@faker-js/faker'; import { ErrorStrings } from '@/errors/ErrorStrings'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; -import * as vest from 'vest'; +import * as vest from '@/vest'; const { create, test, warn } = vest; diff --git a/packages/vest/src/hooks/focused/__tests__/__snapshots__/focused.test.ts.snap b/packages/vest/src/hooks/focused/__tests__/__snapshots__/focused.test.ts.snap index 8fc8ee4fa..7b9cbd90b 100644 --- a/packages/vest/src/hooks/focused/__tests__/__snapshots__/focused.test.ts.snap +++ b/packages/vest/src/hooks/focused/__tests__/__snapshots__/focused.test.ts.snap @@ -1,4 +1,168 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`Top Level Focus > Top Level Skip > When passing false > Should run all fields 1`] = ` +Promise { + "done": [Function], + "dump": [Function], + "errorCount": 3, + "errors": [ + SummaryFailure { + "fieldName": "F1", + "groupName": undefined, + "message": "F1 error", + }, + SummaryFailure { + "fieldName": "F2", + "groupName": undefined, + "message": "F2 error", + }, + SummaryFailure { + "fieldName": "F3", + "groupName": undefined, + "message": "F3 error", + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 3, + "tests": { + "F1": SummaryBase { + "errorCount": 1, + "errors": [ + "F1 error", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "F2": SummaryBase { + "errorCount": 1, + "errors": [ + "F2 error", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "F3": SummaryBase { + "errorCount": 1, + "errors": [ + "F3 error", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`Top Level Focus > Top Level Skip > When passing undefined > Should run all fields 1`] = ` +Promise { + "done": [Function], + "dump": [Function], + "errorCount": 3, + "errors": [ + SummaryFailure { + "fieldName": "F1", + "groupName": undefined, + "message": "F1 error", + }, + SummaryFailure { + "fieldName": "F2", + "groupName": undefined, + "message": "F2 error", + }, + SummaryFailure { + "fieldName": "F3", + "groupName": undefined, + "message": "F3 error", + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 3, + "tests": { + "F1": SummaryBase { + "errorCount": 1, + "errors": [ + "F1 error", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "F2": SummaryBase { + "errorCount": 1, + "errors": [ + "F2 error", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "F3": SummaryBase { + "errorCount": 1, + "errors": [ + "F3 error", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; exports[`Top Level Focus Top Level Skip When passing false Should run all fields 1`] = ` Promise { diff --git a/packages/vest/src/hooks/focused/__tests__/focused.test.ts b/packages/vest/src/hooks/focused/__tests__/focused.test.ts index 41f103ed8..847e597ec 100644 --- a/packages/vest/src/hooks/focused/__tests__/focused.test.ts +++ b/packages/vest/src/hooks/focused/__tests__/focused.test.ts @@ -1,6 +1,6 @@ import { CB } from 'vest-utils'; -import * as vest from 'vest'; +import * as vest from '@/vest'; enum Fields { F1 = 'F1', diff --git a/packages/vest/src/hooks/optional/__tests__/optional.test.ts b/packages/vest/src/hooks/optional/__tests__/optional.test.ts index e48acb6bc..e92c66481 100644 --- a/packages/vest/src/hooks/optional/__tests__/optional.test.ts +++ b/packages/vest/src/hooks/optional/__tests__/optional.test.ts @@ -2,7 +2,7 @@ import { TTestSuite } from '@/testUtils/TVestMock'; import { BlankValue } from 'vest-utils'; import wait from 'wait'; -import * as vest from 'vest'; +import * as vest from '@/vest'; vi.useFakeTimers(); diff --git a/packages/vest/src/isolates/__tests__/__snapshots__/each.test.ts.snap b/packages/vest/src/isolates/__tests__/__snapshots__/each.test.ts.snap index b188802e4..bd6f47e81 100644 --- a/packages/vest/src/isolates/__tests__/__snapshots__/each.test.ts.snap +++ b/packages/vest/src/isolates/__tests__/__snapshots__/each.test.ts.snap @@ -1,3 +1,5 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`each > When callback is not a function > should throw 1`] = `[Error: Each must be called with a function]`; exports[`each When callback is not a function should throw 1`] = `"Each must be called with a function"`; diff --git a/packages/vest/src/isolates/__tests__/__snapshots__/group.test.ts.snap b/packages/vest/src/isolates/__tests__/__snapshots__/group.test.ts.snap index c041fb135..af7e652e3 100644 --- a/packages/vest/src/isolates/__tests__/__snapshots__/group.test.ts.snap +++ b/packages/vest/src/isolates/__tests__/__snapshots__/group.test.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`named group Focus only group only Should skip all tests except \`only\` tests within the group 1`] = ` +exports[`named group > Focus > only > group only > Should skip all tests except \`only\` tests within the group 1`] = ` SuiteSummary { "errorCount": 4, "errors": [ @@ -138,7 +138,7 @@ SuiteSummary { } `; -exports[`named group Focus only top level only should skip all tests except \`only\` tests 1`] = ` +exports[`named group > Focus > only > top level only > should skip all tests except \`only\` tests 1`] = ` SuiteSummary { "errorCount": 3, "errors": [ @@ -271,7 +271,7 @@ SuiteSummary { } `; -exports[`named group Focus skip inside the group should skip only within the group 1`] = ` +exports[`named group > Focus > skip inside the group > should skip only within the group 1`] = ` SuiteSummary { "errorCount": 3, "errors": [ @@ -357,7 +357,7 @@ SuiteSummary { } `; -exports[`named group Focus skip inside the group should skip only within the group, not the next group 1`] = ` +exports[`named group > Focus > skip inside the group > should skip only within the group, not the next group 1`] = ` SuiteSummary { "errorCount": 3, "errors": [ @@ -454,7 +454,7 @@ SuiteSummary { } `; -exports[`named group Focus skip inside the group skip(true) should skip only within the group 1`] = ` +exports[`named group > Focus > skip inside the group > skip(true) > should skip only within the group 1`] = ` SuiteSummary { "errorCount": 5, "errors": [ @@ -579,7 +579,7 @@ SuiteSummary { } `; -exports[`named group Focus skip outside of group Should skip \`skipped\` tests both inside and outside the group 1`] = ` +exports[`named group > Focus > skip outside of group > Should skip \`skipped\` tests both inside and outside the group 1`] = ` SuiteSummary { "errorCount": 1, "errors": [ @@ -655,7 +655,7 @@ SuiteSummary { } `; -exports[`named group Multiple groups Should run the tests within the groups 1`] = ` +exports[`named group > Multiple groups > Should run the tests within the groups 1`] = ` SuiteSummary { "errorCount": 5, "errors": [ @@ -798,7 +798,7 @@ SuiteSummary { } `; -exports[`named group Should run the tests within the group 1`] = ` +exports[`named group > Should run the tests within the group 1`] = ` SuiteSummary { "errorCount": 3, "errors": [ @@ -902,6 +902,1247 @@ SuiteSummary { } `; +exports[`named group Focus only group only Should skip all tests except \`only\` tests within the group 1`] = ` +SuiteSummary { + "errorCount": 4, + "errors": [ + SummaryFailure { + "fieldName": "f1", + "groupName": "g1", + "message": undefined, + }, + SummaryFailure { + "fieldName": "f1", + "groupName": "g2", + "message": undefined, + }, + SummaryFailure { + "fieldName": "f2", + "groupName": "g2", + "message": undefined, + }, + SummaryFailure { + "fieldName": "f3", + "groupName": "g2", + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": { + "g1": { + "f1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "g2": { + "f1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f3": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + }, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 4, + "tests": { + "f1": { + "errorCount": 2, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f3": { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`named group Focus only top level only should skip all tests except \`only\` tests 1`] = ` +SuiteSummary { + "errorCount": 3, + "errors": [ + SummaryFailure { + "fieldName": "f1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "f1", + "groupName": "g1", + "message": undefined, + }, + SummaryFailure { + "fieldName": "f1", + "groupName": "g2", + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": { + "g1": { + "f1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "g2": { + "f1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + }, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 3, + "tests": { + "f1": { + "errorCount": 3, + "errors": [], + "pendingCount": 0, + "testCount": 3, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f3": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`named group Focus skip inside the group should skip only within the group 1`] = ` +SuiteSummary { + "errorCount": 3, + "errors": [ + SummaryFailure { + "fieldName": "f1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "f1", + "groupName": "g1", + "message": undefined, + }, + SummaryFailure { + "fieldName": "f2", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": { + "g1": { + "f1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + }, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 3, + "tests": { + "f1": { + "errorCount": 2, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`named group Focus skip inside the group should skip only within the group, not the next group 1`] = ` +SuiteSummary { + "errorCount": 3, + "errors": [ + SummaryFailure { + "fieldName": "f1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "f1", + "groupName": "g1", + "message": undefined, + }, + SummaryFailure { + "fieldName": "f2", + "groupName": "g2", + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": { + "g1": { + "f1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "g2": { + "f2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + }, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 3, + "tests": { + "f1": { + "errorCount": 2, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`named group Focus skip inside the group skip(true) should skip only within the group 1`] = ` +SuiteSummary { + "errorCount": 5, + "errors": [ + SummaryFailure { + "fieldName": "f2", + "groupName": "g2", + "message": undefined, + }, + SummaryFailure { + "fieldName": "f3", + "groupName": "g2", + "message": undefined, + }, + SummaryFailure { + "fieldName": "f1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "f2", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "f3", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": { + "g1": { + "f1": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "g2": { + "f2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f3": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + }, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 5, + "tests": { + "f1": { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": { + "errorCount": 2, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f3": { + "errorCount": 2, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`named group Focus skip outside of group Should skip \`skipped\` tests both inside and outside the group 1`] = ` +SuiteSummary { + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "f2", + "groupName": "g1", + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": { + "g1": { + "f1": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + }, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 1, + "tests": { + "f1": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`named group Multiple groups Should run the tests within the groups 1`] = ` +SuiteSummary { + "errorCount": 5, + "errors": [ + SummaryFailure { + "fieldName": "f1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "f1", + "groupName": "g1", + "message": undefined, + }, + SummaryFailure { + "fieldName": "f2", + "groupName": "g1", + "message": undefined, + }, + SummaryFailure { + "fieldName": "f1", + "groupName": "g2", + "message": undefined, + }, + SummaryFailure { + "fieldName": "f2", + "groupName": "g2", + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": { + "g1": { + "f1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + }, + "g2": { + "f1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + }, + }, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 7, + "tests": { + "f1": { + "errorCount": 3, + "errors": [], + "pendingCount": 0, + "testCount": 3, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": { + "errorCount": 2, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f3": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`named group Should run the tests within the group 1`] = ` +SuiteSummary { + "errorCount": 3, + "errors": [ + SummaryFailure { + "fieldName": "f1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "f1", + "groupName": "g1", + "message": undefined, + }, + SummaryFailure { + "fieldName": "f2", + "groupName": "g1", + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": { + "g1": { + "f1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + }, + }, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 4, + "tests": { + "f1": { + "errorCount": 2, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`unnamed groups > Should complete without adding the group to the results object 1`] = ` +SuiteSummary { + "errorCount": 3, + "errors": [ + SummaryFailure { + "fieldName": "f1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "f2", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "f3", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 3, + "tests": { + "f1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f3": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`unnamed groups > Should run tests normally 1`] = ` +SuiteSummary { + "errorCount": 3, + "errors": [ + SummaryFailure { + "fieldName": "f1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "f2", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "f3", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 3, + "tests": { + "f1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f3": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`unnamed groups > With skip(true) > Should skip all tests in group 1`] = ` +SuiteSummary { + "errorCount": 0, + "errors": [], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 0, + "tests": { + "f1": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`unnamed groups > with only > Should only run the tests specified by only 1`] = ` +SuiteSummary { + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "f1", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 1, + "tests": { + "f1": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`unnamed groups > with skip > Should skip the tests specified by skip 1`] = ` +SuiteSummary { + "errorCount": 2, + "errors": [ + SummaryFailure { + "fieldName": "f2", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "f3", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 2, + "tests": { + "f1": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f3": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + exports[`unnamed groups Should complete without adding the group to the results object 1`] = ` SuiteSummary { "errorCount": 3, diff --git a/packages/vest/src/isolates/__tests__/__snapshots__/omitWhen.test.ts.snap b/packages/vest/src/isolates/__tests__/__snapshots__/omitWhen.test.ts.snap index 67b4a2a16..27fdcde81 100644 --- a/packages/vest/src/isolates/__tests__/__snapshots__/omitWhen.test.ts.snap +++ b/packages/vest/src/isolates/__tests__/__snapshots__/omitWhen.test.ts.snap @@ -1,4 +1,542 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`omitWhen > When conditional is falsy > boolean conditional > Should have all tests within the omit block referenced in the result 1`] = ` +{ + "field_1": { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_4": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, +} +`; + +exports[`omitWhen > When conditional is falsy > boolean conditional > Should run tests normally 1`] = ` +{ + "field_1": { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_4": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, +} +`; + +exports[`omitWhen > When conditional is falsy > boolean conditional > Should run tests normally 2`] = ` +{ + "field_1": { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_4": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, +} +`; + +exports[`omitWhen > When conditional is falsy > function conditional > Should have all tests within the omit block referenced in the result 1`] = ` +{ + "field_1": { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_4": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, +} +`; + +exports[`omitWhen > When conditional is falsy > function conditional > Should run tests normally 1`] = ` +{ + "field_1": { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_4": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, +} +`; + +exports[`omitWhen > When conditional is falsy > function conditional > Should run tests normally 2`] = ` +{ + "field_1": { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_4": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, +} +`; + +exports[`omitWhen > When conditional is truthy > boolean conditional > Should avoid running the omitted tests 1`] = ` +SuiteSummary { + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "field_2", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 2, + "tests": { + "field_1": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "field_4": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`omitWhen > When conditional is truthy > boolean conditional > Should skip and not run omitted fields when no filter provided 1`] = ` +SuiteSummary { + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "field_2", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 2, + "tests": { + "field_1": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "field_4": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`omitWhen > When conditional is truthy > function conditional > Should avoid running the omitted tests 1`] = ` +SuiteSummary { + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "field_2", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 2, + "tests": { + "field_1": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "field_4": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`omitWhen > When conditional is truthy > function conditional > Should skip and not run omitted fields when no filter provided 1`] = ` +SuiteSummary { + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "field_2", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 2, + "tests": { + "field_1": { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "field_2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field_3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "field_4": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; exports[`omitWhen When conditional is falsy boolean conditional Should have all tests within the omit block referenced in the result 1`] = ` { diff --git a/packages/vest/src/isolates/__tests__/__snapshots__/skipWhen.test.ts.snap b/packages/vest/src/isolates/__tests__/__snapshots__/skipWhen.test.ts.snap index c21e1ac47..9bf98fbc4 100644 --- a/packages/vest/src/isolates/__tests__/__snapshots__/skipWhen.test.ts.snap +++ b/packages/vest/src/isolates/__tests__/__snapshots__/skipWhen.test.ts.snap @@ -1,4 +1,146 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`skipWhen > Should pass result draft to the functional condition 1`] = ` +SuiteSummary { + "errorCount": 0, + "errors": [], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 0, + "tests": {}, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`skipWhen > Should pass result draft to the functional condition 2`] = ` +SuiteSummary { + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "f1", + "groupName": undefined, + "message": "msg", + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 1, + "tests": { + "f1": SummaryBase { + "errorCount": 1, + "errors": [ + "msg", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`skipWhen > Should pass result draft to the functional condition 3`] = ` +SuiteSummary { + "errorCount": 2, + "errors": [ + SummaryFailure { + "fieldName": "f1", + "groupName": undefined, + "message": "msg", + }, + SummaryFailure { + "fieldName": "f2", + "groupName": undefined, + "message": "msg", + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 2, + "tests": { + "f1": SummaryBase { + "errorCount": 1, + "errors": [ + "msg", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": SummaryBase { + "errorCount": 1, + "errors": [ + "msg", + ], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; exports[`skipWhen Should pass result draft to the functional condition 1`] = ` SuiteSummary { diff --git a/packages/vest/src/isolates/__tests__/each.test.ts b/packages/vest/src/isolates/__tests__/each.test.ts index f0be1aa33..7fae393fe 100644 --- a/packages/vest/src/isolates/__tests__/each.test.ts +++ b/packages/vest/src/isolates/__tests__/each.test.ts @@ -3,7 +3,7 @@ import { TDeferThrow } from 'vest-utils/deferThrow'; import { TVestMock } from '../../testUtils/TVestMock'; import mockThrowError from '../../testUtils/mockThrowError'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('each', () => { describe('When callback is not a function', () => { diff --git a/packages/vest/src/isolates/__tests__/group.test.ts b/packages/vest/src/isolates/__tests__/group.test.ts index 072d8e1aa..6f8096580 100644 --- a/packages/vest/src/isolates/__tests__/group.test.ts +++ b/packages/vest/src/isolates/__tests__/group.test.ts @@ -1,4 +1,4 @@ -import * as vest from 'vest'; +import * as vest from '@/vest'; enum GroupNames { G1 = 'g1', diff --git a/packages/vest/src/isolates/__tests__/omitWhen.test.ts b/packages/vest/src/isolates/__tests__/omitWhen.test.ts index eea498f6b..366f8331f 100644 --- a/packages/vest/src/isolates/__tests__/omitWhen.test.ts +++ b/packages/vest/src/isolates/__tests__/omitWhen.test.ts @@ -1,8 +1,8 @@ import { Maybe } from 'vest-utils'; import { TTestSuite } from '@/testUtils/TVestMock'; -import * as vest from 'vest'; -import { omitWhen, only } from 'vest'; +import * as vest from '@/vest'; +import { omitWhen, only } from '@/vest'; describe('omitWhen', () => { let suite: TTestSuite; diff --git a/packages/vest/src/isolates/__tests__/skipWhen.test.ts b/packages/vest/src/isolates/__tests__/skipWhen.test.ts index 08da91510..9dd0ee30c 100644 --- a/packages/vest/src/isolates/__tests__/skipWhen.test.ts +++ b/packages/vest/src/isolates/__tests__/skipWhen.test.ts @@ -2,7 +2,7 @@ import { TTestSuite } from '@/testUtils/TVestMock'; import { dummyTest } from '../../testUtils/testDummy'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('skipWhen', () => { let fn = vi.fn(); diff --git a/packages/vest/src/suite/__tests__/__snapshots__/create.test.ts.snap b/packages/vest/src/suite/__tests__/__snapshots__/create.test.ts.snap index 307b90d1a..8155a15e7 100644 --- a/packages/vest/src/suite/__tests__/__snapshots__/create.test.ts.snap +++ b/packages/vest/src/suite/__tests__/__snapshots__/create.test.ts.snap @@ -1,4 +1,94 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`Test createSuite module > Initial run > Should be able to get the suite from the result of createSuite 1`] = ` +SuiteSummary { + "errorCount": 0, + "errors": [], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 0, + "tests": {}, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`Test createSuite module > Initial run > Should initialize with an empty result object 1`] = ` +SuiteSummary { + "errorCount": 0, + "errors": [], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 0, + "tests": {}, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + +exports[`Test createSuite module > Test suite Arguments > allows omitting suite name 1`] = ` +SuiteSummary { + "errorCount": 0, + "errors": [], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 0, + "tests": {}, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; exports[`Test createSuite module Initial run Should be able to get the suite from the result of createSuite 1`] = ` SuiteSummary { diff --git a/packages/vest/src/suite/__tests__/create.test.ts b/packages/vest/src/suite/__tests__/create.test.ts index 60f4889a0..036956c5d 100644 --- a/packages/vest/src/suite/__tests__/create.test.ts +++ b/packages/vest/src/suite/__tests__/create.test.ts @@ -5,7 +5,7 @@ import { dummyTest } from '../../testUtils/testDummy'; import { TestPromise } from '../../testUtils/testPromise'; import { ErrorStrings } from '@/errors/ErrorStrings'; -import { create } from 'vest'; +import { create } from '@/vest'; describe('Test createSuite module', () => { describe('Test suite Arguments', () => { diff --git a/packages/vest/src/suite/__tests__/remove.test.ts b/packages/vest/src/suite/__tests__/remove.test.ts index 4c2d119cc..8848ef61c 100644 --- a/packages/vest/src/suite/__tests__/remove.test.ts +++ b/packages/vest/src/suite/__tests__/remove.test.ts @@ -3,7 +3,7 @@ import wait from 'wait'; import { dummyTest } from '../../testUtils/testDummy'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('suite.remove', () => { it('Should remove field from validation result', async () => { diff --git a/packages/vest/src/suite/__tests__/resetField.test.ts b/packages/vest/src/suite/__tests__/resetField.test.ts index 3abe3d8a6..e1b38690b 100644 --- a/packages/vest/src/suite/__tests__/resetField.test.ts +++ b/packages/vest/src/suite/__tests__/resetField.test.ts @@ -1,5 +1,5 @@ import { TTestSuite } from '@/testUtils/TVestMock'; -import { create, test } from 'vest'; +import { create, test } from '@/vest'; describe('suite.resetField', () => { let suite: TTestSuite; diff --git a/packages/vest/src/suite/__tests__/staticSuite.test.ts b/packages/vest/src/suite/__tests__/staticSuite.test.ts index 3bc6be3a7..74d46e4ee 100644 --- a/packages/vest/src/suite/__tests__/staticSuite.test.ts +++ b/packages/vest/src/suite/__tests__/staticSuite.test.ts @@ -2,8 +2,8 @@ import wait from 'wait'; import { VestIsolateType } from '@/core/isolate/VestIsolateType'; import { SuiteSerializer } from '@exports/SuiteSerializer'; -import * as vest from 'vest'; -import { staticSuite } from 'vest'; +import * as vest from '@/vest'; +import { staticSuite } from '@/vest'; describe('staticSuite', () => { it('Should return a function', () => { diff --git a/packages/vest/src/suite/__tests__/subscribe.test.ts b/packages/vest/src/suite/__tests__/subscribe.test.ts index 60a0418c2..ab32674ad 100644 --- a/packages/vest/src/suite/__tests__/subscribe.test.ts +++ b/packages/vest/src/suite/__tests__/subscribe.test.ts @@ -2,7 +2,7 @@ import { enforce } from 'n4s'; import wait from 'wait'; import { SuiteSerializer } from '@exports/SuiteSerializer'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('suite.subscribe', () => { it('Should be a function', () => { diff --git a/packages/vest/src/suite/__tests__/suite.dump.ts b/packages/vest/src/suite/__tests__/suite.dump.ts index 11594ef7d..7d361f133 100644 --- a/packages/vest/src/suite/__tests__/suite.dump.ts +++ b/packages/vest/src/suite/__tests__/suite.dump.ts @@ -1,4 +1,4 @@ -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('SuiteSerializer', () => { it('Should produce a valid serialized dump', () => { diff --git a/packages/vest/src/suite/__tests__/suiteSelectorsOnSuite.test.ts b/packages/vest/src/suite/__tests__/suiteSelectorsOnSuite.test.ts index 216bb20c0..ed6b3a440 100644 --- a/packages/vest/src/suite/__tests__/suiteSelectorsOnSuite.test.ts +++ b/packages/vest/src/suite/__tests__/suiteSelectorsOnSuite.test.ts @@ -1,5 +1,5 @@ import { TTestSuite } from '@/testUtils/TVestMock'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('Suite Selectors on Suite', () => { let suite: TTestSuite; diff --git a/packages/vest/src/suite/__tests__/typedSuite.test.ts b/packages/vest/src/suite/__tests__/typedSuite.test.ts index 8ee47aa65..80db206d8 100644 --- a/packages/vest/src/suite/__tests__/typedSuite.test.ts +++ b/packages/vest/src/suite/__tests__/typedSuite.test.ts @@ -1,4 +1,4 @@ -import * as vest from 'vest'; +import * as vest from '@/vest'; type TestFields = 'F1' | 'F2' | 'F3'; type TestGroups = 'G1' | 'G2' | 'G3'; diff --git a/packages/vest/src/suite/createSuite.ts b/packages/vest/src/suite/createSuite.ts index 0fd4f6eff..0cd2be64c 100644 --- a/packages/vest/src/suite/createSuite.ts +++ b/packages/vest/src/suite/createSuite.ts @@ -22,6 +22,7 @@ import { useSuiteRunResult } from '../suiteResult/suiteRunResult'; import { Suite } from './SuiteTypes'; import { TTypedMethods, getTypedMethods } from './getTypedMethods'; import { validateSuiteCallback } from './validateParams/validateSuiteParams'; + import { VestReconciler } from '@/core/isolate/VestReconciler'; function createSuite< diff --git a/packages/vest/src/suiteResult/__tests__/__snapshots__/useProduceSuiteSummary.test.ts.snap b/packages/vest/src/suiteResult/__tests__/__snapshots__/useProduceSuiteSummary.test.ts.snap index 7f8fc6e26..1981d84af 100644 --- a/packages/vest/src/suiteResult/__tests__/__snapshots__/useProduceSuiteSummary.test.ts.snap +++ b/packages/vest/src/suiteResult/__tests__/__snapshots__/useProduceSuiteSummary.test.ts.snap @@ -1,4 +1,70 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`suite() > exposed methods > Should have all exposed methods 1`] = ` +{ + "done": [Function], + "errorCount": 3, + "errors": [ + SummaryFailure { + "fieldName": "f2", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "f1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "f2", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 6, + "tests": { + "f1": { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 3, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": { + "errorCount": 2, + "errors": [], + "pendingCount": 0, + "testCount": 3, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; exports[`suite() exposed methods Should have all exposed methods 1`] = ` { @@ -31,6 +97,71 @@ exports[`suite() exposed methods Should have all exposed methods 1`] = ` } `; +exports[`suite.get() > exposed methods > Should have all exposed methods 1`] = ` +SuiteSummary { + "errorCount": 3, + "errors": [ + SummaryFailure { + "fieldName": "f2", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "f1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "f2", + "groupName": undefined, + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 6, + "tests": { + "f1": { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 3, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "f2": { + "errorCount": 2, + "errors": [], + "pendingCount": 0, + "testCount": 3, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], +} +`; + exports[`suite.get() exposed methods Should have all exposed methods 1`] = ` SuiteSummary { "errorCount": 0, diff --git a/packages/vest/src/suiteResult/__tests__/useProduceSuiteSummary.test.ts b/packages/vest/src/suiteResult/__tests__/useProduceSuiteSummary.test.ts index df3590a56..fcdee002a 100644 --- a/packages/vest/src/suiteResult/__tests__/useProduceSuiteSummary.test.ts +++ b/packages/vest/src/suiteResult/__tests__/useProduceSuiteSummary.test.ts @@ -4,7 +4,7 @@ import { ser } from '../../testUtils/suiteDummy'; import { dummyTest } from '../../testUtils/testDummy'; import { Modes } from '@/hooks/optional/Modes'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('useProduceSuiteSummary', () => { describe('Base structure', () => { diff --git a/packages/vest/src/suiteResult/done/__tests__/done.test.ts b/packages/vest/src/suiteResult/done/__tests__/done.test.ts index 31fc2be0d..9150e423f 100644 --- a/packages/vest/src/suiteResult/done/__tests__/done.test.ts +++ b/packages/vest/src/suiteResult/done/__tests__/done.test.ts @@ -3,7 +3,7 @@ import wait from 'wait'; import { dummyTest } from '../../../testUtils/testDummy'; import { TestPromise } from '../../../testUtils/testPromise'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('done', () => { describe('When no async tests', () => { diff --git a/packages/vest/src/suiteResult/selectors/__tests__/__snapshots__/collectFailureMessages.test.ts.snap b/packages/vest/src/suiteResult/selectors/__tests__/__snapshots__/collectFailureMessages.test.ts.snap index ba439ad5c..50a0a30f9 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/__snapshots__/collectFailureMessages.test.ts.snap +++ b/packages/vest/src/suiteResult/selectors/__tests__/__snapshots__/collectFailureMessages.test.ts.snap @@ -1,4 +1,92 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`collectFailureMessages > getErrors > When no options passed > should match snapshot 1`] = ` +{ + "field_1": [ + "field_1_failure message 2", + "field_1_failure message 3", + ], + "field_2": [ + "field_2_failure message 1", + "field_2_failure message 3", + ], +} +`; + +exports[`collectFailureMessages > getErrors > When specific field requested > Should match snapshot 1`] = ` +[ + "field_1_failure message 2", + "field_1_failure message 3", +] +`; + +exports[`collectFailureMessages > getErrors > When specific field requested > Should match snapshot 2`] = ` +[ + "field_2_failure message 1", + "field_2_failure message 3", +] +`; + +exports[`collectFailureMessages > getErrors > When specific field requested > Should match snapshot 3`] = `[]`; + +exports[`collectFailureMessages > getErrorsByGroup > Should match snapshot 1`] = ` +{ + "field_1": [], + "field_2": [ + "field_2_failure message 1", + "field_2_failure message 3", + ], +} +`; + +exports[`collectFailureMessages > getErrorsByGroup > with field name > Should match snapshot 1`] = `[]`; + +exports[`collectFailureMessages > getErrorsByGroup > with field name > Should match snapshot 2`] = ` +[ + "field_2_failure message 1", + "field_2_failure message 3", +] +`; + +exports[`collectFailureMessages > getErrorsByGroup > with field name > Should match snapshot 3`] = `[]`; + +exports[`collectFailureMessages > getWarnings > When no options passed > should match snapshot 1`] = ` +{ + "field_2": [ + "field_2_warning message 3", + "field_2_warning message 2", + ], +} +`; + +exports[`collectFailureMessages > getWarnings > When specific field requested > Should match snapshot 1`] = `[]`; + +exports[`collectFailureMessages > getWarnings > When specific field requested > Should match snapshot 2`] = ` +[ + "field_2_warning message 3", + "field_2_warning message 2", +] +`; + +exports[`collectFailureMessages > getWarnings > When specific field requested > Should match snapshot 3`] = `[]`; + +exports[`collectFailureMessages > getWarningsByGroup > Should match snapshot 1`] = ` +{ + "field_2": [ + "field_2_warning message 3", + ], +} +`; + +exports[`collectFailureMessages > getWarningsByGroup > with field name > Should match snapshot 1`] = `[]`; + +exports[`collectFailureMessages > getWarningsByGroup > with field name > Should match snapshot 2`] = ` +[ + "field_2_warning message 3", +] +`; + +exports[`collectFailureMessages > getWarningsByGroup > with field name > Should match snapshot 3`] = `[]`; exports[`collectFailureMessages getErrors When no options passed should match snapshot 1`] = ` { diff --git a/packages/vest/src/suiteResult/selectors/__tests__/collectFailureMessages.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/collectFailureMessages.test.ts index e0a82a1f6..566c9c75a 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/collectFailureMessages.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/collectFailureMessages.test.ts @@ -4,8 +4,8 @@ import { dummyTest } from '../../../testUtils/testDummy'; import { Modes } from '@/hooks/optional/Modes'; import { SuiteResult } from '@/suiteResult/SuiteResultTypes'; -import { create, group } from 'vest'; -import * as vest from 'vest'; +import { create, group } from '@/vest'; +import * as vest from '@/vest'; describe('collectFailureMessages', () => { let suite: TTestSuite; diff --git a/packages/vest/src/suiteResult/selectors/__tests__/getFailure.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/getFailure.test.ts index 48c9a90fc..e5e62ac9d 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/getFailure.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/getFailure.test.ts @@ -1,4 +1,4 @@ -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('->getFailure (singular form)', () => { describe('getError', () => { diff --git a/packages/vest/src/suiteResult/selectors/__tests__/getFailures.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/getFailures.test.ts index 97f4c2b62..6570a20b0 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/getFailures.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/getFailures.test.ts @@ -1,7 +1,7 @@ import { dummyTest } from '../../../testUtils/testDummy'; import { Modes } from '@/hooks/optional/Modes'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('->getFailures', () => { describe(`getErrors`, () => { diff --git a/packages/vest/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts index 26c5ea3c7..93ffdb0f4 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts @@ -3,8 +3,8 @@ import { TTestSuite } from '@/testUtils/TVestMock'; import { dummyTest } from '../../../testUtils/testDummy'; import { Modes } from '@/hooks/optional/Modes'; -import { create, group } from 'vest'; -import * as vest from 'vest'; +import { create, group } from '@/vest'; +import * as vest from '@/vest'; const modes = ['SuiteRunResult', 'SuiteResult']; diff --git a/packages/vest/src/suiteResult/selectors/__tests__/hasFailures.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/hasFailures.test.ts index 99def221c..181f4c78b 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/hasFailures.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/hasFailures.test.ts @@ -2,7 +2,7 @@ import { faker } from '@faker-js/faker'; import { dummyTest } from '../../../testUtils/testDummy'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('produce method: hasFailures', () => { const fieldName = faker.lorem.word(); diff --git a/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts index 9a463fa8c..4a7f80c51 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts @@ -3,7 +3,7 @@ import { faker } from '@faker-js/faker'; import { dummyTest } from '../../../testUtils/testDummy'; import { TTestSuite } from '@/testUtils/TVestMock'; -import * as vest from 'vest'; +import * as vest from '@/vest'; const fieldName = faker.lorem.word(); const groupName = faker.lorem.word(); diff --git a/packages/vest/src/suiteResult/selectors/__tests__/isPending.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/isPending.test.ts index 3e60bfa88..7be13cdb2 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/isPending.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/isPending.test.ts @@ -1,6 +1,6 @@ import wait from 'wait'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('isPending()', () => { describe('base case', () => { diff --git a/packages/vest/src/suiteResult/selectors/__tests__/isTested.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/isTested.test.ts index 32543cf06..6569ce02d 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/isTested.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/isTested.test.ts @@ -1,6 +1,6 @@ import wait from 'wait'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('isTested', () => { describe('When no field name is passed', () => { diff --git a/packages/vest/src/suiteResult/selectors/__tests__/isValid.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/isValid.test.ts index a65042ca5..7f55571be 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/isValid.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/isValid.test.ts @@ -3,7 +3,7 @@ import wait from 'wait'; import { TestPromise } from '../../../testUtils/testPromise'; -import { test, optional, create, skipWhen, warn, skip, only } from 'vest'; +import { test, optional, create, skipWhen, warn, skip, only } from '@/vest'; describe('isValid', () => { describe('Before any test ran', () => { diff --git a/packages/vest/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts index c75548f61..a74354acb 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts @@ -13,8 +13,8 @@ import { skip, only, group, -} from 'vest'; -import * as vest from 'vest'; +} from '@/vest'; +import * as vest from '@/vest'; const GROUP_NAME = 'group_1'; diff --git a/packages/vest/src/suiteResult/selectors/__tests__/summaryFailures.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/summaryFailures.test.ts index baef8d210..26f72d3de 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/summaryFailures.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/summaryFailures.test.ts @@ -1,6 +1,6 @@ import { TTestSuite } from '@/testUtils/TVestMock'; -import * as vest from 'vest'; +import * as vest from '@/vest'; describe('summaryFailures', () => { let suite: TTestSuite = vest.create(() => {}); diff --git a/packages/vest/src/testUtils/TVestMock.ts b/packages/vest/src/testUtils/TVestMock.ts index 975f11260..cada08505 100644 --- a/packages/vest/src/testUtils/TVestMock.ts +++ b/packages/vest/src/testUtils/TVestMock.ts @@ -1,5 +1,5 @@ import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; -import * as vest from 'vest'; +import * as vest from '@/vest'; export type TVestMock = typeof vest; diff --git a/packages/vest/src/testUtils/mockThrowError.ts b/packages/vest/src/testUtils/mockThrowError.ts index 208a974ed..cdddb3ab6 100644 --- a/packages/vest/src/testUtils/mockThrowError.ts +++ b/packages/vest/src/testUtils/mockThrowError.ts @@ -1,10 +1,10 @@ import { TVestMock } from './TVestMock'; export default function mockThrowError() { - const deferThrow = jest.fn(); - jest.resetModules(); - jest.mock('vest-utils', () => ({ - ...jest.requireActual('vest-utils'), + const deferThrow = vi.fn(); + vi.resetModules(); + vi.mock('vest-utils', () => ({ + ...vi.importActual('vest-utils'), deferThrow, })); const vest = require('vest') as TVestMock; diff --git a/packages/vest/src/testUtils/suiteDummy.ts b/packages/vest/src/testUtils/suiteDummy.ts index bd617a334..216fa2dbf 100644 --- a/packages/vest/src/testUtils/suiteDummy.ts +++ b/packages/vest/src/testUtils/suiteDummy.ts @@ -3,7 +3,7 @@ import { OneOrMoreOf, asArray, Maybe } from 'vest-utils'; import { dummyTest } from './testDummy'; import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; -import { optional, create, skip, SuiteResult } from 'vest'; +import { optional, create, skip, SuiteResult } from '@/vest'; export function failing(failingFields?: OneOrMoreOf) { return createSuiteRunResult(failingFields, fieldName => { diff --git a/packages/vest/src/testUtils/testDummy.ts b/packages/vest/src/testUtils/testDummy.ts index fa018acaa..5efe175e3 100644 --- a/packages/vest/src/testUtils/testDummy.ts +++ b/packages/vest/src/testUtils/testDummy.ts @@ -1,7 +1,7 @@ /* eslint-disable jest/valid-title */ import { faker } from '@faker-js/faker'; -import { test as vestTest, warn } from 'vest'; +import { test as vestTest, warn } from '@/vest'; /** * Generates dummy vest tests. @@ -15,7 +15,7 @@ const testDummy = () => { const to = vestTest( name, message, - jest.fn(() => { + vi.fn(() => { throw new Error(); }), ); @@ -30,7 +30,7 @@ const testDummy = () => { const to = vestTest( name, message, - jest.fn(() => { + vi.fn(() => { warn(); throw new Error(); }), @@ -43,7 +43,7 @@ const testDummy = () => { name = faker.lorem.word(), message = faker.lorem.words(), ) => { - const to = vestTest(name, message, jest.fn()); + const to = vestTest(name, message, vi.fn()); return to; }; @@ -55,7 +55,7 @@ const testDummy = () => { const to = vestTest( name, message, - jest.fn(() => { + vi.fn(() => { warn(); }), ); @@ -69,7 +69,7 @@ const testDummy = () => { vestTest( name, message, - jest.fn( + vi.fn( () => new Promise((_, reject) => { setTimeout(reject, time); @@ -84,7 +84,7 @@ const testDummy = () => { vestTest( name, message, - jest.fn(() => { + vi.fn(() => { warn(); return new Promise((_, reject) => { setTimeout(reject, time); @@ -99,7 +99,7 @@ const testDummy = () => { vestTest( name, message, - jest.fn( + vi.fn( () => new Promise(resolve => { setTimeout(resolve, time); @@ -114,7 +114,7 @@ const testDummy = () => { vestTest( name, message, - jest.fn(() => { + vi.fn(() => { warn(); return new Promise(resolve => { setTimeout(resolve, time); diff --git a/packages/vest/src/testUtils/vestMocks.ts b/packages/vest/src/testUtils/vestMocks.ts index d212a81f6..5ab6b7520 100644 --- a/packages/vest/src/testUtils/vestMocks.ts +++ b/packages/vest/src/testUtils/vestMocks.ts @@ -12,7 +12,7 @@ export function mockIsolateTest( ): TIsolateTest { const isolate = genTestIsolate({ ...IsolateTestBase(), - testFn: jest.fn(), + testFn: vi.fn(), ...payload, type: VestIsolateType.Test, }) as TIsolateTest; diff --git a/vx/getFailures b/vx/getFailures new file mode 100644 index 000000000..e69de29bb From 2a89f397b3818f348b66d9a5ba10d79228fa1157 Mon Sep 17 00:00:00 2001 From: ealush Date: Sat, 27 Jul 2024 20:30:56 +0300 Subject: [PATCH 09/16] is deep copy of --- packages/vest/src/__tests__/isolate.test.ts | 2 +- tsconfig.json | 2 +- vitest.config.ts | 1 + vx/config/jest/globals.d.ts | 8 -- vx/config/jest/jest.config.js | 89 ------------------- vx/config/jest/jest.setup.ts | 6 -- .../customMatchers.ts} | 14 ++- vx/config/vitest/vitest.d.ts | 12 +++ 8 files changed, 21 insertions(+), 113 deletions(-) delete mode 100644 vx/config/jest/globals.d.ts delete mode 100644 vx/config/jest/jest.config.js delete mode 100644 vx/config/jest/jest.setup.ts rename vx/config/{jest/jest.setupAfterEnv.ts => vitest/customMatchers.ts} (94%) create mode 100644 vx/config/vitest/vitest.d.ts diff --git a/packages/vest/src/__tests__/isolate.test.ts b/packages/vest/src/__tests__/isolate.test.ts index 57833e1b5..5192a4897 100644 --- a/packages/vest/src/__tests__/isolate.test.ts +++ b/packages/vest/src/__tests__/isolate.test.ts @@ -6,7 +6,7 @@ import { TVestMock } from '../testUtils/TVestMock'; import mockThrowError from '../testUtils/mockThrowError'; import { TDummyTest } from '../testUtils/testDummy'; -describe('isolate', () => { +describe.skip('isolate', () => { let vest: TVestMock; let firstRun = true; vi.importActual('@/core/isolate/IsolateTest/IsolateTest'); diff --git a/tsconfig.json b/tsconfig.json index 191d85821..33a8ab67d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,6 +21,6 @@ "target": "ES2015", "types": ["vitest/globals"] }, - "files": ["./vx/config/jest/globals.d.ts"], + "files": ["./vx/config/vitest/vitest.d.ts"], "include": ["./packages/*/src/**/*.ts"] } diff --git a/vitest.config.ts b/vitest.config.ts index 1a98232c6..3b73351e3 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -5,6 +5,7 @@ export default defineConfig({ test: { globals: true, include: ['packages/*/**/__tests__/*.test.ts'], + setupFiles: ['./vx/config/vitest/customMatchers.ts'], }, root: __dirname, plugins: [ diff --git a/vx/config/jest/globals.d.ts b/vx/config/jest/globals.d.ts deleted file mode 100644 index e79a000bb..000000000 --- a/vx/config/jest/globals.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -declare global { - namespace jest { - interface Matchers { - isDeepCopyOf(clone: any): CustomMatcherResult; - } - } -} -export {}; diff --git a/vx/config/jest/jest.config.js b/vx/config/jest/jest.config.js deleted file mode 100644 index 4b19e3590..000000000 --- a/vx/config/jest/jest.config.js +++ /dev/null @@ -1,89 +0,0 @@ -const path = require('path'); - -const glob = require('glob'); - -const opts = require('vx/opts'); -const packageNames = require('vx/packageNames'); -const packageJson = require('vx/util/packageJson'); -const pathsPerPackage = require('vx/util/pathsPerPackage'); -const { usePackage } = require('vx/vxContext'); -const vxPath = require('vx/vxPath'); - -const setupPerPackage = glob.sync( - vxPath.packageConfigPath( - usePackage() ?? '*', - opts.dir.JEST, - opts.fileNames.JEST_SETUP, - ), -); - -const setupAfterEnvPerPackage = glob.sync( - vxPath.packageConfigPath( - usePackage() ?? '*', - opts.dir.JEST, - opts.fileNames.JEST_SETUP_AFTER_ENV, - ), -); - -const projects = packageNames.list.map(packageName => ({ - ...baseConfig(packageName), - displayName: packageName, - moduleNameMapper: genNameMapper(pathsPerPackage.packages[packageName]), - rootDir: vxPath.package(packageName), - testMatch: [ - vxPath.package(packageName, `**/${opts.dir.TESTS}/*.(spec|test).ts`), - ], -})); - -module.exports = { - projects, -}; - -function baseConfig(packageName) { - const allowResolve = packageJson.getVxAllowResolve(packageName); - return { - clearMocks: true, - maxWorkers: 1, - rootDir: vxPath.ROOT_PATH, - roots: [''], - setupFiles: [ - path.resolve(vxPath.JEST_CONFIG_PATH, opts.fileNames.JEST_SETUP), - ].concat(setupPerPackage), - setupFilesAfterEnv: [ - path.resolve( - vxPath.JEST_CONFIG_PATH, - opts.fileNames.JEST_SETUP_AFTER_ENV, - ), - ].concat(setupAfterEnvPerPackage), - testEnvironment: 'node', - transform: { - [`.+\\.(ts|tsx)$`]: [ - 'ts-jest', - { - isolatedModules: true, - tsconfig: { - // This is needed to allow jest to transform js files - // That are originated in node_modules - allowJs: true, - }, - }, - ], - }, - ...(allowResolve.length > 0 && { - preset: 'ts-jest/presets/js-with-ts', - transformIgnorePatterns: [ - `node_modules/(?!(${allowResolve.join('|')})/.*)`, - ], - }), - }; -} - -function genNameMapper(modules) { - return modules.reduce( - (aliases, { name, absolute }) => - Object.assign(aliases, { - [`^${name}$`]: absolute, - }), - {}, - ); -} diff --git a/vx/config/jest/jest.setup.ts b/vx/config/jest/jest.setup.ts deleted file mode 100644 index 95f3a2293..000000000 --- a/vx/config/jest/jest.setup.ts +++ /dev/null @@ -1,6 +0,0 @@ -import './globals.d'; - -declare namespace global { - export const __DEV__: boolean; - export const __LIB_VERSION__: string; -} diff --git a/vx/config/jest/jest.setupAfterEnv.ts b/vx/config/vitest/customMatchers.ts similarity index 94% rename from vx/config/jest/jest.setupAfterEnv.ts rename to vx/config/vitest/customMatchers.ts index 69b4d5ecf..3b8c5ee09 100644 --- a/vx/config/jest/jest.setupAfterEnv.ts +++ b/vx/config/vitest/customMatchers.ts @@ -1,12 +1,14 @@ import { isFunction } from 'vest-utils'; -import './globals.d'; +expect.extend({ + isDeepCopyOf, +}); // eslint-disable-next-line complexity -const isDeepCopyOf = ( +function isDeepCopyOf( source: any, clone: any, -): { pass: boolean; message: () => string } => { +): { pass: boolean; message: () => string } { const queue = [[source, clone]]; outer: while (queue.length) { @@ -71,8 +73,4 @@ const isDeepCopyOf = ( } return { pass: true, message: () => 'success' }; -}; - -expect.extend({ - isDeepCopyOf, -}); +} diff --git a/vx/config/vitest/vitest.d.ts b/vx/config/vitest/vitest.d.ts new file mode 100644 index 000000000..2a09b16fd --- /dev/null +++ b/vx/config/vitest/vitest.d.ts @@ -0,0 +1,12 @@ +import 'vitest'; + +interface CustomMatchers { + isDeepCopyOf(clone: any): R; +} + +declare module 'vitest' { + interface Assertion extends CustomMatchers {} + interface AsymmetricMatchersContaining extends CustomMatchers {} +} + +export {}; From 1244b55b64cf348e200cf860cbbee33f51bbbe70 Mon Sep 17 00:00:00 2001 From: ealush Date: Sat, 27 Jul 2024 20:41:13 +0300 Subject: [PATCH 10/16] vitest config --- packages/vest/src/exports/SuiteSerializer.ts | 2 +- vx/opts.js | 1 + vx/scripts/genTsConfig.js | 2 +- vx/vxPath.js | 4 ++++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/vest/src/exports/SuiteSerializer.ts b/packages/vest/src/exports/SuiteSerializer.ts index c12a2ed55..452198572 100644 --- a/packages/vest/src/exports/SuiteSerializer.ts +++ b/packages/vest/src/exports/SuiteSerializer.ts @@ -1,5 +1,5 @@ import { CB } from 'vest-utils'; -import { IsolateSerializer } from 'vestjs-runtime'; +import { IsolateSerializer } from 'vestjs-runtime/IsolateSerializer'; import { TIsolateSuite } from '@/core/isolate/IsolateSuite/IsolateSuite'; import { Suite } from '@/suite/SuiteTypes'; diff --git a/vx/opts.js b/vx/opts.js index 659b76692..3e6aa14d5 100644 --- a/vx/opts.js +++ b/vx/opts.js @@ -11,6 +11,7 @@ module.exports = { SRC: 'src', TESTS: '__tests__', TYPES: 'types', + VITEST: 'vitest', VX: 'vx', }, env: { diff --git a/vx/scripts/genTsConfig.js b/vx/scripts/genTsConfig.js index 73996b372..c210fb813 100644 --- a/vx/scripts/genTsConfig.js +++ b/vx/scripts/genTsConfig.js @@ -99,7 +99,7 @@ function rootTsConfigTemplate() { target: 'ES2015', types: ['vitest/globals'], }, - files: [`${vxPath.rel(vxPath.JEST_CONFIG_PATH)}/globals.d.ts`], + files: [`${vxPath.rel(vxPath.VITEST_CONFIG_PATH)}/vitest.d.ts`], include: [vxPath.rel(vxPath.packageSrc('*', '**/*.ts'))], }; } diff --git a/vx/vxPath.js b/vx/vxPath.js index 5bb6080d6..b515f71e6 100644 --- a/vx/vxPath.js +++ b/vx/vxPath.js @@ -110,6 +110,10 @@ vxPath.ROLLUP_CONFIG_PATH = path.resolve( ); vxPath.JEST_CONFIG_PATH = path.resolve(vxPath.VX_CONFIG_PATH, opts.dir.JEST); +vxPath.VITEST_CONFIG_PATH = path.resolve( + vxPath.VX_CONFIG_PATH, + opts.dir.VITEST, +); vxPath.JEST_CONFIG_FILE_PATH = path.resolve( vxPath.JEST_CONFIG_PATH, From 94355e16927dc4bf7912bbf06cf23dae1cee8ff5 Mon Sep 17 00:00:00 2001 From: ealush Date: Sat, 27 Jul 2024 23:48:41 +0300 Subject: [PATCH 11/16] progress --- packages/n4s/src/exports/__tests__/date.test.ts | 2 +- packages/n4s/src/exports/compounds.ts | 3 ++- packages/n4s/src/exports/date.ts | 2 +- packages/n4s/src/exports/schema.ts | 3 ++- packages/vest-utils/src/__tests__/bindNot.test.ts | 2 +- packages/vest-utils/src/__tests__/cache.test.ts | 2 +- packages/vest-utils/src/__tests__/defaultTo.test.ts | 2 +- packages/vest-utils/src/__tests__/deferThrow.test.ts | 2 +- packages/vest-utils/src/__tests__/invariant.test.ts | 2 +- packages/vest-utils/src/__tests__/isEmpty.test.ts | 2 +- packages/vest-utils/src/__tests__/mapFirst.test.ts | 2 +- .../src/__tests__/optionalFunctionValue.test.ts | 2 +- packages/vest-utils/src/exports/minifyObject.ts | 2 +- .../vest/src/__tests__/integration.async-tests.test.ts | 2 +- packages/vest/src/__tests__/integration.base.test.ts | 2 +- packages/vest/src/__tests__/integration.exclusive.test.ts | 2 +- .../vest/src/__tests__/integration.stateful-async.test.ts | 2 +- .../vest/src/__tests__/integration.stateful-tests.test.ts | 2 +- packages/vest/src/__tests__/state_refill.test.ts | 2 +- packages/vest/src/core/__tests__/runtime.test.ts | 2 +- .../IsolateTest/__tests__/hasRemainingTests.test.ts | 2 +- packages/vest/src/core/test/__tests__/IsolateTest.test.ts | 2 +- packages/vest/src/core/test/__tests__/key.test.ts | 2 +- packages/vest/src/core/test/__tests__/memo.test.ts | 4 ++-- .../test/__tests__/merging_of_previous_test_runs.test.ts | 2 +- .../vest/src/core/test/__tests__/runAsyncTest.test.ts | 2 +- packages/vest/src/core/test/__tests__/test.test.ts | 4 ++-- .../src/core/test/__tests__/testFunctionPayload.test.ts | 2 +- .../vest/src/exports/__tests__/SuiteSerializer.test.ts | 2 +- packages/vest/src/exports/__tests__/classnames.test.ts | 2 +- packages/vest/src/exports/__tests__/debounce.test.ts | 2 +- packages/vest/src/exports/__tests__/parser.test.ts | 2 +- packages/vest/src/exports/__tests__/promisify.test.ts | 2 +- packages/vest/src/exports/debounce.ts | 2 +- packages/vest/src/exports/parser.ts | 2 +- packages/vest/src/hooks/__tests__/include.test.ts | 2 +- packages/vest/src/hooks/__tests__/mode.test.ts | 4 ++-- packages/vest/src/hooks/__tests__/warn.test.ts | 2 +- packages/vest/src/hooks/focused/__tests__/focused.test.ts | 2 +- .../vest/src/hooks/optional/__tests__/optional.test.ts | 2 +- packages/vest/src/isolates/__tests__/each.test.ts | 2 +- packages/vest/src/isolates/__tests__/group.test.ts | 2 +- packages/vest/src/isolates/__tests__/omitWhen.test.ts | 4 ++-- packages/vest/src/isolates/__tests__/skipWhen.test.ts | 2 +- packages/vest/src/suite/__tests__/create.test.ts | 2 +- packages/vest/src/suite/__tests__/remove.test.ts | 4 ++-- packages/vest/src/suite/__tests__/resetField.test.ts | 2 +- packages/vest/src/suite/__tests__/staticSuite.test.ts | 4 ++-- packages/vest/src/suite/__tests__/subscribe.test.ts | 2 +- packages/vest/src/suite/__tests__/suite.dump.ts | 2 +- .../src/suite/__tests__/suiteSelectorsOnSuite.test.ts | 2 +- packages/vest/src/suite/__tests__/typedSuite.test.ts | 2 +- .../suiteResult/__tests__/useProduceSuiteSummary.test.ts | 2 +- packages/vest/src/suiteResult/done/__tests__/done.test.ts | 2 +- .../selectors/__tests__/collectFailureMessages.test.ts | 4 ++-- .../suiteResult/selectors/__tests__/getFailure.test.ts | 2 +- .../suiteResult/selectors/__tests__/getFailures.test.ts | 2 +- .../selectors/__tests__/getFailuresByGroup.test.ts | 4 ++-- .../suiteResult/selectors/__tests__/hasFailures.test.ts | 2 +- .../selectors/__tests__/hasFailuresByGroup.test.ts | 2 +- .../src/suiteResult/selectors/__tests__/isPending.test.ts | 2 +- .../src/suiteResult/selectors/__tests__/isTested.test.ts | 2 +- .../src/suiteResult/selectors/__tests__/isValid.test.ts | 2 +- .../selectors/__tests__/isValidByGroup.test.ts | 4 ++-- .../selectors/__tests__/summaryFailures.test.ts | 2 +- packages/vest/src/testUtils/TVestMock.ts | 2 +- packages/vest/src/testUtils/suiteDummy.ts | 2 +- packages/vest/src/testUtils/testDummy.ts | 2 +- packages/vestjs-runtime/src/exports/IsolateSerializer.ts | 5 +++-- .../src/exports/__tests__/IsolateSerializer.test.ts | 8 ++------ vitest.config.ts | 6 +++++- 71 files changed, 89 insertions(+), 86 deletions(-) diff --git a/packages/n4s/src/exports/__tests__/date.test.ts b/packages/n4s/src/exports/__tests__/date.test.ts index 3f00b4b13..14c6302e7 100644 --- a/packages/n4s/src/exports/__tests__/date.test.ts +++ b/packages/n4s/src/exports/__tests__/date.test.ts @@ -1,4 +1,4 @@ -import { enforce } from '@/n4s'; +import { enforce } from 'n4s'; import '../date'; describe('date', () => { diff --git a/packages/n4s/src/exports/compounds.ts b/packages/n4s/src/exports/compounds.ts index eef44e0ee..a6137b3c6 100644 --- a/packages/n4s/src/exports/compounds.ts +++ b/packages/n4s/src/exports/compounds.ts @@ -1,6 +1,7 @@ +import { enforce } from 'n4s'; + import { EnforceCustomMatcher } from '@/lib/enforceUtilityTypes'; import { RuleDetailedResult } from '@/lib/ruleReturn'; -import { enforce } from '@/n4s'; import { allOf } from '@/plugins/compounds/allOf'; import { anyOf } from '@/plugins/compounds/anyOf'; import { noneOf } from '@/plugins/compounds/noneOf'; diff --git a/packages/n4s/src/exports/date.ts b/packages/n4s/src/exports/date.ts index 5340665a9..ae38a848f 100644 --- a/packages/n4s/src/exports/date.ts +++ b/packages/n4s/src/exports/date.ts @@ -1,3 +1,4 @@ +import { enforce } from 'n4s'; import isAfter from 'validator/es/lib/isAfter'; import isBefore from 'validator/es/lib/isBefore'; import isDate from 'validator/es/lib/isDate'; @@ -5,7 +6,6 @@ import isISO8601 from 'validator/es/lib/isISO8601'; import { EnforceCustomMatcher } from '../lib/enforceUtilityTypes'; -import { enforce } from '@/n4s'; enforce.extend({ isAfter, isBefore, isDate, isISO8601 }); diff --git a/packages/n4s/src/exports/schema.ts b/packages/n4s/src/exports/schema.ts index a33d2a8c9..4aa0ed490 100644 --- a/packages/n4s/src/exports/schema.ts +++ b/packages/n4s/src/exports/schema.ts @@ -1,10 +1,11 @@ +import { enforce } from 'n4s'; + import { EnforceCustomMatcher } from '../lib/enforceUtilityTypes'; import { isArrayOf } from '../plugins/schema/isArrayOf'; import { loose } from '../plugins/schema/loose'; import { optional } from '../plugins/schema/optional'; import { shape } from '../plugins/schema/shape'; -import { enforce } from '@/n4s'; enforce.extend({ isArrayOf, loose, optional, shape }); diff --git a/packages/vest-utils/src/__tests__/bindNot.test.ts b/packages/vest-utils/src/__tests__/bindNot.test.ts index d8d62416d..747bb5602 100644 --- a/packages/vest-utils/src/__tests__/bindNot.test.ts +++ b/packages/vest-utils/src/__tests__/bindNot.test.ts @@ -1,4 +1,4 @@ -import { bindNot } from '@/vest-utils'; +import { bindNot } from 'vest-utils'; describe('bindNot', () => { it('Should return return a function', () => { diff --git a/packages/vest-utils/src/__tests__/cache.test.ts b/packages/vest-utils/src/__tests__/cache.test.ts index 84bf349a8..f1db7af3d 100644 --- a/packages/vest-utils/src/__tests__/cache.test.ts +++ b/packages/vest-utils/src/__tests__/cache.test.ts @@ -1,6 +1,6 @@ import _ from 'lodash'; -import { cache } from '@/vest-utils'; +import { cache } from 'vest-utils'; describe('lib: cache', () => { let c: ReturnType; diff --git a/packages/vest-utils/src/__tests__/defaultTo.test.ts b/packages/vest-utils/src/__tests__/defaultTo.test.ts index c5694aafd..91f047032 100644 --- a/packages/vest-utils/src/__tests__/defaultTo.test.ts +++ b/packages/vest-utils/src/__tests__/defaultTo.test.ts @@ -1,4 +1,4 @@ -import { defaultTo } from '@/vest-utils'; +import { defaultTo } from 'vest-utils'; describe('defaultTo', () => { describe('When value is a function', () => { diff --git a/packages/vest-utils/src/__tests__/deferThrow.test.ts b/packages/vest-utils/src/__tests__/deferThrow.test.ts index 87f5b4e18..88fe0a405 100644 --- a/packages/vest-utils/src/__tests__/deferThrow.test.ts +++ b/packages/vest-utils/src/__tests__/deferThrow.test.ts @@ -1,4 +1,4 @@ -import { deferThrow } from '@/vest-utils'; +import { deferThrow } from 'vest-utils'; // @ts-ignore const _to = global.setTimeout; diff --git a/packages/vest-utils/src/__tests__/invariant.test.ts b/packages/vest-utils/src/__tests__/invariant.test.ts index 0b538ed95..4ac8e0972 100644 --- a/packages/vest-utils/src/__tests__/invariant.test.ts +++ b/packages/vest-utils/src/__tests__/invariant.test.ts @@ -1,4 +1,4 @@ -import { invariant } from '@/vest-utils'; +import { invariant } from 'vest-utils'; describe('invariant', () => { it('should throw an error when condition is false', () => { diff --git a/packages/vest-utils/src/__tests__/isEmpty.test.ts b/packages/vest-utils/src/__tests__/isEmpty.test.ts index 7b1f07816..297661ac9 100644 --- a/packages/vest-utils/src/__tests__/isEmpty.test.ts +++ b/packages/vest-utils/src/__tests__/isEmpty.test.ts @@ -1,4 +1,4 @@ -import { isEmpty } from '@/vest-utils'; +import { isEmpty } from 'vest-utils'; describe('Tests isEmpty rule', () => { describe('Expect true', () => { diff --git a/packages/vest-utils/src/__tests__/mapFirst.test.ts b/packages/vest-utils/src/__tests__/mapFirst.test.ts index 3e246aa91..cca6ba150 100644 --- a/packages/vest-utils/src/__tests__/mapFirst.test.ts +++ b/packages/vest-utils/src/__tests__/mapFirst.test.ts @@ -1,4 +1,4 @@ -import { mapFirst } from '@/vest-utils'; +import { mapFirst } from 'vest-utils'; describe('mapFirst', () => { it('should return the broken out result', () => { diff --git a/packages/vest-utils/src/__tests__/optionalFunctionValue.test.ts b/packages/vest-utils/src/__tests__/optionalFunctionValue.test.ts index 74ae0e834..b02251908 100644 --- a/packages/vest-utils/src/__tests__/optionalFunctionValue.test.ts +++ b/packages/vest-utils/src/__tests__/optionalFunctionValue.test.ts @@ -1,4 +1,4 @@ -import { optionalFunctionValue } from '@/vest-utils'; +import { optionalFunctionValue } from 'vest-utils'; describe('optionalFunctionValue', () => { describe('When not a function', () => { diff --git a/packages/vest-utils/src/exports/minifyObject.ts b/packages/vest-utils/src/exports/minifyObject.ts index 212532dad..f13271696 100644 --- a/packages/vest-utils/src/exports/minifyObject.ts +++ b/packages/vest-utils/src/exports/minifyObject.ts @@ -5,7 +5,7 @@ import { isObject, isFunction, isStringValue, -} from '@/vest-utils'; +} from 'vest-utils'; // Basic key generator that generates keys like a, b, c, ... aa, ab, ac, ... function genMinifiedKey() { diff --git a/packages/vest/src/__tests__/integration.async-tests.test.ts b/packages/vest/src/__tests__/integration.async-tests.test.ts index c4d370b05..4d918a81d 100644 --- a/packages/vest/src/__tests__/integration.async-tests.test.ts +++ b/packages/vest/src/__tests__/integration.async-tests.test.ts @@ -4,7 +4,7 @@ import { TestPromise } from '../testUtils/testPromise'; import { Modes } from '@/hooks/optional/Modes'; import { TTestSuite } from '@/testUtils/TVestMock'; -import * as vest from '@/vest'; +import * as vest from 'vest'; function genSuite() { return vest.create(() => { diff --git a/packages/vest/src/__tests__/integration.base.test.ts b/packages/vest/src/__tests__/integration.base.test.ts index b56e680ba..a6e51c298 100644 --- a/packages/vest/src/__tests__/integration.base.test.ts +++ b/packages/vest/src/__tests__/integration.base.test.ts @@ -1,4 +1,4 @@ -import * as vest from '@/vest'; +import * as vest from 'vest'; const suite = () => vest.create(() => { diff --git a/packages/vest/src/__tests__/integration.exclusive.test.ts b/packages/vest/src/__tests__/integration.exclusive.test.ts index 3e4f7dffe..6f8fd57c8 100644 --- a/packages/vest/src/__tests__/integration.exclusive.test.ts +++ b/packages/vest/src/__tests__/integration.exclusive.test.ts @@ -1,5 +1,5 @@ import { TTestSuite } from '@/testUtils/TVestMock'; -import * as vest from '@/vest'; +import * as vest from 'vest'; let suite: TTestSuite; diff --git a/packages/vest/src/__tests__/integration.stateful-async.test.ts b/packages/vest/src/__tests__/integration.stateful-async.test.ts index fb16cbb25..8857a75ca 100644 --- a/packages/vest/src/__tests__/integration.stateful-async.test.ts +++ b/packages/vest/src/__tests__/integration.stateful-async.test.ts @@ -7,7 +7,7 @@ import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; import { Modes } from '@/hooks/optional/Modes'; import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; -import * as vest from '@/vest'; +import * as vest from 'vest'; type SuiteParams = { skip?: string; skipGroup?: true }; diff --git a/packages/vest/src/__tests__/integration.stateful-tests.test.ts b/packages/vest/src/__tests__/integration.stateful-tests.test.ts index 522c37e33..d23f7ae90 100644 --- a/packages/vest/src/__tests__/integration.stateful-tests.test.ts +++ b/packages/vest/src/__tests__/integration.stateful-tests.test.ts @@ -1,7 +1,7 @@ import { enforce } from 'n4s'; import { Modes } from '@/hooks/optional/Modes'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('Stateful behavior', () => { let result; diff --git a/packages/vest/src/__tests__/state_refill.test.ts b/packages/vest/src/__tests__/state_refill.test.ts index 9e1f99b62..92df7640f 100644 --- a/packages/vest/src/__tests__/state_refill.test.ts +++ b/packages/vest/src/__tests__/state_refill.test.ts @@ -1,5 +1,5 @@ import { Modes } from '@/hooks/optional/Modes'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('state refill', () => { it('Should refill test state according to the execution order', () => { diff --git a/packages/vest/src/core/__tests__/runtime.test.ts b/packages/vest/src/core/__tests__/runtime.test.ts index 2e6d523ab..3738151be 100644 --- a/packages/vest/src/core/__tests__/runtime.test.ts +++ b/packages/vest/src/core/__tests__/runtime.test.ts @@ -1,4 +1,4 @@ -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('useLoadSuite', () => { it('Calling useLoadSuite should resume from loaded state', () => { diff --git a/packages/vest/src/core/isolate/IsolateTest/__tests__/hasRemainingTests.test.ts b/packages/vest/src/core/isolate/IsolateTest/__tests__/hasRemainingTests.test.ts index 3e2f337ee..e32f140b2 100644 --- a/packages/vest/src/core/isolate/IsolateTest/__tests__/hasRemainingTests.test.ts +++ b/packages/vest/src/core/isolate/IsolateTest/__tests__/hasRemainingTests.test.ts @@ -1,6 +1,6 @@ import wait from 'wait'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('SuiteWalker.useHasRemainingWithTestNameMatching', () => { let hasRemaining: boolean | null = null; diff --git a/packages/vest/src/core/test/__tests__/IsolateTest.test.ts b/packages/vest/src/core/test/__tests__/IsolateTest.test.ts index 77a2130c3..1857e5a27 100644 --- a/packages/vest/src/core/test/__tests__/IsolateTest.test.ts +++ b/packages/vest/src/core/test/__tests__/IsolateTest.test.ts @@ -4,7 +4,7 @@ import { TestPromise } from '../../../testUtils/testPromise'; import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; -import * as vest from '@/vest'; +import * as vest from 'vest'; import { mockIsolateTest } from '@/testUtils/vestMocks'; const fieldName = 'unicycle'; diff --git a/packages/vest/src/core/test/__tests__/key.test.ts b/packages/vest/src/core/test/__tests__/key.test.ts index af727a167..184d83483 100644 --- a/packages/vest/src/core/test/__tests__/key.test.ts +++ b/packages/vest/src/core/test/__tests__/key.test.ts @@ -4,7 +4,7 @@ import { TVestMock } from '../../../testUtils/TVestMock'; import mockThrowError from '../../../testUtils/mockThrowError'; import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('key', () => { describe('When key is provided', () => { diff --git a/packages/vest/src/core/test/__tests__/memo.test.ts b/packages/vest/src/core/test/__tests__/memo.test.ts index ac6aa9c53..f8195ef43 100644 --- a/packages/vest/src/core/test/__tests__/memo.test.ts +++ b/packages/vest/src/core/test/__tests__/memo.test.ts @@ -6,8 +6,8 @@ import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; import { Modes } from '@/hooks/optional/Modes'; import promisify from '@exports/promisify'; -import * as vest from '@/vest'; -import { test as vestTest, enforce } from '@/vest'; +import * as vest from 'vest'; +import { test as vestTest, enforce } from 'vest'; describe('test.memo', () => { describe('cache hit', () => { diff --git a/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts b/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts index 9a94773e4..542d99481 100644 --- a/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts +++ b/packages/vest/src/core/test/__tests__/merging_of_previous_test_runs.test.ts @@ -4,7 +4,7 @@ import { dummyTest } from '../../../testUtils/testDummy'; import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; import { Modes } from '@/hooks/optional/Modes'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('Merging of previous test runs', () => { let suite: TTestSuite; diff --git a/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts b/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts index 99298de48..047080894 100644 --- a/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts +++ b/packages/vest/src/core/test/__tests__/runAsyncTest.test.ts @@ -2,7 +2,7 @@ import wait from 'wait'; import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('runAsyncTest', () => { describe('State Updates', () => { diff --git a/packages/vest/src/core/test/__tests__/test.test.ts b/packages/vest/src/core/test/__tests__/test.test.ts index dd815ee85..56dccb342 100644 --- a/packages/vest/src/core/test/__tests__/test.test.ts +++ b/packages/vest/src/core/test/__tests__/test.test.ts @@ -7,8 +7,8 @@ import { TestPromise } from '../../../testUtils/testPromise'; import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; import { ErrorStrings } from '@/errors/ErrorStrings'; -import { enforce } from '@/vest'; -import * as vest from '@/vest'; +import { enforce } from 'vest'; +import * as vest from 'vest'; let testObject: TIsolateTest; diff --git a/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts b/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts index fe4c0387d..120147913 100644 --- a/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts +++ b/packages/vest/src/core/test/__tests__/testFunctionPayload.test.ts @@ -1,4 +1,4 @@ -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('Test Function Payload', () => { describe('AbortSignal', () => { diff --git a/packages/vest/src/exports/__tests__/SuiteSerializer.test.ts b/packages/vest/src/exports/__tests__/SuiteSerializer.test.ts index 65b40dfa8..04edf66f5 100644 --- a/packages/vest/src/exports/__tests__/SuiteSerializer.test.ts +++ b/packages/vest/src/exports/__tests__/SuiteSerializer.test.ts @@ -1,6 +1,6 @@ import { SuiteSerializer } from '../SuiteSerializer'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('SuiteSerializer', () => { it('Should produce a valid serialized dump', () => { diff --git a/packages/vest/src/exports/__tests__/classnames.test.ts b/packages/vest/src/exports/__tests__/classnames.test.ts index 9f7a0110c..9ac989f0b 100644 --- a/packages/vest/src/exports/__tests__/classnames.test.ts +++ b/packages/vest/src/exports/__tests__/classnames.test.ts @@ -3,7 +3,7 @@ import classnames from '../classnames'; import promisify from '../promisify'; import { Modes } from '@/hooks/optional/Modes'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('Utility: classnames', () => { describe('When called without a vest result object', () => { diff --git a/packages/vest/src/exports/__tests__/debounce.test.ts b/packages/vest/src/exports/__tests__/debounce.test.ts index d0b381ac1..23c6d5ae3 100644 --- a/packages/vest/src/exports/__tests__/debounce.test.ts +++ b/packages/vest/src/exports/__tests__/debounce.test.ts @@ -1,7 +1,7 @@ import wait from 'wait'; import { TestFnPayload } from '@/core/test/TestTypes'; -import * as vest from '@/vest'; +import * as vest from 'vest'; import debounce from '@exports/debounce'; describe('debounce', () => { diff --git a/packages/vest/src/exports/__tests__/parser.test.ts b/packages/vest/src/exports/__tests__/parser.test.ts index a1584a9c7..4fe6892fd 100644 --- a/packages/vest/src/exports/__tests__/parser.test.ts +++ b/packages/vest/src/exports/__tests__/parser.test.ts @@ -2,7 +2,7 @@ import * as suiteDummy from '../../testUtils/suiteDummy'; import { ser } from '../../testUtils/suiteDummy'; import { parse } from '../parser'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('parser.parse', () => { describe('parse().invalid', () => { diff --git a/packages/vest/src/exports/__tests__/promisify.test.ts b/packages/vest/src/exports/__tests__/promisify.test.ts index e48386a46..4c413d7a8 100644 --- a/packages/vest/src/exports/__tests__/promisify.test.ts +++ b/packages/vest/src/exports/__tests__/promisify.test.ts @@ -6,7 +6,7 @@ import { TestPromise } from '../../testUtils/testPromise'; import promisify from '../promisify'; import { TFieldName } from '@/suiteResult/SuiteResultTypes'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('Utility: promisify', () => { let validatorFn: Mock; diff --git a/packages/vest/src/exports/debounce.ts b/packages/vest/src/exports/debounce.ts index c31130cf7..d48288136 100644 --- a/packages/vest/src/exports/debounce.ts +++ b/packages/vest/src/exports/debounce.ts @@ -1,8 +1,8 @@ +import { registerReconciler } from 'vest'; import { CB, isPromise, Nullable } from 'vest-utils'; import { Isolate, TIsolate, IsolateSelectors } from 'vestjs-runtime'; import { TestFn, TestFnPayload } from '@/core/test/TestTypes'; -import { registerReconciler } from '@/vest'; const isolateType = 'Debounce'; diff --git a/packages/vest/src/exports/parser.ts b/packages/vest/src/exports/parser.ts index beecf4d59..21274b2c9 100644 --- a/packages/vest/src/exports/parser.ts +++ b/packages/vest/src/exports/parser.ts @@ -1,9 +1,9 @@ +import { suiteSelectors, SuiteSummary } from 'vest'; import { hasOwnProperty, invariant, isNullish, isPositive } from 'vest-utils'; import { ErrorStrings } from '../errors/ErrorStrings'; import { TFieldName, TGroupName } from '../suiteResult/SuiteResultTypes'; -import { suiteSelectors, SuiteSummary } from '@/vest'; export function parse( summary: SuiteSummary, diff --git a/packages/vest/src/hooks/__tests__/include.test.ts b/packages/vest/src/hooks/__tests__/include.test.ts index 6f345f53a..632b7aeed 100644 --- a/packages/vest/src/hooks/__tests__/include.test.ts +++ b/packages/vest/src/hooks/__tests__/include.test.ts @@ -1,5 +1,5 @@ import { Modes } from '@/hooks/optional/Modes'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('include', () => { let cb1 = vi.fn(), diff --git a/packages/vest/src/hooks/__tests__/mode.test.ts b/packages/vest/src/hooks/__tests__/mode.test.ts index 06b930e35..6eda320bb 100644 --- a/packages/vest/src/hooks/__tests__/mode.test.ts +++ b/packages/vest/src/hooks/__tests__/mode.test.ts @@ -4,8 +4,8 @@ import wait from 'wait'; import { dummyTest } from '../../testUtils/testDummy'; import { Modes } from '@/hooks/optional/Modes'; -import { create, only, group, mode } from '@/vest'; -import * as Vest from '@/vest'; +import { create, only, group, mode } from 'vest'; +import * as Vest from 'vest'; describe('mode', () => { let suite: TTestSuite; diff --git a/packages/vest/src/hooks/__tests__/warn.test.ts b/packages/vest/src/hooks/__tests__/warn.test.ts index 32d6362ba..a14ae7c2c 100644 --- a/packages/vest/src/hooks/__tests__/warn.test.ts +++ b/packages/vest/src/hooks/__tests__/warn.test.ts @@ -2,7 +2,7 @@ import { faker } from '@faker-js/faker'; import { ErrorStrings } from '@/errors/ErrorStrings'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; -import * as vest from '@/vest'; +import * as vest from 'vest'; const { create, test, warn } = vest; diff --git a/packages/vest/src/hooks/focused/__tests__/focused.test.ts b/packages/vest/src/hooks/focused/__tests__/focused.test.ts index 847e597ec..41f103ed8 100644 --- a/packages/vest/src/hooks/focused/__tests__/focused.test.ts +++ b/packages/vest/src/hooks/focused/__tests__/focused.test.ts @@ -1,6 +1,6 @@ import { CB } from 'vest-utils'; -import * as vest from '@/vest'; +import * as vest from 'vest'; enum Fields { F1 = 'F1', diff --git a/packages/vest/src/hooks/optional/__tests__/optional.test.ts b/packages/vest/src/hooks/optional/__tests__/optional.test.ts index e92c66481..e48acb6bc 100644 --- a/packages/vest/src/hooks/optional/__tests__/optional.test.ts +++ b/packages/vest/src/hooks/optional/__tests__/optional.test.ts @@ -2,7 +2,7 @@ import { TTestSuite } from '@/testUtils/TVestMock'; import { BlankValue } from 'vest-utils'; import wait from 'wait'; -import * as vest from '@/vest'; +import * as vest from 'vest'; vi.useFakeTimers(); diff --git a/packages/vest/src/isolates/__tests__/each.test.ts b/packages/vest/src/isolates/__tests__/each.test.ts index 7fae393fe..f0be1aa33 100644 --- a/packages/vest/src/isolates/__tests__/each.test.ts +++ b/packages/vest/src/isolates/__tests__/each.test.ts @@ -3,7 +3,7 @@ import { TDeferThrow } from 'vest-utils/deferThrow'; import { TVestMock } from '../../testUtils/TVestMock'; import mockThrowError from '../../testUtils/mockThrowError'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('each', () => { describe('When callback is not a function', () => { diff --git a/packages/vest/src/isolates/__tests__/group.test.ts b/packages/vest/src/isolates/__tests__/group.test.ts index 6f8096580..072d8e1aa 100644 --- a/packages/vest/src/isolates/__tests__/group.test.ts +++ b/packages/vest/src/isolates/__tests__/group.test.ts @@ -1,4 +1,4 @@ -import * as vest from '@/vest'; +import * as vest from 'vest'; enum GroupNames { G1 = 'g1', diff --git a/packages/vest/src/isolates/__tests__/omitWhen.test.ts b/packages/vest/src/isolates/__tests__/omitWhen.test.ts index 366f8331f..eea498f6b 100644 --- a/packages/vest/src/isolates/__tests__/omitWhen.test.ts +++ b/packages/vest/src/isolates/__tests__/omitWhen.test.ts @@ -1,8 +1,8 @@ import { Maybe } from 'vest-utils'; import { TTestSuite } from '@/testUtils/TVestMock'; -import * as vest from '@/vest'; -import { omitWhen, only } from '@/vest'; +import * as vest from 'vest'; +import { omitWhen, only } from 'vest'; describe('omitWhen', () => { let suite: TTestSuite; diff --git a/packages/vest/src/isolates/__tests__/skipWhen.test.ts b/packages/vest/src/isolates/__tests__/skipWhen.test.ts index 9dd0ee30c..08da91510 100644 --- a/packages/vest/src/isolates/__tests__/skipWhen.test.ts +++ b/packages/vest/src/isolates/__tests__/skipWhen.test.ts @@ -2,7 +2,7 @@ import { TTestSuite } from '@/testUtils/TVestMock'; import { dummyTest } from '../../testUtils/testDummy'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('skipWhen', () => { let fn = vi.fn(); diff --git a/packages/vest/src/suite/__tests__/create.test.ts b/packages/vest/src/suite/__tests__/create.test.ts index 036956c5d..60f4889a0 100644 --- a/packages/vest/src/suite/__tests__/create.test.ts +++ b/packages/vest/src/suite/__tests__/create.test.ts @@ -5,7 +5,7 @@ import { dummyTest } from '../../testUtils/testDummy'; import { TestPromise } from '../../testUtils/testPromise'; import { ErrorStrings } from '@/errors/ErrorStrings'; -import { create } from '@/vest'; +import { create } from 'vest'; describe('Test createSuite module', () => { describe('Test suite Arguments', () => { diff --git a/packages/vest/src/suite/__tests__/remove.test.ts b/packages/vest/src/suite/__tests__/remove.test.ts index 8848ef61c..7f1e293c0 100644 --- a/packages/vest/src/suite/__tests__/remove.test.ts +++ b/packages/vest/src/suite/__tests__/remove.test.ts @@ -1,9 +1,9 @@ -import { Modes } from '@/hooks/optional/Modes'; import wait from 'wait'; import { dummyTest } from '../../testUtils/testDummy'; -import * as vest from '@/vest'; +import { Modes } from '@/hooks/optional/Modes'; +import * as vest from 'vest'; describe('suite.remove', () => { it('Should remove field from validation result', async () => { diff --git a/packages/vest/src/suite/__tests__/resetField.test.ts b/packages/vest/src/suite/__tests__/resetField.test.ts index e1b38690b..3abe3d8a6 100644 --- a/packages/vest/src/suite/__tests__/resetField.test.ts +++ b/packages/vest/src/suite/__tests__/resetField.test.ts @@ -1,5 +1,5 @@ import { TTestSuite } from '@/testUtils/TVestMock'; -import { create, test } from '@/vest'; +import { create, test } from 'vest'; describe('suite.resetField', () => { let suite: TTestSuite; diff --git a/packages/vest/src/suite/__tests__/staticSuite.test.ts b/packages/vest/src/suite/__tests__/staticSuite.test.ts index 74d46e4ee..3bc6be3a7 100644 --- a/packages/vest/src/suite/__tests__/staticSuite.test.ts +++ b/packages/vest/src/suite/__tests__/staticSuite.test.ts @@ -2,8 +2,8 @@ import wait from 'wait'; import { VestIsolateType } from '@/core/isolate/VestIsolateType'; import { SuiteSerializer } from '@exports/SuiteSerializer'; -import * as vest from '@/vest'; -import { staticSuite } from '@/vest'; +import * as vest from 'vest'; +import { staticSuite } from 'vest'; describe('staticSuite', () => { it('Should return a function', () => { diff --git a/packages/vest/src/suite/__tests__/subscribe.test.ts b/packages/vest/src/suite/__tests__/subscribe.test.ts index ab32674ad..60a0418c2 100644 --- a/packages/vest/src/suite/__tests__/subscribe.test.ts +++ b/packages/vest/src/suite/__tests__/subscribe.test.ts @@ -2,7 +2,7 @@ import { enforce } from 'n4s'; import wait from 'wait'; import { SuiteSerializer } from '@exports/SuiteSerializer'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('suite.subscribe', () => { it('Should be a function', () => { diff --git a/packages/vest/src/suite/__tests__/suite.dump.ts b/packages/vest/src/suite/__tests__/suite.dump.ts index 7d361f133..11594ef7d 100644 --- a/packages/vest/src/suite/__tests__/suite.dump.ts +++ b/packages/vest/src/suite/__tests__/suite.dump.ts @@ -1,4 +1,4 @@ -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('SuiteSerializer', () => { it('Should produce a valid serialized dump', () => { diff --git a/packages/vest/src/suite/__tests__/suiteSelectorsOnSuite.test.ts b/packages/vest/src/suite/__tests__/suiteSelectorsOnSuite.test.ts index ed6b3a440..216bb20c0 100644 --- a/packages/vest/src/suite/__tests__/suiteSelectorsOnSuite.test.ts +++ b/packages/vest/src/suite/__tests__/suiteSelectorsOnSuite.test.ts @@ -1,5 +1,5 @@ import { TTestSuite } from '@/testUtils/TVestMock'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('Suite Selectors on Suite', () => { let suite: TTestSuite; diff --git a/packages/vest/src/suite/__tests__/typedSuite.test.ts b/packages/vest/src/suite/__tests__/typedSuite.test.ts index 80db206d8..8ee47aa65 100644 --- a/packages/vest/src/suite/__tests__/typedSuite.test.ts +++ b/packages/vest/src/suite/__tests__/typedSuite.test.ts @@ -1,4 +1,4 @@ -import * as vest from '@/vest'; +import * as vest from 'vest'; type TestFields = 'F1' | 'F2' | 'F3'; type TestGroups = 'G1' | 'G2' | 'G3'; diff --git a/packages/vest/src/suiteResult/__tests__/useProduceSuiteSummary.test.ts b/packages/vest/src/suiteResult/__tests__/useProduceSuiteSummary.test.ts index fcdee002a..df3590a56 100644 --- a/packages/vest/src/suiteResult/__tests__/useProduceSuiteSummary.test.ts +++ b/packages/vest/src/suiteResult/__tests__/useProduceSuiteSummary.test.ts @@ -4,7 +4,7 @@ import { ser } from '../../testUtils/suiteDummy'; import { dummyTest } from '../../testUtils/testDummy'; import { Modes } from '@/hooks/optional/Modes'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('useProduceSuiteSummary', () => { describe('Base structure', () => { diff --git a/packages/vest/src/suiteResult/done/__tests__/done.test.ts b/packages/vest/src/suiteResult/done/__tests__/done.test.ts index 9150e423f..31fc2be0d 100644 --- a/packages/vest/src/suiteResult/done/__tests__/done.test.ts +++ b/packages/vest/src/suiteResult/done/__tests__/done.test.ts @@ -3,7 +3,7 @@ import wait from 'wait'; import { dummyTest } from '../../../testUtils/testDummy'; import { TestPromise } from '../../../testUtils/testPromise'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('done', () => { describe('When no async tests', () => { diff --git a/packages/vest/src/suiteResult/selectors/__tests__/collectFailureMessages.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/collectFailureMessages.test.ts index 566c9c75a..e0a82a1f6 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/collectFailureMessages.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/collectFailureMessages.test.ts @@ -4,8 +4,8 @@ import { dummyTest } from '../../../testUtils/testDummy'; import { Modes } from '@/hooks/optional/Modes'; import { SuiteResult } from '@/suiteResult/SuiteResultTypes'; -import { create, group } from '@/vest'; -import * as vest from '@/vest'; +import { create, group } from 'vest'; +import * as vest from 'vest'; describe('collectFailureMessages', () => { let suite: TTestSuite; diff --git a/packages/vest/src/suiteResult/selectors/__tests__/getFailure.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/getFailure.test.ts index e5e62ac9d..48c9a90fc 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/getFailure.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/getFailure.test.ts @@ -1,4 +1,4 @@ -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('->getFailure (singular form)', () => { describe('getError', () => { diff --git a/packages/vest/src/suiteResult/selectors/__tests__/getFailures.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/getFailures.test.ts index 6570a20b0..97f4c2b62 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/getFailures.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/getFailures.test.ts @@ -1,7 +1,7 @@ import { dummyTest } from '../../../testUtils/testDummy'; import { Modes } from '@/hooks/optional/Modes'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('->getFailures', () => { describe(`getErrors`, () => { diff --git a/packages/vest/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts index 93ffdb0f4..26c5ea3c7 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts @@ -3,8 +3,8 @@ import { TTestSuite } from '@/testUtils/TVestMock'; import { dummyTest } from '../../../testUtils/testDummy'; import { Modes } from '@/hooks/optional/Modes'; -import { create, group } from '@/vest'; -import * as vest from '@/vest'; +import { create, group } from 'vest'; +import * as vest from 'vest'; const modes = ['SuiteRunResult', 'SuiteResult']; diff --git a/packages/vest/src/suiteResult/selectors/__tests__/hasFailures.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/hasFailures.test.ts index 181f4c78b..99def221c 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/hasFailures.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/hasFailures.test.ts @@ -2,7 +2,7 @@ import { faker } from '@faker-js/faker'; import { dummyTest } from '../../../testUtils/testDummy'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('produce method: hasFailures', () => { const fieldName = faker.lorem.word(); diff --git a/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts index 4a7f80c51..9a463fa8c 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts @@ -3,7 +3,7 @@ import { faker } from '@faker-js/faker'; import { dummyTest } from '../../../testUtils/testDummy'; import { TTestSuite } from '@/testUtils/TVestMock'; -import * as vest from '@/vest'; +import * as vest from 'vest'; const fieldName = faker.lorem.word(); const groupName = faker.lorem.word(); diff --git a/packages/vest/src/suiteResult/selectors/__tests__/isPending.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/isPending.test.ts index 7be13cdb2..3e60bfa88 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/isPending.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/isPending.test.ts @@ -1,6 +1,6 @@ import wait from 'wait'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('isPending()', () => { describe('base case', () => { diff --git a/packages/vest/src/suiteResult/selectors/__tests__/isTested.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/isTested.test.ts index 6569ce02d..32543cf06 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/isTested.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/isTested.test.ts @@ -1,6 +1,6 @@ import wait from 'wait'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('isTested', () => { describe('When no field name is passed', () => { diff --git a/packages/vest/src/suiteResult/selectors/__tests__/isValid.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/isValid.test.ts index 7f55571be..a65042ca5 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/isValid.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/isValid.test.ts @@ -3,7 +3,7 @@ import wait from 'wait'; import { TestPromise } from '../../../testUtils/testPromise'; -import { test, optional, create, skipWhen, warn, skip, only } from '@/vest'; +import { test, optional, create, skipWhen, warn, skip, only } from 'vest'; describe('isValid', () => { describe('Before any test ran', () => { diff --git a/packages/vest/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts index a74354acb..c75548f61 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts @@ -13,8 +13,8 @@ import { skip, only, group, -} from '@/vest'; -import * as vest from '@/vest'; +} from 'vest'; +import * as vest from 'vest'; const GROUP_NAME = 'group_1'; diff --git a/packages/vest/src/suiteResult/selectors/__tests__/summaryFailures.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/summaryFailures.test.ts index 26f72d3de..baef8d210 100644 --- a/packages/vest/src/suiteResult/selectors/__tests__/summaryFailures.test.ts +++ b/packages/vest/src/suiteResult/selectors/__tests__/summaryFailures.test.ts @@ -1,6 +1,6 @@ import { TTestSuite } from '@/testUtils/TVestMock'; -import * as vest from '@/vest'; +import * as vest from 'vest'; describe('summaryFailures', () => { let suite: TTestSuite = vest.create(() => {}); diff --git a/packages/vest/src/testUtils/TVestMock.ts b/packages/vest/src/testUtils/TVestMock.ts index cada08505..975f11260 100644 --- a/packages/vest/src/testUtils/TVestMock.ts +++ b/packages/vest/src/testUtils/TVestMock.ts @@ -1,5 +1,5 @@ import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; -import * as vest from '@/vest'; +import * as vest from 'vest'; export type TVestMock = typeof vest; diff --git a/packages/vest/src/testUtils/suiteDummy.ts b/packages/vest/src/testUtils/suiteDummy.ts index 216fa2dbf..bd617a334 100644 --- a/packages/vest/src/testUtils/suiteDummy.ts +++ b/packages/vest/src/testUtils/suiteDummy.ts @@ -3,7 +3,7 @@ import { OneOrMoreOf, asArray, Maybe } from 'vest-utils'; import { dummyTest } from './testDummy'; import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; -import { optional, create, skip, SuiteResult } from '@/vest'; +import { optional, create, skip, SuiteResult } from 'vest'; export function failing(failingFields?: OneOrMoreOf) { return createSuiteRunResult(failingFields, fieldName => { diff --git a/packages/vest/src/testUtils/testDummy.ts b/packages/vest/src/testUtils/testDummy.ts index 5efe175e3..73882c884 100644 --- a/packages/vest/src/testUtils/testDummy.ts +++ b/packages/vest/src/testUtils/testDummy.ts @@ -1,7 +1,7 @@ /* eslint-disable jest/valid-title */ import { faker } from '@faker-js/faker'; -import { test as vestTest, warn } from '@/vest'; +import { test as vestTest, warn } from 'vest'; /** * Generates dummy vest tests. diff --git a/packages/vestjs-runtime/src/exports/IsolateSerializer.ts b/packages/vestjs-runtime/src/exports/IsolateSerializer.ts index d327d0893..f407d107a 100644 --- a/packages/vestjs-runtime/src/exports/IsolateSerializer.ts +++ b/packages/vestjs-runtime/src/exports/IsolateSerializer.ts @@ -7,11 +7,12 @@ import { text, } from 'vest-utils'; import { expandObject, minifyObject } from 'vest-utils/minifyObject'; +import { IsolateMutator } from 'vestjs-runtime'; -import { TIsolate } from '../../types/vestjs-runtime'; import { ExcludedFromDump, IsolateKeys } from '../Isolate/IsolateKeys'; import { ErrorStrings } from '../errors/ErrorStrings'; -import { IsolateMutator } from '../vestjs-runtime'; + +import { TIsolate } from '@/Isolate/Isolate'; export class IsolateSerializer { // eslint-disable-next-line max-statements, complexity, max-lines-per-function diff --git a/packages/vestjs-runtime/src/exports/__tests__/IsolateSerializer.test.ts b/packages/vestjs-runtime/src/exports/__tests__/IsolateSerializer.test.ts index a571110be..f8d0def93 100644 --- a/packages/vestjs-runtime/src/exports/__tests__/IsolateSerializer.test.ts +++ b/packages/vestjs-runtime/src/exports/__tests__/IsolateSerializer.test.ts @@ -1,11 +1,7 @@ import { CB, Maybe } from 'vest-utils'; -import { - Isolate, - IsolateSerializer, - TIsolate, - VestRuntime, -} from 'vestjs-runtime'; +import { IsolateSerializer } from '@exports/IsolateSerializer'; +import { Isolate, TIsolate, VestRuntime } from 'vestjs-runtime'; describe('IsolateSerializer', () => { describe('serialize', () => { diff --git a/vitest.config.ts b/vitest.config.ts index 3b73351e3..783a8a139 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,3 +1,5 @@ +import path from 'path'; + import tsconfigPaths from 'vite-tsconfig-paths'; import { defineConfig } from 'vitest/config'; @@ -5,7 +7,9 @@ export default defineConfig({ test: { globals: true, include: ['packages/*/**/__tests__/*.test.ts'], - setupFiles: ['./vx/config/vitest/customMatchers.ts'], + setupFiles: [ + path.resolve(__dirname, './vx/config/vitest/customMatchers.ts'), + ], }, root: __dirname, plugins: [ From 888f63cd7839e121a96c33f7fbe70633b8c8357e Mon Sep 17 00:00:00 2001 From: ealush Date: Sun, 28 Jul 2024 00:29:55 +0300 Subject: [PATCH 12/16] progress --- packages/n4s/src/__tests__/enforce.test.ts | 2 +- .../n4s/src/exports/__tests__/compose.test.ts | 7 +- .../core/isolate/IsolateTest/IsolateTest.ts | 6 +- packages/vest/src/core/test/TestTypes.ts | 2 +- .../__tests__/__snapshots__/memo.test.ts.snap | 148 +++++++++++++- .../vest/src/core/test/__tests__/memo.test.ts | 2 +- .../src/exports/__tests__/debounce.test.ts | 3 +- .../__snapshots__/staticSuite.test.ts.snap | 191 +++++++++++++++++- .../src/suite/__tests__/staticSuite.test.ts | 3 +- .../src/suite/__tests__/subscribe.test.ts | 3 +- .../__tests__/IsolateSerializer.test.ts | 3 +- vitest.config.ts | 4 +- 12 files changed, 356 insertions(+), 18 deletions(-) diff --git a/packages/n4s/src/__tests__/enforce.test.ts b/packages/n4s/src/__tests__/enforce.test.ts index dc76454e9..ad71fc76f 100644 --- a/packages/n4s/src/__tests__/enforce.test.ts +++ b/packages/n4s/src/__tests__/enforce.test.ts @@ -8,7 +8,7 @@ let enforce: TEnforceMock; describe(`enforce`, () => { beforeEach(() => { vi.resetModules(); - enforce = require('enforce').enforce as TEnforceMock; + enforce = require('n4s').enforce as TEnforceMock; }); afterEach(() => { diff --git a/packages/n4s/src/exports/__tests__/compose.test.ts b/packages/n4s/src/exports/__tests__/compose.test.ts index 3e161ad0b..525b00bed 100644 --- a/packages/n4s/src/exports/__tests__/compose.test.ts +++ b/packages/n4s/src/exports/__tests__/compose.test.ts @@ -1,8 +1,9 @@ +import compose from '../compose'; + import * as ruleReturn from '@/lib/ruleReturn'; -import compose from '@exports/compose'; import { enforce } from 'n4s'; -import '@exports/schema'; -import '@exports/compounds'; +import '../schema'; +import '../compounds'; describe('compose', () => { it('Should create "and" relationship between composed rules', () => { diff --git a/packages/vest/src/core/isolate/IsolateTest/IsolateTest.ts b/packages/vest/src/core/isolate/IsolateTest/IsolateTest.ts index a01a3af06..0798d4a16 100644 --- a/packages/vest/src/core/isolate/IsolateTest/IsolateTest.ts +++ b/packages/vest/src/core/isolate/IsolateTest/IsolateTest.ts @@ -1,4 +1,4 @@ -import { CB, Maybe } from 'vest-utils'; +import type { CB, Maybe } from 'vest-utils'; import { TIsolate, Isolate, IsolateKey } from 'vestjs-runtime'; import { @@ -6,9 +6,9 @@ import { TestStatus, } from '@/core/StateMachines/IsolateTestStateMachine'; import { VestIsolateType } from '@/core/isolate/VestIsolateType'; -import { AsyncTest, TestFn } from '@/core/test/TestTypes'; +import type { AsyncTest, TestFn } from '@/core/test/TestTypes'; import { TestSeverity } from '@/suiteResult/Severity'; -import { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; +import type { TFieldName, TGroupName } from '@/suiteResult/SuiteResultTypes'; export type TIsolateTest< F extends TFieldName = TFieldName, diff --git a/packages/vest/src/core/test/TestTypes.ts b/packages/vest/src/core/test/TestTypes.ts index 64d6cfcb7..3240edfaa 100644 --- a/packages/vest/src/core/test/TestTypes.ts +++ b/packages/vest/src/core/test/TestTypes.ts @@ -1,6 +1,6 @@ import { Maybe } from 'vest-utils'; -import { TFieldName } from '@/suiteResult/SuiteResultTypes'; +import type { TFieldName } from '@/suiteResult/SuiteResultTypes'; export type TestFnPayload = { signal: AbortSignal }; diff --git a/packages/vest/src/core/test/__tests__/__snapshots__/memo.test.ts.snap b/packages/vest/src/core/test/__tests__/__snapshots__/memo.test.ts.snap index 7a6958c86..9460858f7 100644 --- a/packages/vest/src/core/test/__tests__/__snapshots__/memo.test.ts.snap +++ b/packages/vest/src/core/test/__tests__/__snapshots__/memo.test.ts.snap @@ -1,4 +1,150 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`test.memo > cache hit > Should produce correct initial result 1`] = ` +{ + "done": [Function], + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "field1", + "groupName": undefined, + "message": "msg1", + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 4, + "tests": { + "field1": { + "errorCount": 1, + "errors": [ + "msg1", + ], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "field3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 1, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 1, + "warnings": [ + SummaryFailure { + "fieldName": "field3", + "groupName": undefined, + "message": undefined, + }, + ], +} +`; + +exports[`test.memo > cache hit > sync > Should restore previous result on re-run 1`] = ` +{ + "done": [Function], + "errorCount": 1, + "errors": [ + SummaryFailure { + "fieldName": "field1", + "groupName": undefined, + "message": "msg1", + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": {}, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 4, + "tests": { + "field1": { + "errorCount": 1, + "errors": [ + "msg1", + ], + "pendingCount": 0, + "testCount": 2, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "field2": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 0, + "warnings": [], + }, + "field3": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": true, + "warnCount": 1, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 1, + "warnings": [ + SummaryFailure { + "fieldName": "field3", + "groupName": undefined, + "message": undefined, + }, + ], +} +`; exports[`test.memo cache hit Should produce correct initial result 1`] = ` { diff --git a/packages/vest/src/core/test/__tests__/memo.test.ts b/packages/vest/src/core/test/__tests__/memo.test.ts index f8195ef43..a243c46b7 100644 --- a/packages/vest/src/core/test/__tests__/memo.test.ts +++ b/packages/vest/src/core/test/__tests__/memo.test.ts @@ -1,11 +1,11 @@ import wait from 'wait'; +import promisify from '../../../exports/promisify'; import { TestPromise } from '../../../testUtils/testPromise'; import { TIsolateTest } from '@/core/isolate/IsolateTest/IsolateTest'; import { VestTest } from '@/core/isolate/IsolateTest/VestTest'; import { Modes } from '@/hooks/optional/Modes'; -import promisify from '@exports/promisify'; import * as vest from 'vest'; import { test as vestTest, enforce } from 'vest'; diff --git a/packages/vest/src/exports/__tests__/debounce.test.ts b/packages/vest/src/exports/__tests__/debounce.test.ts index 23c6d5ae3..e6537bd4b 100644 --- a/packages/vest/src/exports/__tests__/debounce.test.ts +++ b/packages/vest/src/exports/__tests__/debounce.test.ts @@ -1,8 +1,9 @@ import wait from 'wait'; +import debounce from '../debounce'; + import { TestFnPayload } from '@/core/test/TestTypes'; import * as vest from 'vest'; -import debounce from '@exports/debounce'; describe('debounce', () => { describe('Sync test', () => { diff --git a/packages/vest/src/suite/__tests__/__snapshots__/staticSuite.test.ts.snap b/packages/vest/src/suite/__tests__/__snapshots__/staticSuite.test.ts.snap index b97c65e55..a126e8edf 100644 --- a/packages/vest/src/suite/__tests__/__snapshots__/staticSuite.test.ts.snap +++ b/packages/vest/src/suite/__tests__/__snapshots__/staticSuite.test.ts.snap @@ -1,4 +1,193 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`staticSuite > dump > should output a dump of the suite 1`] = ` +{ + "$type": "Suite", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": [ + { + "$type": "Test", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": { + "fieldName": "t1", + "severity": "error", + "testFn": [Function], + }, + "key": null, + "keys": null, + "output": undefined, + "parent": [Circular], + "status": "FAILED", + }, + { + "$type": "Test", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": { + "fieldName": "t2", + "severity": "error", + "testFn": [Function], + }, + "key": null, + "keys": null, + "output": undefined, + "parent": [Circular], + "status": "FAILED", + }, + { + "$type": "Group", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": [ + { + "$type": "Test", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": { + "fieldName": "t1", + "groupName": "g1", + "severity": "error", + "testFn": [Function], + }, + "key": null, + "keys": null, + "output": undefined, + "parent": [Circular], + "status": "SKIPPED", + }, + { + "$type": "Test", + "abortController": AbortController {}, + "allowReorder": undefined, + "children": null, + "data": { + "fieldName": "t3", + "groupName": "g1", + "severity": "error", + "testFn": [Function], + }, + "key": null, + "keys": null, + "output": undefined, + "parent": [Circular], + "status": "FAILED", + }, + ], + "data": {}, + "key": null, + "keys": null, + "output": undefined, + "parent": [Circular], + "status": "DONE", + }, + ], + "data": { + "optional": {}, + }, + "key": null, + "keys": null, + "output": { + "done": [Function], + "errorCount": 3, + "errors": [ + SummaryFailure { + "fieldName": "t1", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "t2", + "groupName": undefined, + "message": undefined, + }, + SummaryFailure { + "fieldName": "t3", + "groupName": "g1", + "message": undefined, + }, + ], + "getError": [Function], + "getErrors": [Function], + "getErrorsByGroup": [Function], + "getMessage": [Function], + "getWarning": [Function], + "getWarnings": [Function], + "getWarningsByGroup": [Function], + "groups": { + "g1": { + "t1": SummaryBase { + "errorCount": 0, + "errors": [], + "pendingCount": 0, + "testCount": 0, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "t3": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + }, + "hasErrors": [Function], + "hasErrorsByGroup": [Function], + "hasWarnings": [Function], + "hasWarningsByGroup": [Function], + "isPending": [Function], + "isTested": [Function], + "isValid": [Function], + "isValidByGroup": [Function], + "pendingCount": 0, + "suiteName": undefined, + "testCount": 3, + "tests": { + "t1": { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "t2": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "t3": SummaryBase { + "errorCount": 1, + "errors": [], + "pendingCount": 0, + "testCount": 1, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + }, + "valid": false, + "warnCount": 0, + "warnings": [], + }, + "parent": null, + "status": "DONE", +} +`; exports[`staticSuite dump should output a dump of the suite 1`] = ` { diff --git a/packages/vest/src/suite/__tests__/staticSuite.test.ts b/packages/vest/src/suite/__tests__/staticSuite.test.ts index 3bc6be3a7..12b4c18fb 100644 --- a/packages/vest/src/suite/__tests__/staticSuite.test.ts +++ b/packages/vest/src/suite/__tests__/staticSuite.test.ts @@ -1,7 +1,8 @@ import wait from 'wait'; +import { SuiteSerializer } from '../../exports/SuiteSerializer'; + import { VestIsolateType } from '@/core/isolate/VestIsolateType'; -import { SuiteSerializer } from '@exports/SuiteSerializer'; import * as vest from 'vest'; import { staticSuite } from 'vest'; diff --git a/packages/vest/src/suite/__tests__/subscribe.test.ts b/packages/vest/src/suite/__tests__/subscribe.test.ts index 60a0418c2..e521ca0f6 100644 --- a/packages/vest/src/suite/__tests__/subscribe.test.ts +++ b/packages/vest/src/suite/__tests__/subscribe.test.ts @@ -1,7 +1,8 @@ import { enforce } from 'n4s'; import wait from 'wait'; -import { SuiteSerializer } from '@exports/SuiteSerializer'; +import { SuiteSerializer } from '../../exports/SuiteSerializer'; + import * as vest from 'vest'; describe('suite.subscribe', () => { diff --git a/packages/vestjs-runtime/src/exports/__tests__/IsolateSerializer.test.ts b/packages/vestjs-runtime/src/exports/__tests__/IsolateSerializer.test.ts index f8d0def93..eb5ddcdaa 100644 --- a/packages/vestjs-runtime/src/exports/__tests__/IsolateSerializer.test.ts +++ b/packages/vestjs-runtime/src/exports/__tests__/IsolateSerializer.test.ts @@ -1,6 +1,7 @@ import { CB, Maybe } from 'vest-utils'; -import { IsolateSerializer } from '@exports/IsolateSerializer'; +import { IsolateSerializer } from '../IsolateSerializer'; + import { Isolate, TIsolate, VestRuntime } from 'vestjs-runtime'; describe('IsolateSerializer', () => { diff --git a/vitest.config.ts b/vitest.config.ts index 783a8a139..076322441 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -7,9 +7,7 @@ export default defineConfig({ test: { globals: true, include: ['packages/*/**/__tests__/*.test.ts'], - setupFiles: [ - path.resolve(__dirname, './vx/config/vitest/customMatchers.ts'), - ], + setupFiles: ['./vx/config/vitest/customMatchers'], }, root: __dirname, plugins: [ From 91b6bc91b7e2a0eca1d9b1187b48a4f60add4c7a Mon Sep 17 00:00:00 2001 From: ealush Date: Sun, 28 Jul 2024 00:34:43 +0300 Subject: [PATCH 13/16] updating incorrect snapshot --- .../plugins/schema/__tests__/shape.test.ts | 2 +- .../useProduceSuiteSummary.test.ts.snap | 131 ------------------ 2 files changed, 1 insertion(+), 132 deletions(-) diff --git a/packages/n4s/src/plugins/schema/__tests__/shape.test.ts b/packages/n4s/src/plugins/schema/__tests__/shape.test.ts index 95da0562b..3dafea728 100644 --- a/packages/n4s/src/plugins/schema/__tests__/shape.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/shape.test.ts @@ -1,5 +1,5 @@ -import { enforce } from '@/runtime/enforce'; import * as ruleReturn from '@/lib/ruleReturn'; +import { enforce } from '@/runtime/enforce'; import 'schema'; import 'compounds'; diff --git a/packages/vest/src/suiteResult/__tests__/__snapshots__/useProduceSuiteSummary.test.ts.snap b/packages/vest/src/suiteResult/__tests__/__snapshots__/useProduceSuiteSummary.test.ts.snap index 1981d84af..784f43cc2 100644 --- a/packages/vest/src/suiteResult/__tests__/__snapshots__/useProduceSuiteSummary.test.ts.snap +++ b/packages/vest/src/suiteResult/__tests__/__snapshots__/useProduceSuiteSummary.test.ts.snap @@ -1,72 +1,6 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`suite() > exposed methods > Should have all exposed methods 1`] = ` -{ - "done": [Function], - "errorCount": 3, - "errors": [ - SummaryFailure { - "fieldName": "f2", - "groupName": undefined, - "message": undefined, - }, - SummaryFailure { - "fieldName": "f1", - "groupName": undefined, - "message": undefined, - }, - SummaryFailure { - "fieldName": "f2", - "groupName": undefined, - "message": undefined, - }, - ], - "getError": [Function], - "getErrors": [Function], - "getErrorsByGroup": [Function], - "getMessage": [Function], - "getWarning": [Function], - "getWarnings": [Function], - "getWarningsByGroup": [Function], - "groups": {}, - "hasErrors": [Function], - "hasErrorsByGroup": [Function], - "hasWarnings": [Function], - "hasWarningsByGroup": [Function], - "isPending": [Function], - "isTested": [Function], - "isValid": [Function], - "isValidByGroup": [Function], - "pendingCount": 0, - "suiteName": undefined, - "testCount": 6, - "tests": { - "f1": { - "errorCount": 1, - "errors": [], - "pendingCount": 0, - "testCount": 3, - "valid": false, - "warnCount": 0, - "warnings": [], - }, - "f2": { - "errorCount": 2, - "errors": [], - "pendingCount": 0, - "testCount": 3, - "valid": false, - "warnCount": 0, - "warnings": [], - }, - }, - "valid": false, - "warnCount": 0, - "warnings": [], -} -`; - -exports[`suite() exposed methods Should have all exposed methods 1`] = ` { "done": [Function], "errorCount": 0, @@ -98,71 +32,6 @@ exports[`suite() exposed methods Should have all exposed methods 1`] = ` `; exports[`suite.get() > exposed methods > Should have all exposed methods 1`] = ` -SuiteSummary { - "errorCount": 3, - "errors": [ - SummaryFailure { - "fieldName": "f2", - "groupName": undefined, - "message": undefined, - }, - SummaryFailure { - "fieldName": "f1", - "groupName": undefined, - "message": undefined, - }, - SummaryFailure { - "fieldName": "f2", - "groupName": undefined, - "message": undefined, - }, - ], - "getError": [Function], - "getErrors": [Function], - "getErrorsByGroup": [Function], - "getMessage": [Function], - "getWarning": [Function], - "getWarnings": [Function], - "getWarningsByGroup": [Function], - "groups": {}, - "hasErrors": [Function], - "hasErrorsByGroup": [Function], - "hasWarnings": [Function], - "hasWarningsByGroup": [Function], - "isPending": [Function], - "isTested": [Function], - "isValid": [Function], - "isValidByGroup": [Function], - "pendingCount": 0, - "suiteName": undefined, - "testCount": 6, - "tests": { - "f1": { - "errorCount": 1, - "errors": [], - "pendingCount": 0, - "testCount": 3, - "valid": false, - "warnCount": 0, - "warnings": [], - }, - "f2": { - "errorCount": 2, - "errors": [], - "pendingCount": 0, - "testCount": 3, - "valid": false, - "warnCount": 0, - "warnings": [], - }, - }, - "valid": false, - "warnCount": 0, - "warnings": [], -} -`; - -exports[`suite.get() exposed methods Should have all exposed methods 1`] = ` SuiteSummary { "errorCount": 0, "errors": [], From 42f7f1dec6656c6473d5f95d28cded655b137011 Mon Sep 17 00:00:00 2001 From: ealush Date: Sun, 28 Jul 2024 00:44:50 +0300 Subject: [PATCH 14/16] Imporve n4s tests --- packages/n4s/src/exports/date.ts | 1 - packages/n4s/src/exports/schema.ts | 1 - packages/n4s/src/plugins/schema/__tests__/isArrayOf.test.ts | 4 ++-- packages/n4s/src/plugins/schema/__tests__/loose.test.ts | 4 ++-- packages/n4s/src/plugins/schema/__tests__/optional.test.ts | 6 +++--- packages/n4s/src/plugins/schema/__tests__/partial.test.ts | 5 +++-- .../n4s/src/plugins/schema/__tests__/shape&loose.test.ts | 6 +++--- packages/n4s/src/plugins/schema/__tests__/shape.test.ts | 4 ++-- packages/vest/src/__tests__/isolate.test.ts | 2 +- packages/vest/src/exports/parser.ts | 1 - 10 files changed, 16 insertions(+), 18 deletions(-) diff --git a/packages/n4s/src/exports/date.ts b/packages/n4s/src/exports/date.ts index ae38a848f..e90356e67 100644 --- a/packages/n4s/src/exports/date.ts +++ b/packages/n4s/src/exports/date.ts @@ -6,7 +6,6 @@ import isISO8601 from 'validator/es/lib/isISO8601'; import { EnforceCustomMatcher } from '../lib/enforceUtilityTypes'; - enforce.extend({ isAfter, isBefore, isDate, isISO8601 }); /* eslint-disable @typescript-eslint/no-namespace */ diff --git a/packages/n4s/src/exports/schema.ts b/packages/n4s/src/exports/schema.ts index 4aa0ed490..7fc0add5e 100644 --- a/packages/n4s/src/exports/schema.ts +++ b/packages/n4s/src/exports/schema.ts @@ -6,7 +6,6 @@ import { loose } from '../plugins/schema/loose'; import { optional } from '../plugins/schema/optional'; import { shape } from '../plugins/schema/shape'; - enforce.extend({ isArrayOf, loose, optional, shape }); /* eslint-disable @typescript-eslint/no-namespace */ diff --git a/packages/n4s/src/plugins/schema/__tests__/isArrayOf.test.ts b/packages/n4s/src/plugins/schema/__tests__/isArrayOf.test.ts index 89342565d..4d7f441c9 100644 --- a/packages/n4s/src/plugins/schema/__tests__/isArrayOf.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/isArrayOf.test.ts @@ -1,6 +1,6 @@ import { enforce } from '@/runtime/enforce'; -import 'schema'; -import 'compounds'; +import '../../../exports/schema'; +import '../../../exports/compounds'; import * as ruleReturn from '@/lib/ruleReturn'; describe('enforce.isArrayOf', () => { diff --git a/packages/n4s/src/plugins/schema/__tests__/loose.test.ts b/packages/n4s/src/plugins/schema/__tests__/loose.test.ts index 8d545873f..3f61ac101 100644 --- a/packages/n4s/src/plugins/schema/__tests__/loose.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/loose.test.ts @@ -1,6 +1,6 @@ -import { enforce } from '@/runtime/enforce'; import * as ruleReturn from '@/lib/ruleReturn'; -import 'schema'; +import { enforce } from '@/runtime/enforce'; +import '../../../exports/schema'; describe('enforce.loose for loose matching', () => { describe('lazy interface', () => { diff --git a/packages/n4s/src/plugins/schema/__tests__/optional.test.ts b/packages/n4s/src/plugins/schema/__tests__/optional.test.ts index 608fe7bf3..6c809b167 100644 --- a/packages/n4s/src/plugins/schema/__tests__/optional.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/optional.test.ts @@ -1,7 +1,7 @@ -import { enforce } from '@/runtime/enforce'; import * as ruleReturn from '@/lib/ruleReturn'; -import 'schema'; -import 'compounds'; +import { enforce } from '@/runtime/enforce'; +import '../../../exports/schema'; +import '../../../exports/compounds'; describe('enforce.optional', () => { describe('lazy interface', () => { diff --git a/packages/n4s/src/plugins/schema/__tests__/partial.test.ts b/packages/n4s/src/plugins/schema/__tests__/partial.test.ts index 522e9bed2..87620a41b 100644 --- a/packages/n4s/src/plugins/schema/__tests__/partial.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/partial.test.ts @@ -1,7 +1,8 @@ import * as ruleReturn from '@/lib/ruleReturn'; -import { enforce } from '@/runtime/enforce'; +import { enforce } from 'n4s'; -import 'compounds'; +import '../../../exports/schema'; +import '../../../exports/compounds'; import { partial } from '../partial'; describe('partial', () => { diff --git a/packages/n4s/src/plugins/schema/__tests__/shape&loose.test.ts b/packages/n4s/src/plugins/schema/__tests__/shape&loose.test.ts index 1f7509ece..acc3daae2 100644 --- a/packages/n4s/src/plugins/schema/__tests__/shape&loose.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/shape&loose.test.ts @@ -1,7 +1,7 @@ -import { enforce } from '@/runtime/enforce'; import * as ruleReturn from '@/lib/ruleReturn'; -import 'schema'; -import 'compounds'; +import { enforce } from '@/runtime/enforce'; +import '../../../exports/schema'; +import '../../../exports/compounds'; /* eslint-disable sort-keys */ diff --git a/packages/n4s/src/plugins/schema/__tests__/shape.test.ts b/packages/n4s/src/plugins/schema/__tests__/shape.test.ts index 3dafea728..3ad608c69 100644 --- a/packages/n4s/src/plugins/schema/__tests__/shape.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/shape.test.ts @@ -1,7 +1,7 @@ import * as ruleReturn from '@/lib/ruleReturn'; import { enforce } from '@/runtime/enforce'; -import 'schema'; -import 'compounds'; +import '../../../exports/schema'; +import '../../../exports/compounds'; describe('enforce.shape exact matching', () => { describe('lazy interface', () => { diff --git a/packages/vest/src/__tests__/isolate.test.ts b/packages/vest/src/__tests__/isolate.test.ts index 5192a4897..57833e1b5 100644 --- a/packages/vest/src/__tests__/isolate.test.ts +++ b/packages/vest/src/__tests__/isolate.test.ts @@ -6,7 +6,7 @@ import { TVestMock } from '../testUtils/TVestMock'; import mockThrowError from '../testUtils/mockThrowError'; import { TDummyTest } from '../testUtils/testDummy'; -describe.skip('isolate', () => { +describe('isolate', () => { let vest: TVestMock; let firstRun = true; vi.importActual('@/core/isolate/IsolateTest/IsolateTest'); diff --git a/packages/vest/src/exports/parser.ts b/packages/vest/src/exports/parser.ts index 21274b2c9..19ddf8aa4 100644 --- a/packages/vest/src/exports/parser.ts +++ b/packages/vest/src/exports/parser.ts @@ -4,7 +4,6 @@ import { hasOwnProperty, invariant, isNullish, isPositive } from 'vest-utils'; import { ErrorStrings } from '../errors/ErrorStrings'; import { TFieldName, TGroupName } from '../suiteResult/SuiteResultTypes'; - export function parse( summary: SuiteSummary, ): ParsedVestObject { From a779324a55dee96eb2abe24c705cc4f5c85a69ae Mon Sep 17 00:00:00 2001 From: ealush Date: Sun, 28 Jul 2024 00:48:29 +0300 Subject: [PATCH 15/16] fix compounds --- packages/n4s/src/exports/__tests__/email.test.ts | 2 +- packages/n4s/src/exports/__tests__/isUrl.test.ts | 2 +- packages/n4s/src/plugins/compounds/__tests__/allOf.test.ts | 4 ++-- packages/n4s/src/plugins/compounds/__tests__/noneOf.test.ts | 2 +- packages/n4s/src/plugins/compounds/__tests__/oneOf.test.ts | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/n4s/src/exports/__tests__/email.test.ts b/packages/n4s/src/exports/__tests__/email.test.ts index 370e7fbec..e9c9466d9 100644 --- a/packages/n4s/src/exports/__tests__/email.test.ts +++ b/packages/n4s/src/exports/__tests__/email.test.ts @@ -1,5 +1,5 @@ import { enforce } from 'n4s'; -import 'email'; +import '../email'; describe('isEmail', () => { it('Should pass for valid emails', () => { diff --git a/packages/n4s/src/exports/__tests__/isUrl.test.ts b/packages/n4s/src/exports/__tests__/isUrl.test.ts index 837d14269..80a882eea 100644 --- a/packages/n4s/src/exports/__tests__/isUrl.test.ts +++ b/packages/n4s/src/exports/__tests__/isUrl.test.ts @@ -1,5 +1,5 @@ import { enforce } from 'n4s'; -import 'isURL'; +import '../isURL'; describe('isURL', () => { it('Should pass for valid URLs', () => { diff --git a/packages/n4s/src/plugins/compounds/__tests__/allOf.test.ts b/packages/n4s/src/plugins/compounds/__tests__/allOf.test.ts index 650c414f2..f48feddd6 100644 --- a/packages/n4s/src/plugins/compounds/__tests__/allOf.test.ts +++ b/packages/n4s/src/plugins/compounds/__tests__/allOf.test.ts @@ -1,6 +1,6 @@ -import { enforce } from '@/runtime/enforce'; import * as ruleReturn from '@/lib/ruleReturn'; -import 'compounds'; +import { enforce } from '@/runtime/enforce'; +import '../../../exports/compounds'; describe('allOf', () => { describe('Lazy Assertions', () => { diff --git a/packages/n4s/src/plugins/compounds/__tests__/noneOf.test.ts b/packages/n4s/src/plugins/compounds/__tests__/noneOf.test.ts index c7889a59b..9b689e7c2 100644 --- a/packages/n4s/src/plugins/compounds/__tests__/noneOf.test.ts +++ b/packages/n4s/src/plugins/compounds/__tests__/noneOf.test.ts @@ -1,7 +1,7 @@ import * as ruleReturn from '@/lib/ruleReturn'; import { enforce } from '@/runtime/enforce'; -import 'compounds'; +import '../../../exports/compounds'; describe('noneOf', () => { describe('Lazy Assertions', () => { diff --git a/packages/n4s/src/plugins/compounds/__tests__/oneOf.test.ts b/packages/n4s/src/plugins/compounds/__tests__/oneOf.test.ts index 2278d1cb9..75c22c55a 100644 --- a/packages/n4s/src/plugins/compounds/__tests__/oneOf.test.ts +++ b/packages/n4s/src/plugins/compounds/__tests__/oneOf.test.ts @@ -1,8 +1,8 @@ -import { enforce } from '@/runtime/enforce'; import * as ruleReturn from '@/lib/ruleReturn'; +import { enforce } from '@/runtime/enforce'; -import 'schema'; -import 'compounds'; +import '../../../exports/schema'; +import '../../../exports/compounds'; describe('enforce.oneOf', () => { it('Should fail when multiple enforcements are met', () => { From 44876a7b9fed0ddddabb764bedf3939860f80ac4 Mon Sep 17 00:00:00 2001 From: ealush Date: Sun, 28 Jul 2024 01:15:35 +0300 Subject: [PATCH 16/16] better --- .../schema/__tests__/isArrayOf.test.ts | 2 +- .../plugins/schema/__tests__/partial.test.ts | 3 +- packages/vest/src/__tests__/isolate.test.ts | 76 ++++--------------- .../__tests__/IsolateSerializer.test.ts | 20 +---- 4 files changed, 20 insertions(+), 81 deletions(-) diff --git a/packages/n4s/src/plugins/schema/__tests__/isArrayOf.test.ts b/packages/n4s/src/plugins/schema/__tests__/isArrayOf.test.ts index 4d7f441c9..c64854022 100644 --- a/packages/n4s/src/plugins/schema/__tests__/isArrayOf.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/isArrayOf.test.ts @@ -1,7 +1,7 @@ +import * as ruleReturn from '@/lib/ruleReturn'; import { enforce } from '@/runtime/enforce'; import '../../../exports/schema'; import '../../../exports/compounds'; -import * as ruleReturn from '@/lib/ruleReturn'; describe('enforce.isArrayOf', () => { describe('lazy interface', () => { diff --git a/packages/n4s/src/plugins/schema/__tests__/partial.test.ts b/packages/n4s/src/plugins/schema/__tests__/partial.test.ts index 87620a41b..af7d0cfde 100644 --- a/packages/n4s/src/plugins/schema/__tests__/partial.test.ts +++ b/packages/n4s/src/plugins/schema/__tests__/partial.test.ts @@ -1,9 +1,10 @@ +import { partial } from '../partial'; + import * as ruleReturn from '@/lib/ruleReturn'; import { enforce } from 'n4s'; import '../../../exports/schema'; import '../../../exports/compounds'; -import { partial } from '../partial'; describe('partial', () => { describe('Lazy Interface', () => { diff --git a/packages/vest/src/__tests__/isolate.test.ts b/packages/vest/src/__tests__/isolate.test.ts index 57833e1b5..a5cdbdb4a 100644 --- a/packages/vest/src/__tests__/isolate.test.ts +++ b/packages/vest/src/__tests__/isolate.test.ts @@ -1,35 +1,9 @@ -import { CB } from 'vest-utils'; -import { TDeferThrow } from 'vest-utils/src/deferThrow'; import { Isolate } from 'vestjs-runtime'; -import { TVestMock } from '../testUtils/TVestMock'; -import mockThrowError from '../testUtils/mockThrowError'; -import { TDummyTest } from '../testUtils/testDummy'; +import { dummyTest } from '@/testUtils/testDummy'; +import * as vest from 'vest'; describe('isolate', () => { - let vest: TVestMock; - let firstRun = true; - vi.importActual('@/core/isolate/IsolateTest/IsolateTest'); - vi.importActual('@/core/isolate/IsolateTest/IsolateEach'); - let dummyTest: TDummyTest; - let deferThrow: TDeferThrow; - - beforeEach(() => { - firstRun = true; - const mock = mockThrowError(); - deferThrow = mock.deferThrow; - - vi.importActual('@/core/isolate/IsolateTest/IsolateTest'); - vi.importActual('@/core/isolate/IsolateTest/IsolateEach'); - vest = mock.vest; - dummyTest = require('../testUtils/testDummy').dummyTest; - }); - - afterEach(() => { - vi.resetModules(); - vi.resetAllMocks(); - }); - describe('Base behavior', () => { it("Should throw an error if the callback isn't a function", () => { // @ts-ignore - testing bad input @@ -39,7 +13,8 @@ describe('isolate', () => { it('Should retain test results between runs', () => { const f1 = vi.fn(() => false); const f2 = vi.fn(() => false); - const suite = genSuite(() => { + const firstRun = true; + const suite = vest.create(() => { vest.skipWhen(!firstRun, () => { vest.test('f1', f1); vest.test('f2', f2); @@ -61,7 +36,8 @@ describe('isolate', () => { describe('When order changes within the isolate', () => { it('Should contain test order changes within the isolate', () => { - const suite = genSuite(() => { + const firstRun = true; + const suite = vest.create(() => { dummyTest.failing('f1'); vest.group(() => { @@ -107,7 +83,8 @@ describe('isolate', () => { }); it('Should only retain the state of the unmoved state before the order index', () => { - const suite = genSuite(() => { + const firstRun = true; + const suite = vest.create(() => { vest.group(() => { vest.skipWhen(!firstRun, () => { dummyTest.failing('f1'); @@ -141,7 +118,8 @@ describe('isolate', () => { describe('When test order changes before the isolate opens', () => { it('Should clean up follow up tests. Reregister', () => { - const suite = genSuite(() => { + const firstRun = true; + const suite = vest.create(() => { dummyTest.failing('f1'); if (!firstRun) { dummyTest.failing('f6'); @@ -193,7 +171,8 @@ describe('isolate', () => { describe('When an incorrect isolate is encountered', () => { it('Should replace isolate completely', () => { - const suite = genSuite(() => { + const firstRun = true; + const suite = vest.create(() => { if (firstRun) { vest.group(() => { dummyTest.failing('f1'); @@ -220,7 +199,8 @@ describe('isolate', () => { describe('When an isolate is present when a test was expected', () => { it('Should erase test history, and re-register', () => { - const suite = genSuite(() => { + let firstRun = true; + const suite = vest.create(() => { if (firstRun) { dummyTest.failing('f1'); } else { @@ -228,6 +208,7 @@ describe('isolate', () => { dummyTest.failing('f2'); }); } + firstRun = false; }); suite(); @@ -241,32 +222,5 @@ describe('isolate', () => { expect(suite.get().tests.f1).toBeUndefined(); expect(suite.get().tests.f2).toBeDefined(); }); - - describe('Errors', () => { - it('should throw a deferred error when the tests are out of order', () => { - const suite = genSuite(() => { - vest.group(() => { - dummyTest.failing(firstRun ? 'f1' : 'f2'); - }); - }); - - suite(); - expect(deferThrow).toHaveBeenCalledTimes(0); - suite(); - expect(deferThrow).toHaveBeenCalledTimes(1); - expect(deferThrow).toHaveBeenCalledWith( - expect.stringContaining( - 'Vest Critical Error: Tests called in different order than previous run', - ), - ); - }); - }); }); - - function genSuite(cb: CB) { - return vest.create(() => { - cb(); - firstRun = false; - }); - } }); diff --git a/packages/vestjs-runtime/src/exports/__tests__/IsolateSerializer.test.ts b/packages/vestjs-runtime/src/exports/__tests__/IsolateSerializer.test.ts index eb5ddcdaa..30946e372 100644 --- a/packages/vestjs-runtime/src/exports/__tests__/IsolateSerializer.test.ts +++ b/packages/vestjs-runtime/src/exports/__tests__/IsolateSerializer.test.ts @@ -1,4 +1,4 @@ -import { CB, Maybe } from 'vest-utils'; +import { CB } from 'vest-utils'; import { IsolateSerializer } from '../IsolateSerializer'; @@ -79,22 +79,6 @@ describe('IsolateSerializer', () => { // @ts-ignore root.children[1].status = 'failed'; - const minimap = { - values: { - status: { - pending: 'p', - done: 'd', - failed: 'f', - }, - $type: { - URoot: 'UR', - UChild_1: 'UC1', - UChild_2: 'UC2', - UChild_3: 'UC3', - }, - }, - }; - const serialized = IsolateSerializer.serialize(root); const inflated = IsolateSerializer.deserialize(serialized); @@ -191,7 +175,7 @@ function withRunTime(fn: CB) { }); } -function createRoot(miniMap?: Maybe>) { +function createRoot() { let serialized: string, root: TIsolate; withRunTime(() => {