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(() => {