From 65b675255283fc88c99c2929c0a1fed573538093 Mon Sep 17 00:00:00 2001 From: Chris Thoburn Date: Wed, 18 Oct 2023 20:05:06 -0700 Subject: [PATCH] chore(internal) add @warp-drive/diagnostic/ember (#9009) * chore(internal) add @warp-drive/diagnostic/ember * chore(private): add setup to @warp-drive/diagnostic/ember * stash * make diagnostic behave like an addon when needed * maybe can do less --- packages/diagnostic/README.md | 32 +++++++++ packages/diagnostic/addon-main.cjs | 4 ++ packages/diagnostic/package.json | 36 +++++++++- packages/diagnostic/rollup.config.mjs | 4 +- packages/diagnostic/src/-types.ts | 52 +++++++------- packages/diagnostic/src/-utils.ts | 7 +- packages/diagnostic/src/ember.ts | 68 +++++++++++++++++++ packages/diagnostic/src/index.ts | 30 ++++---- packages/diagnostic/src/internals/config.ts | 19 ++++-- .../diagnostic/src/internals/diagnostic.ts | 16 ++--- packages/diagnostic/src/internals/run.ts | 12 ++-- .../addon-test-support/asserts/index.ts | 4 +- pnpm-lock.yaml | 59 ++++++++++++---- tests/builders/package.json | 1 + .../tests/integration/create-record-test.ts | 2 +- .../tests/integration/delete-record-test.ts | 2 +- .../tests/integration/update-record-test.ts | 2 +- tests/builders/tests/test-helper.js | 45 +----------- .../tests/unit/active-record-builder-test.ts | 2 +- .../tests/unit/json-api-builder-test.ts | 2 +- .../builders/tests/unit/rest-builder-test.ts | 2 +- tests/ember-data__adapter/package.json | 1 + .../tests/integration/belongs-to-test.js | 2 +- .../tests/integration/coalescing-test.js | 2 +- .../tests/integration/generate-id-test.js | 2 +- .../tests/integration/has-many-test.js | 2 +- .../tests/integration/mutations-test.js | 2 +- .../tests/integration/queries-test.js | 2 +- .../tests/integration/reload-test.js | 2 +- .../ember-data__adapter/tests/test-helper.js | 41 +---------- tests/ember-data__graph/package.json | 1 + tests/ember-data__graph/tests/.gitkeep | 0 .../graph/diff-preservation-test.ts | 2 +- .../integration/graph/duplicate-data-test.ts | 2 +- .../integration/graph/edge-removal/setup.ts | 2 +- .../tests/integration/graph/edge-test.ts | 2 +- .../tests/integration/graph/graph-test.ts | 2 +- .../graph/order-preservation-test.ts | 4 +- .../graph/polymorphism/implicit-keys-test.ts | 2 +- .../tests/integration/graph/unload-test.ts | 2 +- tests/ember-data__graph/tests/test-helper.js | 41 +---------- tests/ember-data__json-api/package.json | 1 + .../ember-data__json-api/tests/test-helper.js | 46 +------------ tests/ember-data__model/package.json | 1 + tests/ember-data__model/tests/test-helper.js | 44 +----------- tests/ember-data__request/package.json | 5 +- .../tests/integration/service-test.ts | 2 +- .../integration/stateful-handler-test.ts | 2 +- .../ember-data__request/tests/test-helper.js | 46 +------------ 49 files changed, 300 insertions(+), 364 deletions(-) create mode 100644 packages/diagnostic/addon-main.cjs create mode 100644 packages/diagnostic/src/ember.ts delete mode 100644 tests/ember-data__graph/tests/.gitkeep diff --git a/packages/diagnostic/README.md b/packages/diagnostic/README.md index dc4ee0e3df0..c04d97a6c31 100644 --- a/packages/diagnostic/README.md +++ b/packages/diagnostic/README.md @@ -52,6 +52,7 @@ or you can add your own. - [🔜 Randomization](#randomization) - [Why Is It Fast?](#why-is-it-fast) - [Migration From QUnit](#migration-from-qunit) +- [Using with Ember](#using-with-ember) --- @@ -433,6 +434,37 @@ module('My Module', function(hooks) { --- +### Using With Ember + +1. Add the following peer-deps to your app: + +```diff ++ "@ember/test-helpers": ">= 3.2.0", ++ "ember-cli-test-loader": ">= 3.1.0", ++ "@embroider/addon-shim": ">= 1.8.6" +``` + +2. Configure for ember in `test-helper.js` + +```ts +import { configure } from '@warp-drive/diagnostic/ember'; + +configure(); +``` + +3. Use setup helpers + +```ts +import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; + +module('My Module', function (hooks) { + setupTest(hooks); +}); +``` + +--- + ### ♥️ Credits
diff --git a/packages/diagnostic/addon-main.cjs b/packages/diagnostic/addon-main.cjs new file mode 100644 index 00000000000..f868d6b91ec --- /dev/null +++ b/packages/diagnostic/addon-main.cjs @@ -0,0 +1,4 @@ +'use strict'; + +const { addonV1Shim } = require('@embroider/addon-shim'); +module.exports = addonV1Shim(__dirname); diff --git a/packages/diagnostic/package.json b/packages/diagnostic/package.json index 116090c3a26..8aadceab193 100644 --- a/packages/diagnostic/package.json +++ b/packages/diagnostic/package.json @@ -14,7 +14,8 @@ "vitest", "jest", "mocha", - "chai" + "chai", + "ember-addon" ], "repository": { "type": "git", @@ -24,6 +25,7 @@ "license": "MIT", "author": "Chris Thoburn ", "files": [ + "addon-main.cjs", "dist/", "server/", "README.md", @@ -48,6 +50,10 @@ "bun": "./server/*.js", "deno": "./server/*.js" }, + "./ember": { + "types": "./dist/ember.d.ts", + "default": "./dist/ember.js" + }, "./*": { "types": "./dist/*.d.ts", "default": "./dist/*.js" @@ -62,7 +68,22 @@ "prepack": "pnpm build", "prepare": "pnpm build" }, - "peerDependencies": {}, + "peerDependencies": { + "@ember/test-helpers": ">= 3.2.0", + "ember-cli-test-loader": ">= 3.1.0", + "@embroider/addon-shim": ">= 1.8.6" + }, + "peerDependenciesMeta": { + "@ember/test-helpers": { + "optional": true + }, + "ember-cli-test-loader": { + "optional": true + }, + "@embroider/addon-shim": { + "optional": true + } + }, "dependencies": { "chalk": "^5.3.0", "debug": "^4.3.4", @@ -78,6 +99,7 @@ "@embroider/addon-dev": "^4.1.1", "@rollup/plugin-babel": "^6.0.4", "@rollup/plugin-node-resolve": "^15.2.3", + "ember-cli-test-loader": "^3.1.0", "rollup": "^4.1.1", "tslib": "^2.6.2", "typescript": "^5.2.2", @@ -90,5 +112,13 @@ "volta": { "extends": "../../package.json" }, - "packageManager": "pnpm@8.9.0" + "packageManager": "pnpm@8.9.0", + "ember-addon": { + "main": "addon-main.cjs", + "type": "addon", + "version": 2 + }, + "ember": { + "edition": "octane" + } } \ No newline at end of file diff --git a/packages/diagnostic/rollup.config.mjs b/packages/diagnostic/rollup.config.mjs index adca52320ce..c74dc4f6bcd 100644 --- a/packages/diagnostic/rollup.config.mjs +++ b/packages/diagnostic/rollup.config.mjs @@ -12,12 +12,12 @@ export default { // You can augment this if you need to. output: addon.output(), - external: [], + external: ["@ember/test-helpers", "ember-cli-test-loader/test-support/index"], plugins: [ // These are the modules that users should be able to import from your // addon. Anything not listed here may get optimized away. - addon.publicEntrypoints(['index.js', 'reporters/dom.js', 'reporters/tap.js', 'runners/dom.js']), + addon.publicEntrypoints(['index.js', 'reporters/dom.js', 'reporters/tap.js', 'runners/dom.js', 'ember.js']), nodeResolve({ extensions: ['.ts'] }), babel({ diff --git a/packages/diagnostic/src/-types.ts b/packages/diagnostic/src/-types.ts index 710055e0c9c..5404884eedb 100644 --- a/packages/diagnostic/src/-types.ts +++ b/packages/diagnostic/src/-types.ts @@ -27,20 +27,22 @@ export type ParamConfig = { value: boolean; } -export type GlobalConfig = { +export type GlobalHooksStorage = { + onSuiteStart: GlobalCallback[]; + onSuiteFinish: GlobalCallback[]; + beforeModule: GlobalCallback[]; + afterModule: GlobalCallback[]; + beforeEach: HooksCallback[]; + afterEach: HooksCallback[]; +} + +export type GlobalConfig = { params: { [key in 'concurrency' | 'tryCatch' | 'instrument' | 'hideReport' | 'memory' | 'groupLogs' | 'debug' | 'container']: ParamConfig }; _current: SuiteReport | null; useTestem: boolean; useDiagnostic: boolean; concurrency: number; - globalHooks: { - beforeEach: HooksCallback[]; - afterEach: HooksCallback[]; - beforeModule: GlobalCallback[]; - afterModule: GlobalCallback[]; - onSuiteStart: GlobalCallback[]; - onSuiteFinish: GlobalCallback[]; - } + globalHooks: GlobalHooksStorage; totals: { tests: number; primaryModules: number; @@ -73,28 +75,28 @@ export interface TestContext {} export type GlobalCallback = () => void | Promise; -export interface Hooks { - beforeEach: (cb: HooksCallback) => void; - afterEach: (cb: HooksCallback) => void; +export interface Hooks { + beforeEach: (cb: HooksCallback) => void; + afterEach: (cb: HooksCallback) => void; beforeModule: (cb: GlobalCallback) => void; afterModule: (cb: GlobalCallback) => void; } -export interface GlobalHooks extends Hooks { +export interface GlobalHooks extends Hooks { onSuiteStart: (cb: GlobalCallback) => void; onSuiteFinish: (cb: GlobalCallback) => void; } -export type HooksCallback = (this: TestContext, assert: Diagnostic) => void | Promise; -export type ModuleCallback = ((hooks: Hooks) => void | Promise) | (() => void | Promise); -export type TestCallback = (this: TestContext, assert: Diagnostic) => void | Promise; +export type HooksCallback = (this: TC, assert: Diagnostic) => void | Promise; +export type ModuleCallback = ((hooks: Hooks) => void | Promise) | (() => void | Promise); +export type TestCallback = (this: TC, assert: Diagnostic) => void | Promise; -export interface TestInfo { +export interface TestInfo { id: string; name: string; - cb: TestCallback; + cb: TestCallback; skip: boolean; todo: boolean; - module: ModuleInfo; + module: ModuleInfo; } export interface OrderedMap { @@ -102,16 +104,16 @@ export interface OrderedMap { byOrder: T[]; } -export interface ModuleInfo { +export interface ModuleInfo { moduleName: string; name: string; - cb: ModuleCallback; + cb: ModuleCallback; config: { - beforeEach: HooksCallback[]; - afterEach: HooksCallback[]; + beforeEach: HooksCallback[]; + afterEach: HooksCallback[]; beforeModule: GlobalCallback[]; afterModule: GlobalCallback[]; }, - tests: OrderedMap; - modules: OrderedMap; + tests: OrderedMap>; + modules: OrderedMap>; } diff --git a/packages/diagnostic/src/-utils.ts b/packages/diagnostic/src/-utils.ts index c887c9083b8..e76e7949351 100644 --- a/packages/diagnostic/src/-utils.ts +++ b/packages/diagnostic/src/-utils.ts @@ -1,6 +1,5 @@ /* global window, globalThis, global, self */ -import type { Config } from "./internals/config"; -import { HooksCallback, ModuleInfo } from "./-types"; +import { HooksCallback,TestContext, ModuleInfo, GlobalHooksStorage } from "./-types"; export function assert(message: string, test: unknown): asserts test { if (!test) { @@ -15,8 +14,8 @@ export function getGlobal(): Window { return g as unknown as Window; } -export function getChain(globalHooks: typeof Config.globalHooks, module: ModuleInfo, parents: ModuleInfo[] | null, prop: 'beforeEach' | 'afterEach'): HooksCallback[] { - const chain: HooksCallback[] = []; +export function getChain(globalHooks: GlobalHooksStorage, module: ModuleInfo, parents: ModuleInfo[] | null, prop: 'beforeEach' | 'afterEach'): HooksCallback[] { + const chain: HooksCallback[] = []; if (globalHooks[prop].length) { chain.push(...globalHooks[prop]); diff --git a/packages/diagnostic/src/ember.ts b/packages/diagnostic/src/ember.ts new file mode 100644 index 00000000000..1975addee42 --- /dev/null +++ b/packages/diagnostic/src/ember.ts @@ -0,0 +1,68 @@ +import { getTestMetadata, setupContext, SetupContextOptions, teardownContext, TestContext } from '@ember/test-helpers'; +import AbstractTestLoader from 'ember-cli-test-loader/test-support/index'; + +import type { Hooks } from './-types'; + +import { setupGlobalHooks } from './internals/config'; + +// fix bug with embroider/webpack/auto-import and test-loader +// @ts-expect-error +const CLITestLoader: typeof AbstractTestLoader = AbstractTestLoader.default ? AbstractTestLoader.default : AbstractTestLoader; + +export function setupTest(hooks: Hooks, opts?: SetupContextOptions) { + const options = { waitForSettled: false, ...opts }; + + hooks.beforeEach(async function () { + let testMetadata = getTestMetadata(this); + testMetadata.framework = 'qunit'; + + await setupContext(this, options); + }); + + hooks.afterEach(function (this: TestContext) { + return teardownContext(this, options); + }); +} + +let moduleLoadFailures: Error[] = []; + +class TestLoader extends CLITestLoader { + moduleLoadFailure(moduleName: string, error: Error) { + moduleLoadFailures.push(error); + } +} + +/** + Load tests following the default patterns: + + * The module name ends with `-test` + * The module name ends with `.jshint` + + @method loadTests + */ +function loadTests() { + TestLoader.load(); +} + +export function configure() { + setupGlobalHooks((hooks) => { + hooks.onSuiteFinish(() => { + let length = moduleLoadFailures.length; + + try { + if (length === 0) { + // do nothing + } else if (length === 1) { + throw moduleLoadFailures[0]; + } else { + throw new Error('\n' + moduleLoadFailures.join('\n')); + } + } finally { + // ensure we release previously captured errors. + moduleLoadFailures = []; + } + }); + }); + + loadTests(); +} diff --git a/packages/diagnostic/src/index.ts b/packages/diagnostic/src/index.ts index 43273fcd428..f27022f2d58 100644 --- a/packages/diagnostic/src/index.ts +++ b/packages/diagnostic/src/index.ts @@ -1,5 +1,5 @@ import { assert, generateHash } from "./-utils"; -import { ModuleInfo, TestInfo, ModuleCallback, TestCallback, OrderedMap } from "./-types"; +import { ModuleInfo, TestInfo, ModuleCallback, TestCallback, OrderedMap, TestContext } from "./-types"; import { SuiteReport } from "./-types/report"; import { Config, HooksDelegate, getCurrentModule, instrument, setCurrentModule } from "./internals/config"; @@ -9,15 +9,15 @@ import { runModule } from "./internals/run"; export { registerReporter } from "./internals/delegating-reporter"; export { setupGlobalHooks, configure } from "./internals/config"; -const Modules: OrderedMap = { +const Modules: OrderedMap> = { byName: new Map(), byOrder: [] } export type { Diagnostic, Hooks as NestedHooks, GlobalHooks, TestContext } from './-types'; -export function module(name: string, cb: ModuleCallback): void { - const parentModule = getCurrentModule() ?? null; +export function module(name: string, cb: ModuleCallback): void { + const parentModule = getCurrentModule() ?? null; let moduleName = name; if (parentModule) { moduleName = `${parentModule.name} > ${name}`; @@ -27,14 +27,14 @@ export function module(name: string, cb: ModuleCallback): void { Config.totals.modules++; assert(`Cannot add the same module name twice: ${moduleName}`, !Modules.byName.has(moduleName)); - const moduleConfig = { + const moduleConfig: ModuleInfo['config'] = { beforeEach: [], afterEach: [], beforeModule: [], afterModule: [] }; - const tests: OrderedMap = { byName: new Map(), byOrder: [] }; - const modules: OrderedMap = { byName: new Map(), byOrder: [] }; + const tests: OrderedMap> = { byName: new Map(), byOrder: [] }; + const modules: OrderedMap> = { byName: new Map(), byOrder: [] }; const moduleInfo = { moduleName, name, @@ -51,16 +51,18 @@ export function module(name: string, cb: ModuleCallback): void { parentModule.modules.byName.set(name, moduleInfo); parentModule.modules.byOrder.push(moduleInfo); } else { + // @ts-expect-error TS poorly handles subtype constraints Modules.byName.set(name, moduleInfo); + // @ts-expect-error TS poorly handles subtype constraints Modules.byOrder.push(moduleInfo); } cb(HooksDelegate); - setCurrentModule(parentModule as unknown as ModuleInfo); + setCurrentModule(parentModule as unknown as ModuleInfo); } -export function test(name: string, cb: TestCallback): void { - const currentModule = getCurrentModule(); +export function test(name: string, cb: TestCallback): void { + const currentModule = getCurrentModule(); assert(`Cannot add a test outside of a module`, !!currentModule); assert(`Cannot add the same test name twice: ${name}`, !currentModule.tests.byName.has(name)); Config.totals.tests++; @@ -78,8 +80,8 @@ export function test(name: string, cb: TestCallback): void { currentModule.tests.byOrder.push(testInfo); } -export function todo(name: string, cb: TestCallback): void { - const currentModule = getCurrentModule(); +export function todo(name: string, cb: TestCallback): void { + const currentModule = getCurrentModule(); assert(`Cannot add a test outside of a module`, !!currentModule); assert(`Cannot add the same test name twice: ${name}`, !currentModule.tests.byName.has(name)); Config.totals.todo++; @@ -97,8 +99,8 @@ export function todo(name: string, cb: TestCallback): void { currentModule.tests.byOrder.push(testInfo); } -export function skip(name: string, cb: TestCallback): void { - const currentModule = getCurrentModule(); +export function skip(name: string, cb: TestCallback): void { + const currentModule = getCurrentModule(); assert(`Cannot add a test outside of a module`, !!currentModule); assert(`Cannot add the same test name twice: ${name}`, !currentModule.tests.byName.has(name)); Config.totals.skipped++; diff --git a/packages/diagnostic/src/internals/config.ts b/packages/diagnostic/src/internals/config.ts index 750c71b0845..1465edfd852 100644 --- a/packages/diagnostic/src/internals/config.ts +++ b/packages/diagnostic/src/internals/config.ts @@ -1,6 +1,6 @@ /* global emit, Testem */ import { assert } from "../-utils"; -import { GlobalHooks, GlobalCallback, HooksCallback, GlobalConfig, ModuleInfo, ParamConfig } from "../-types"; +import { GlobalHooks, GlobalCallback, TestContext, HooksCallback, GlobalConfig, ModuleInfo, ParamConfig } from "../-types"; export const Config: GlobalConfig = { globalHooks: { @@ -68,20 +68,24 @@ export const Config: GlobalConfig = { _current: null, } -let currentModule: ModuleInfo; +let currentModule: ModuleInfo; let isResolvingGlobalHooks = false; export const HooksDelegate = { - beforeEach(cb: HooksCallback): void { + beforeEach(cb: HooksCallback): void { if (isResolvingGlobalHooks) { + // @ts-expect-error TS poorly handles subtype constraints Config.globalHooks.beforeEach.push(cb); } else { + // @ts-expect-error TS poorly handles subtype constraints currentModule.config.beforeEach.push(cb); } }, - afterEach(cb: HooksCallback): void { + afterEach(cb: HooksCallback): void { if (isResolvingGlobalHooks) { + // @ts-expect-error TS poorly handles subtype constraints Config.globalHooks.afterEach.push(cb); } else { + // @ts-expect-error TS poorly handles subtype constraints currentModule.config.afterEach.push(cb); } }, @@ -109,15 +113,16 @@ export const HooksDelegate = { }, } -export function getCurrentModule() { +export function getCurrentModule(): ModuleInfo { return currentModule; } -export function setCurrentModule(module: ModuleInfo) { +export function setCurrentModule(module: ModuleInfo) { + // @ts-expect-error TS poorly handles subtype constraints currentModule = module; } -export function setupGlobalHooks(cb: (hooks: GlobalHooks) => void): void { +export function setupGlobalHooks(cb: (hooks: GlobalHooks) => void): void { isResolvingGlobalHooks = true; cb(HooksDelegate); isResolvingGlobalHooks = false; diff --git a/packages/diagnostic/src/internals/diagnostic.ts b/packages/diagnostic/src/internals/diagnostic.ts index 8e44d5c2d1f..eb83a37fca1 100644 --- a/packages/diagnostic/src/internals/diagnostic.ts +++ b/packages/diagnostic/src/internals/diagnostic.ts @@ -1,11 +1,11 @@ -import { GlobalConfig, TestInfo } from "../-types"; +import { GlobalConfig, TestContext, TestInfo } from "../-types"; import { DiagnosticReport, Reporter, TestReport } from "../-types/report"; import equiv from "../legacy/equiv"; -class InternalCompat { - declare _diagnostic: Diagnostic; +class InternalCompat { + declare _diagnostic: Diagnostic; - constructor(diagnostic: Diagnostic) { + constructor(diagnostic: Diagnostic) { this._diagnostic = diagnostic; } @@ -22,8 +22,8 @@ class InternalCompat { } -export class Diagnostic { - declare __currentTest: TestInfo; +export class Diagnostic { + declare __currentTest: TestInfo; declare __report: TestReport; declare __config: GlobalConfig; declare __reporter: Reporter; @@ -31,9 +31,9 @@ export class Diagnostic { declare _steps: string[]; // QUnit private API compat - declare test: InternalCompat; + declare test: InternalCompat; - constructor(reporter: Reporter, config: GlobalConfig, test: TestInfo, report: TestReport) { + constructor(reporter: Reporter, config: GlobalConfig, test: TestInfo, report: TestReport) { this.__currentTest = test; this.__report = report; this.__config = config; diff --git a/packages/diagnostic/src/internals/run.ts b/packages/diagnostic/src/internals/run.ts index 43a11229f67..438dfbe20cf 100644 --- a/packages/diagnostic/src/internals/run.ts +++ b/packages/diagnostic/src/internals/run.ts @@ -1,12 +1,12 @@ import { getChain } from "../-utils"; -import { ModuleInfo, HooksCallback, TestInfo, } from "../-types"; +import { ModuleInfo, HooksCallback, TestInfo, TestContext, } from "../-types"; import { TestReport, ModuleReport } from "../-types/report"; import { Diagnostic } from "./diagnostic"; import { Config, groupLogs, instrument } from "./config"; import { DelegatingReporter } from "./delegating-reporter"; -export async function runTest(moduleReport: ModuleReport, beforeChain: HooksCallback[], test: TestInfo, afterChain: HooksCallback[]) { - const testContext = {}; +export async function runTest(moduleReport: ModuleReport, beforeChain: HooksCallback[], test: TestInfo, afterChain: HooksCallback[]) { + const testContext = {} as TC; const testReport: TestReport = { id: test.id, name: test.name, @@ -68,7 +68,7 @@ export async function runTest(moduleReport: ModuleReport, beforeChain: HooksCall DelegatingReporter.onTestFinish(testReport); } -export async function runModule(module: ModuleInfo, parents: ModuleInfo[] | null, promises: Promise[]) { +export async function runModule(module: ModuleInfo, parents: ModuleInfo[] | null, promises: Promise[]) { groupLogs() && console.groupCollapsed(module.name); const moduleReport: ModuleReport = { name: module.moduleName, @@ -90,8 +90,8 @@ export async function runModule(module: ModuleInfo, parents: ModuleInfo[] | null } // run tests - const beforeChain = getChain(Config.globalHooks, module, parents, 'beforeEach'); - const afterChain = getChain(Config.globalHooks, module, parents, 'afterEach'); + const beforeChain = getChain(Config.globalHooks, module, parents, 'beforeEach'); + const afterChain = getChain(Config.globalHooks, module, parents, 'afterEach'); if (Config.params.concurrency.value && Config.concurrency > 1) { const tests = module.tests.byOrder; diff --git a/packages/unpublished-test-infra/addon-test-support/asserts/index.ts b/packages/unpublished-test-infra/addon-test-support/asserts/index.ts index f0f27972b02..11e9451dc00 100644 --- a/packages/unpublished-test-infra/addon-test-support/asserts/index.ts +++ b/packages/unpublished-test-infra/addon-test-support/asserts/index.ts @@ -60,8 +60,8 @@ declare module '@warp-drive/diagnostic' { onSuiteFinish: (cb: () => void | Promise) => void; beforeModule: (cb: () => void | Promise) => void; afterModule: (cb: () => void | Promise) => void; - beforeEach: (cb: (this: TC, assert: Assert) => void | Promise) => void; - afterEach: (cb: (this: TC, assert: Assert) => void | Promise) => void; + beforeEach: (cb: (this: TC, assert: EmberDiagnostic) => void | Promise) => void; + afterEach: (cb: (this: TC, assert: EmberDiagnostic) => void | Promise) => void; } export function module( diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4ead9c990a0..af5b2e43fc9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -495,6 +495,9 @@ importers: bun-types: specifier: ^1.0.6 version: 1.0.6 + ember-cli-test-loader: + specifier: ^3.1.0 + version: 3.1.0(@babel/core@7.23.2) rollup: specifier: ^4.1.1 version: 4.1.4 @@ -1727,6 +1730,9 @@ importers: '@ember/test-helpers': specifier: ^3.2.0 version: 3.2.0(@babel/core@7.23.2)(ember-source@5.3.0)(webpack@5.89.0) + '@embroider/addon-shim': + specifier: ^1.8.6 + version: 1.8.6 '@glimmer/component': specifier: ^1.1.2 version: 1.1.2(@babel/core@7.23.2) @@ -1738,7 +1744,7 @@ importers: version: 4.0.6 '@warp-drive/diagnostic': specifier: workspace:5.5.0-alpha.11 - version: file:packages/diagnostic + version: file:packages/diagnostic(@ember/test-helpers@3.2.0)(@embroider/addon-shim@1.8.6)(ember-cli-test-loader@3.1.0) ember-auto-import: specifier: ^2.6.3 version: 2.6.3(webpack@5.89.0) @@ -1870,6 +1876,9 @@ importers: '@ember/test-helpers': specifier: ^3.2.0 version: 3.2.0(@babel/core@7.23.2)(ember-source@5.3.0)(webpack@5.89.0) + '@embroider/addon-shim': + specifier: ^1.8.6 + version: 1.8.6 '@glimmer/component': specifier: ^1.1.2 version: 1.1.2(@babel/core@7.23.2) @@ -1881,7 +1890,7 @@ importers: version: 4.0.6 '@warp-drive/diagnostic': specifier: workspace:5.5.0-alpha.11 - version: file:packages/diagnostic + version: file:packages/diagnostic(@ember/test-helpers@3.2.0)(@embroider/addon-shim@1.8.6)(ember-cli-test-loader@3.1.0) ember-auto-import: specifier: ^2.6.3 version: 2.6.3(webpack@5.89.0) @@ -2000,6 +2009,9 @@ importers: '@ember/test-helpers': specifier: ^3.2.0 version: 3.2.0(@babel/core@7.23.2)(ember-source@5.3.0)(webpack@5.89.0) + '@embroider/addon-shim': + specifier: ^1.8.6 + version: 1.8.6 '@embroider/macros': specifier: ^1.12.2 version: 1.13.1(@babel/core@7.23.2) @@ -2014,7 +2026,7 @@ importers: version: 4.0.6 '@warp-drive/diagnostic': specifier: workspace:5.5.0-alpha.11 - version: file:packages/diagnostic + version: file:packages/diagnostic(@ember/test-helpers@3.2.0)(@embroider/addon-shim@1.8.6)(ember-cli-test-loader@3.1.0) ember-auto-import: specifier: ^2.6.3 version: 2.6.3(webpack@5.89.0) @@ -2137,6 +2149,9 @@ importers: '@ember/test-helpers': specifier: ^3.2.0 version: 3.2.0(@babel/core@7.23.2)(ember-source@5.3.0)(webpack@5.89.0) + '@embroider/addon-shim': + specifier: ^1.8.6 + version: 1.8.6 '@embroider/macros': specifier: ^1.12.2 version: 1.13.1(@babel/core@7.23.2) @@ -2151,7 +2166,7 @@ importers: version: 4.0.6 '@warp-drive/diagnostic': specifier: workspace:5.5.0-alpha.11 - version: file:packages/diagnostic + version: file:packages/diagnostic(@ember/test-helpers@3.2.0)(@embroider/addon-shim@1.8.6)(ember-cli-test-loader@3.1.0) ember-auto-import: specifier: ^2.6.3 version: 2.6.3(webpack@5.89.0) @@ -2259,6 +2274,9 @@ importers: '@ember/test-helpers': specifier: ^3.2.0 version: 3.2.0(@babel/core@7.23.2)(ember-source@5.3.0)(webpack@5.89.0) + '@embroider/addon-shim': + specifier: ^1.8.6 + version: 1.8.6 '@glimmer/component': specifier: ^1.1.2 version: 1.1.2(@babel/core@7.23.2) @@ -2270,7 +2288,7 @@ importers: version: 4.0.6 '@warp-drive/diagnostic': specifier: workspace:5.5.0-alpha.11 - version: file:packages/diagnostic + version: file:packages/diagnostic(@ember/test-helpers@3.2.0)(@embroider/addon-shim@1.8.6)(ember-cli-test-loader@3.1.0) ember-auto-import: specifier: ^2.6.3 version: 2.6.3(webpack@5.89.0) @@ -2341,9 +2359,6 @@ importers: '@ember-data/request': specifier: workspace:5.5.0-alpha.11 version: file:packages/request(@babel/core@7.23.2) - '@ember-data/unpublished-test-infra': - specifier: workspace:5.5.0-alpha.11 - version: file:packages/unpublished-test-infra(@babel/core@7.23.2)(qunit@2.19.4) '@ember/edition-utils': specifier: ^1.2.0 version: 1.2.0 @@ -2356,6 +2371,9 @@ importers: '@ember/test-helpers': specifier: ^3.2.0 version: 3.2.0(@babel/core@7.23.2)(ember-source@5.3.0)(webpack@5.89.0) + '@embroider/addon-shim': + specifier: ^1.8.6 + version: 1.8.6 '@glimmer/component': specifier: ^1.1.2 version: 1.1.2(@babel/core@7.23.2) @@ -2367,7 +2385,7 @@ importers: version: 4.0.6 '@warp-drive/diagnostic': specifier: workspace:5.5.0-alpha.11 - version: file:packages/diagnostic + version: file:packages/diagnostic(@ember/test-helpers@3.2.0)(@embroider/addon-shim@1.8.6)(ember-cli-test-loader@3.1.0) '@warp-drive/holodeck': specifier: workspace:5.5.0-alpha.11 version: file:packages/holodeck @@ -2442,8 +2460,6 @@ importers: injected: true '@ember-data/request': injected: true - '@ember-data/unpublished-test-infra': - injected: true '@warp-drive/diagnostic': injected: true '@warp-drive/holodeck': @@ -5122,12 +5138,11 @@ packages: resolution: {integrity: sha512-siC9kP78uucEbpDcVyxjkwa76pcs5rVzDVpWO4PDc9EAXRX+pzmUuSTLAK3GztUwx7/PWhz1BenAivqdSvSgfg==} engines: {node: 12.* || 14.* || >= 16} dependencies: - '@embroider/shared-internals': 2.4.0 + '@embroider/shared-internals': 2.5.0(supports-color@8.1.1) broccoli-funnel: 3.0.8 semver: 7.5.4 transitivePeerDependencies: - supports-color - dev: true /@embroider/babel-loader-9@3.1.0(@embroider/core@3.3.0)(supports-color@8.1.1)(webpack@5.89.0): resolution: {integrity: sha512-TEOaOAsci15Zc3qh8kFAt/XpAsKjw/DzS/1+dv7yNGOeEgqImux+RoZ7DkZkVZNeuA0eAonpY79B+B0J17Us5g==} @@ -5302,7 +5317,6 @@ packages: typescript-memoize: 1.1.1 transitivePeerDependencies: - supports-color - dev: true /@embroider/webpack@3.2.0(@embroider/core@3.3.0)(webpack@5.89.0): resolution: {integrity: sha512-+H2NjbExiZBY1m3bj2WRmd+1WxndcMiITwa7CuUnq84iOSzQ7T7DWuSB3FLkFfkKeO/4x40pHV0QilzD9ldlZQ==} @@ -17592,13 +17606,28 @@ packages: - uglify-js - webpack-cli - file:packages/diagnostic: + file:packages/diagnostic(@ember/test-helpers@3.2.0)(@embroider/addon-shim@1.8.6)(ember-cli-test-loader@3.1.0): resolution: {directory: packages/diagnostic, type: directory} + id: file:packages/diagnostic name: '@warp-drive/diagnostic' engines: {node: '>= 18.18.0'} + peerDependencies: + '@ember/test-helpers': '>= 3.2.0' + '@embroider/addon-shim': '>= 1.8.6' + ember-cli-test-loader: '>= 3.1.0' + peerDependenciesMeta: + '@ember/test-helpers': + optional: true + '@embroider/addon-shim': + optional: true + ember-cli-test-loader: + optional: true dependencies: + '@ember/test-helpers': 3.2.0(@babel/core@7.23.2)(ember-source@5.3.0)(webpack@5.89.0) + '@embroider/addon-shim': 1.8.6 chalk: 5.3.0 debug: 4.3.4(supports-color@8.1.1) + ember-cli-test-loader: 3.1.0(@babel/core@7.23.2) tmp: 0.2.1 transitivePeerDependencies: - supports-color diff --git a/tests/builders/package.json b/tests/builders/package.json index 656bfe87387..64eb93ff8a1 100644 --- a/tests/builders/package.json +++ b/tests/builders/package.json @@ -71,6 +71,7 @@ "@ember/edition-utils": "^1.2.0", "@ember/optional-features": "^2.0.0", "@ember/string": "3.1.1", + "@embroider/addon-shim": "^1.8.6", "@ember/test-helpers": "^3.2.0", "@glimmer/component": "^1.1.2", "@glimmer/tracking": "^1.1.2", diff --git a/tests/builders/tests/integration/create-record-test.ts b/tests/builders/tests/integration/create-record-test.ts index 0c55465f7fe..28207d50632 100644 --- a/tests/builders/tests/integration/create-record-test.ts +++ b/tests/builders/tests/integration/create-record-test.ts @@ -1,4 +1,5 @@ import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import JSONAPICache from '@ember-data/json-api'; import { createRecord } from '@ember-data/json-api/request'; @@ -15,7 +16,6 @@ import type { CacheCapabilitiesManager } from '@ember-data/types/q/cache-store-w import { SingleResourceDocument } from '@ember-data/types/q/ember-data-json-api'; import type { StableExistingRecordIdentifier, StableRecordIdentifier } from '@ember-data/types/q/identifier'; import { JsonApiError } from '@ember-data/types/q/record-data-json-api'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; class TestStore extends DataStore { constructor(args: unknown) { diff --git a/tests/builders/tests/integration/delete-record-test.ts b/tests/builders/tests/integration/delete-record-test.ts index f40b4e68299..56b5ecd8880 100644 --- a/tests/builders/tests/integration/delete-record-test.ts +++ b/tests/builders/tests/integration/delete-record-test.ts @@ -1,4 +1,5 @@ import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import JSONAPICache from '@ember-data/json-api'; import { deleteRecord } from '@ember-data/json-api/request'; @@ -15,7 +16,6 @@ import type { CacheCapabilitiesManager } from '@ember-data/types/q/cache-store-w import { SingleResourceDocument } from '@ember-data/types/q/ember-data-json-api'; import type { StableExistingRecordIdentifier, StableRecordIdentifier } from '@ember-data/types/q/identifier'; import { JsonApiError } from '@ember-data/types/q/record-data-json-api'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; class TestStore extends DataStore { constructor(args: unknown) { diff --git a/tests/builders/tests/integration/update-record-test.ts b/tests/builders/tests/integration/update-record-test.ts index df4a33d3c8a..5ebbbccf8c1 100644 --- a/tests/builders/tests/integration/update-record-test.ts +++ b/tests/builders/tests/integration/update-record-test.ts @@ -1,4 +1,5 @@ import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import JSONAPICache from '@ember-data/json-api'; import { updateRecord } from '@ember-data/json-api/request'; @@ -15,7 +16,6 @@ import type { CacheCapabilitiesManager } from '@ember-data/types/q/cache-store-w import { SingleResourceDocument } from '@ember-data/types/q/ember-data-json-api'; import type { StableExistingRecordIdentifier, StableRecordIdentifier } from '@ember-data/types/q/identifier'; import { JsonApiError } from '@ember-data/types/q/record-data-json-api'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; class TestStore extends DataStore { constructor(args: unknown) { diff --git a/tests/builders/tests/test-helper.js b/tests/builders/tests/test-helper.js index 7675642ebaf..9f4f19ec6fd 100644 --- a/tests/builders/tests/test-helper.js +++ b/tests/builders/tests/test-helper.js @@ -1,53 +1,12 @@ import { setApplication } from '@ember/test-helpers'; -import { setupGlobalHooks } from '@warp-drive/diagnostic'; +import { configure } from '@warp-drive/diagnostic/ember'; import { start } from '@warp-drive/diagnostic/runners/dom'; -import AbstractTestLoader from 'ember-cli-test-loader/test-support/index'; - import Application from '../app'; import config from '../config/environment'; -let moduleLoadFailures = []; - -setupGlobalHooks((hooks) => { - hooks.onSuiteFinish(() => { - let length = moduleLoadFailures.length; - - try { - if (length === 0) { - // do nothing - } else if (length === 1) { - throw moduleLoadFailures[0]; - } else { - throw new Error('\n' + moduleLoadFailures.join('\n')); - } - } finally { - // ensure we release previously captured errors. - moduleLoadFailures = []; - } - }); -}); - -export class TestLoader extends AbstractTestLoader { - moduleLoadFailure(moduleName, error) { - moduleLoadFailures.push(error); - } -} - -/** - Load tests following the default patterns: - - * The module name ends with `-test` - * The module name ends with `.jshint` - - @method loadTests - */ -export function loadTests() { - new TestLoader().loadModules(); -} - -loadTests(); +configure(); setApplication(Application.create(config.APP)); start({ diff --git a/tests/builders/tests/unit/active-record-builder-test.ts b/tests/builders/tests/unit/active-record-builder-test.ts index bf7dd499d1b..d317a3f440f 100644 --- a/tests/builders/tests/unit/active-record-builder-test.ts +++ b/tests/builders/tests/unit/active-record-builder-test.ts @@ -1,9 +1,9 @@ import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import { createRecord, deleteRecord, findRecord, query, updateRecord } from '@ember-data/active-record/request'; import { setBuildURLConfig } from '@ember-data/request-utils'; import Store, { recordIdentifierFor } from '@ember-data/store'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; import UserSetting from '../../app/models/user-setting'; import { headersToObject } from '../helpers/utils'; diff --git a/tests/builders/tests/unit/json-api-builder-test.ts b/tests/builders/tests/unit/json-api-builder-test.ts index 592770370e4..e4936556ad1 100644 --- a/tests/builders/tests/unit/json-api-builder-test.ts +++ b/tests/builders/tests/unit/json-api-builder-test.ts @@ -1,9 +1,9 @@ import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import { createRecord, deleteRecord, findRecord, postQuery, query, updateRecord } from '@ember-data/json-api/request'; import { setBuildURLConfig } from '@ember-data/request-utils'; import Store, { recordIdentifierFor } from '@ember-data/store'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; import UserSetting from '../../app/models/user-setting'; import { headersToObject } from '../helpers/utils'; diff --git a/tests/builders/tests/unit/rest-builder-test.ts b/tests/builders/tests/unit/rest-builder-test.ts index c913e694caa..eb69902df1e 100644 --- a/tests/builders/tests/unit/rest-builder-test.ts +++ b/tests/builders/tests/unit/rest-builder-test.ts @@ -1,9 +1,9 @@ import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import { setBuildURLConfig } from '@ember-data/request-utils'; import { createRecord, deleteRecord, findRecord, query, updateRecord } from '@ember-data/rest/request'; import Store, { recordIdentifierFor } from '@ember-data/store'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; import UserSetting from '../../app/models/user-setting'; import { headersToObject } from '../helpers/utils'; diff --git a/tests/ember-data__adapter/package.json b/tests/ember-data__adapter/package.json index f48168b7acf..201b41d1ff7 100644 --- a/tests/ember-data__adapter/package.json +++ b/tests/ember-data__adapter/package.json @@ -75,6 +75,7 @@ "@ember/optional-features": "^2.0.0", "@ember/string": "3.1.1", "@ember/test-helpers": "^3.2.0", + "@embroider/addon-shim": "^1.8.6", "@glimmer/component": "^1.1.2", "@glimmer/tracking": "^1.1.2", "@types/ember__owner": "^4.0.6", diff --git a/tests/ember-data__adapter/tests/integration/belongs-to-test.js b/tests/ember-data__adapter/tests/integration/belongs-to-test.js index 7c6381443d1..dad445959a4 100644 --- a/tests/ember-data__adapter/tests/integration/belongs-to-test.js +++ b/tests/ember-data__adapter/tests/integration/belongs-to-test.js @@ -1,12 +1,12 @@ import EmberObject from '@ember/object'; import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import Store from 'ember-data__adapter/services/store'; import Model, { attr, belongsTo, hasMany } from '@ember-data/model'; import deepCopy from '@ember-data/unpublished-test-infra/test-support/deep-copy'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; import testInDebug from '@ember-data/unpublished-test-infra/test-support/test-in-debug'; class MinimalSerializer extends EmberObject { diff --git a/tests/ember-data__adapter/tests/integration/coalescing-test.js b/tests/ember-data__adapter/tests/integration/coalescing-test.js index 4e74ec00026..26f91f11f62 100644 --- a/tests/ember-data__adapter/tests/integration/coalescing-test.js +++ b/tests/ember-data__adapter/tests/integration/coalescing-test.js @@ -1,13 +1,13 @@ import EmberObject from '@ember/object'; import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import Store from 'ember-data__adapter/services/store'; import Model, { attr } from '@ember-data/model'; import { recordIdentifierFor } from '@ember-data/store'; import deepCopy from '@ember-data/unpublished-test-infra/test-support/deep-copy'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; class MinimalSerializer extends EmberObject { normalizeResponse(_, __, data) { diff --git a/tests/ember-data__adapter/tests/integration/generate-id-test.js b/tests/ember-data__adapter/tests/integration/generate-id-test.js index b7455f86fba..89f0d5c1ede 100644 --- a/tests/ember-data__adapter/tests/integration/generate-id-test.js +++ b/tests/ember-data__adapter/tests/integration/generate-id-test.js @@ -1,11 +1,11 @@ import EmberObject from '@ember/object'; import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import Store from 'ember-data__adapter/services/store'; import Model, { attr } from '@ember-data/model'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; class MinimalSerializer extends EmberObject { normalizeResponse(_, __, data) { diff --git a/tests/ember-data__adapter/tests/integration/has-many-test.js b/tests/ember-data__adapter/tests/integration/has-many-test.js index 97488728995..11e15567023 100644 --- a/tests/ember-data__adapter/tests/integration/has-many-test.js +++ b/tests/ember-data__adapter/tests/integration/has-many-test.js @@ -1,12 +1,12 @@ import EmberObject from '@ember/object'; import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import Store from 'ember-data__adapter/services/store'; import Model, { attr, belongsTo, hasMany } from '@ember-data/model'; import deepCopy from '@ember-data/unpublished-test-infra/test-support/deep-copy'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; import testInDebug from '@ember-data/unpublished-test-infra/test-support/test-in-debug'; class MinimalSerializer extends EmberObject { diff --git a/tests/ember-data__adapter/tests/integration/mutations-test.js b/tests/ember-data__adapter/tests/integration/mutations-test.js index 4991d59a1f7..24c25515c63 100644 --- a/tests/ember-data__adapter/tests/integration/mutations-test.js +++ b/tests/ember-data__adapter/tests/integration/mutations-test.js @@ -1,11 +1,11 @@ import EmberObject from '@ember/object'; import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import Store from 'ember-data__adapter/services/store'; import Model, { attr } from '@ember-data/model'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; class MinimalSerializer extends EmberObject { normalizeResponse(_, __, data) { diff --git a/tests/ember-data__adapter/tests/integration/queries-test.js b/tests/ember-data__adapter/tests/integration/queries-test.js index 5ae22004e92..3593b6b4306 100644 --- a/tests/ember-data__adapter/tests/integration/queries-test.js +++ b/tests/ember-data__adapter/tests/integration/queries-test.js @@ -1,12 +1,12 @@ import EmberObject from '@ember/object'; import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import Store from 'ember-data__adapter/services/store'; import Model, { attr } from '@ember-data/model'; import deepCopy from '@ember-data/unpublished-test-infra/test-support/deep-copy'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; class MinimalSerializer extends EmberObject { normalizeResponse(_, __, data) { diff --git a/tests/ember-data__adapter/tests/integration/reload-test.js b/tests/ember-data__adapter/tests/integration/reload-test.js index dbf761cdcc0..ff5521364a5 100644 --- a/tests/ember-data__adapter/tests/integration/reload-test.js +++ b/tests/ember-data__adapter/tests/integration/reload-test.js @@ -1,11 +1,11 @@ import EmberObject from '@ember/object'; import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import Store from 'ember-data__adapter/services/store'; import Model, { attr } from '@ember-data/model'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; class MinimalSerializer extends EmberObject { normalizeResponse(_, __, data) { diff --git a/tests/ember-data__adapter/tests/test-helper.js b/tests/ember-data__adapter/tests/test-helper.js index 829ee9070c7..595269a528f 100644 --- a/tests/ember-data__adapter/tests/test-helper.js +++ b/tests/ember-data__adapter/tests/test-helper.js @@ -1,56 +1,19 @@ import { setApplication } from '@ember/test-helpers'; import { setupGlobalHooks } from '@warp-drive/diagnostic'; +import { configure } from '@warp-drive/diagnostic/ember'; import { start } from '@warp-drive/diagnostic/runners/dom'; -import AbstractTestLoader from 'ember-cli-test-loader/test-support/index'; - import configureAsserts from '@ember-data/unpublished-test-infra/test-support/asserts'; import Application from '../app'; import config from '../config/environment'; -let moduleLoadFailures = []; - setupGlobalHooks((hooks) => { configureAsserts(hooks); - hooks.onSuiteFinish(() => { - let length = moduleLoadFailures.length; - - try { - if (length === 0) { - // do nothing - } else if (length === 1) { - throw moduleLoadFailures[0]; - } else { - throw new Error('\n' + moduleLoadFailures.join('\n')); - } - } finally { - // ensure we release previously captured errors. - moduleLoadFailures = []; - } - }); }); -export class TestLoader extends AbstractTestLoader { - moduleLoadFailure(moduleName, error) { - moduleLoadFailures.push(error); - } -} - -/** - Load tests following the default patterns: - - * The module name ends with `-test` - * The module name ends with `.jshint` - - @method loadTests - */ -export function loadTests() { - new TestLoader().loadModules(); -} - -loadTests(); +configure(); setApplication(Application.create(config.APP)); start({ diff --git a/tests/ember-data__graph/package.json b/tests/ember-data__graph/package.json index 3c1533d5905..cdf19b4b047 100644 --- a/tests/ember-data__graph/package.json +++ b/tests/ember-data__graph/package.json @@ -72,6 +72,7 @@ "@ember/string": "3.1.1", "@ember/test-helpers": "^3.2.0", "@embroider/macros": "^1.13.2", + "@embroider/addon-shim": "^1.8.6", "@glimmer/component": "^1.1.2", "@glimmer/tracking": "^1.1.2", "@types/ember__owner": "^4.0.6", diff --git a/tests/ember-data__graph/tests/.gitkeep b/tests/ember-data__graph/tests/.gitkeep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/ember-data__graph/tests/integration/graph/diff-preservation-test.ts b/tests/ember-data__graph/tests/integration/graph/diff-preservation-test.ts index 45453327164..33b6304a189 100644 --- a/tests/ember-data__graph/tests/integration/graph/diff-preservation-test.ts +++ b/tests/ember-data__graph/tests/integration/graph/diff-preservation-test.ts @@ -1,10 +1,10 @@ import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import { DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE } from '@ember-data/deprecations'; import { graphFor } from '@ember-data/graph/-private'; import Model, { attr, belongsTo, hasMany } from '@ember-data/model'; import type Store from '@ember-data/store'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; import { deprecatedTest } from '../../setup-test'; diff --git a/tests/ember-data__graph/tests/integration/graph/duplicate-data-test.ts b/tests/ember-data__graph/tests/integration/graph/duplicate-data-test.ts index 937580b9e51..b5fad2345f8 100644 --- a/tests/ember-data__graph/tests/integration/graph/duplicate-data-test.ts +++ b/tests/ember-data__graph/tests/integration/graph/duplicate-data-test.ts @@ -1,10 +1,10 @@ import { module } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import { DEPRECATE_NON_UNIQUE_PAYLOADS } from '@ember-data/deprecations'; import { graphFor } from '@ember-data/graph/-private'; import Model, { attr, hasMany } from '@ember-data/model'; import type Store from '@ember-data/store'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; import { test } from '@ember-data/unpublished-test-infra/test-support/test-in-debug'; import { deprecatedTest } from '../../setup-test'; diff --git a/tests/ember-data__graph/tests/integration/graph/edge-removal/setup.ts b/tests/ember-data__graph/tests/integration/graph/edge-removal/setup.ts index 9b09d4408a4..90062477568 100644 --- a/tests/ember-data__graph/tests/integration/graph/edge-removal/setup.ts +++ b/tests/ember-data__graph/tests/integration/graph/edge-removal/setup.ts @@ -1,6 +1,7 @@ import { TestContext } from '@ember/test-helpers'; import type { EmberHooks } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import { graphFor } from '@ember-data/graph/-private'; import type { CollectionEdge } from '@ember-data/graph/-private/edges/collection'; @@ -18,7 +19,6 @@ import type { } from '@ember-data/types/q/ember-data-json-api'; import type { StableRecordIdentifier } from '@ember-data/types/q/identifier'; import type { RecordInstance } from '@ember-data/types/q/record-instance'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; class AbstractMap { constructor( diff --git a/tests/ember-data__graph/tests/integration/graph/edge-test.ts b/tests/ember-data__graph/tests/integration/graph/edge-test.ts index 7d28ffbf9c8..853e0a35b91 100644 --- a/tests/ember-data__graph/tests/integration/graph/edge-test.ts +++ b/tests/ember-data__graph/tests/integration/graph/edge-test.ts @@ -1,4 +1,5 @@ import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import { graphFor } from '@ember-data/graph/-private'; import type { Graph } from '@ember-data/graph/-private/graph'; @@ -6,7 +7,6 @@ import Model, { attr, belongsTo, hasMany } from '@ember-data/model'; import type Store from '@ember-data/store'; import { recordIdentifierFor } from '@ember-data/store'; import { peekCache } from '@ember-data/store/-private'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; import { stateOf } from './edge-removal/setup'; diff --git a/tests/ember-data__graph/tests/integration/graph/graph-test.ts b/tests/ember-data__graph/tests/integration/graph/graph-test.ts index 40a674bc380..1a5b3219dba 100644 --- a/tests/ember-data__graph/tests/integration/graph/graph-test.ts +++ b/tests/ember-data__graph/tests/integration/graph/graph-test.ts @@ -1,8 +1,8 @@ import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import { graphFor } from '@ember-data/graph/-private'; import Store from '@ember-data/store'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; module('Integration | Graph | Configuration', function (hooks) { setupTest(hooks); diff --git a/tests/ember-data__graph/tests/integration/graph/order-preservation-test.ts b/tests/ember-data__graph/tests/integration/graph/order-preservation-test.ts index bf9622043e7..ed7653b2019 100644 --- a/tests/ember-data__graph/tests/integration/graph/order-preservation-test.ts +++ b/tests/ember-data__graph/tests/integration/graph/order-preservation-test.ts @@ -1,9 +1,9 @@ import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import { graphFor } from '@ember-data/graph/-private'; import Model, { attr, belongsTo, hasMany } from '@ember-data/model'; import Store from '@ember-data/store'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; class App extends Model { @attr declare name: string; @@ -40,7 +40,7 @@ module('Graph | Order Preservation', function (hooks) { }); module('during local mutation', function (innerHooks) { - innerHooks.beforeEach(function (assert: Assert) { + innerHooks.beforeEach(function (assert) { const { owner } = this; const store = owner.lookup('service:store') as Store; diff --git a/tests/ember-data__graph/tests/integration/graph/polymorphism/implicit-keys-test.ts b/tests/ember-data__graph/tests/integration/graph/polymorphism/implicit-keys-test.ts index d5ed4b88893..86b715b9f51 100644 --- a/tests/ember-data__graph/tests/integration/graph/polymorphism/implicit-keys-test.ts +++ b/tests/ember-data__graph/tests/integration/graph/polymorphism/implicit-keys-test.ts @@ -1,9 +1,9 @@ import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import { graphFor } from '@ember-data/graph/-private'; import Model, { attr, belongsTo } from '@ember-data/model'; import Store, { recordIdentifierFor } from '@ember-data/store'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; module('Integration | Graph | Implicit Keys', function (hooks) { setupTest(hooks); diff --git a/tests/ember-data__graph/tests/integration/graph/unload-test.ts b/tests/ember-data__graph/tests/integration/graph/unload-test.ts index ef1a6b21a0b..acb313ab0a2 100644 --- a/tests/ember-data__graph/tests/integration/graph/unload-test.ts +++ b/tests/ember-data__graph/tests/integration/graph/unload-test.ts @@ -1,4 +1,5 @@ import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import { graphFor } from '@ember-data/graph/-private'; import type { ResourceEdge } from '@ember-data/graph/-private/edges/resource'; @@ -6,7 +7,6 @@ import type { Graph } from '@ember-data/graph/-private/graph'; import Model, { attr, belongsTo } from '@ember-data/model'; import type Store from '@ember-data/store'; import { StableRecordIdentifier } from '@ember-data/types/q/identifier'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; module('Integration | Graph | Unload', function (hooks) { setupTest(hooks); diff --git a/tests/ember-data__graph/tests/test-helper.js b/tests/ember-data__graph/tests/test-helper.js index 829ee9070c7..595269a528f 100644 --- a/tests/ember-data__graph/tests/test-helper.js +++ b/tests/ember-data__graph/tests/test-helper.js @@ -1,56 +1,19 @@ import { setApplication } from '@ember/test-helpers'; import { setupGlobalHooks } from '@warp-drive/diagnostic'; +import { configure } from '@warp-drive/diagnostic/ember'; import { start } from '@warp-drive/diagnostic/runners/dom'; -import AbstractTestLoader from 'ember-cli-test-loader/test-support/index'; - import configureAsserts from '@ember-data/unpublished-test-infra/test-support/asserts'; import Application from '../app'; import config from '../config/environment'; -let moduleLoadFailures = []; - setupGlobalHooks((hooks) => { configureAsserts(hooks); - hooks.onSuiteFinish(() => { - let length = moduleLoadFailures.length; - - try { - if (length === 0) { - // do nothing - } else if (length === 1) { - throw moduleLoadFailures[0]; - } else { - throw new Error('\n' + moduleLoadFailures.join('\n')); - } - } finally { - // ensure we release previously captured errors. - moduleLoadFailures = []; - } - }); }); -export class TestLoader extends AbstractTestLoader { - moduleLoadFailure(moduleName, error) { - moduleLoadFailures.push(error); - } -} - -/** - Load tests following the default patterns: - - * The module name ends with `-test` - * The module name ends with `.jshint` - - @method loadTests - */ -export function loadTests() { - new TestLoader().loadModules(); -} - -loadTests(); +configure(); setApplication(Application.create(config.APP)); start({ diff --git a/tests/ember-data__json-api/package.json b/tests/ember-data__json-api/package.json index d8d72190d5b..c27164ebbe9 100644 --- a/tests/ember-data__json-api/package.json +++ b/tests/ember-data__json-api/package.json @@ -59,6 +59,7 @@ "@ember/optional-features": "^2.0.0", "@ember/string": "3.1.1", "@ember/test-helpers": "^3.2.0", + "@embroider/addon-shim": "^1.8.6", "@embroider/macros": "^1.13.2", "@glimmer/component": "^1.1.2", "@glimmer/tracking": "^1.1.2", diff --git a/tests/ember-data__json-api/tests/test-helper.js b/tests/ember-data__json-api/tests/test-helper.js index ac7264cd21b..bcb6a580430 100644 --- a/tests/ember-data__json-api/tests/test-helper.js +++ b/tests/ember-data__json-api/tests/test-helper.js @@ -1,50 +1,10 @@ -import { setupGlobalHooks } from '@warp-drive/diagnostic'; +import { configure } from '@warp-drive/diagnostic/ember'; import { start } from '@warp-drive/diagnostic/runners/dom'; -import AbstractTestLoader from 'ember-cli-test-loader/test-support/index'; - -let moduleLoadFailures = []; - -setupGlobalHooks((hooks) => { - hooks.onSuiteFinish(() => { - let length = moduleLoadFailures.length; - - try { - if (length === 0) { - // do nothing - } else if (length === 1) { - throw moduleLoadFailures[0]; - } else { - throw new Error('\n' + moduleLoadFailures.join('\n')); - } - } finally { - // ensure we release previously captured errors. - moduleLoadFailures = []; - } - }); -}); - -export class TestLoader extends AbstractTestLoader { - moduleLoadFailure(moduleName, error) { - moduleLoadFailures.push(error); - } -} - -/** - Load tests following the default patterns: - - * The module name ends with `-test` - * The module name ends with `.jshint` - - @method loadTests - */ -export function loadTests() { - new TestLoader().loadModules(); -} - -loadTests(); +configure(); start({ + tryCatch: false, groupLogs: false, instrument: true, hideReport: true, diff --git a/tests/ember-data__model/package.json b/tests/ember-data__model/package.json index 1862a5b21ca..943813663d9 100644 --- a/tests/ember-data__model/package.json +++ b/tests/ember-data__model/package.json @@ -51,6 +51,7 @@ "@ember/optional-features": "^2.0.0", "@ember/string": "3.1.1", "@ember/test-helpers": "^3.2.0", + "@embroider/addon-shim": "^1.8.6", "@glimmer/component": "^1.1.2", "@glimmer/tracking": "^1.1.2", "@types/ember__owner": "^4.0.6", diff --git a/tests/ember-data__model/tests/test-helper.js b/tests/ember-data__model/tests/test-helper.js index 4e482ada2cc..bcb6a580430 100644 --- a/tests/ember-data__model/tests/test-helper.js +++ b/tests/ember-data__model/tests/test-helper.js @@ -1,47 +1,7 @@ -import { setupGlobalHooks } from '@warp-drive/diagnostic'; +import { configure } from '@warp-drive/diagnostic/ember'; import { start } from '@warp-drive/diagnostic/runners/dom'; -import AbstractTestLoader from 'ember-cli-test-loader/test-support/index'; - -let moduleLoadFailures = []; -setupGlobalHooks((hooks) => { - hooks.onSuiteFinish(() => { - let length = moduleLoadFailures.length; - - try { - if (length === 0) { - // do nothing - } else if (length === 1) { - throw moduleLoadFailures[0]; - } else { - throw new Error('\n' + moduleLoadFailures.join('\n')); - } - } finally { - // ensure we release previously captured errors. - moduleLoadFailures = []; - } - }); -}); - -export class TestLoader extends AbstractTestLoader { - moduleLoadFailure(moduleName, error) { - moduleLoadFailures.push(error); - } -} - -/** - Load tests following the default patterns: - - * The module name ends with `-test` - * The module name ends with `.jshint` - - @method loadTests - */ -export function loadTests() { - new TestLoader().loadModules(); -} - -loadTests(); +configure(); start({ tryCatch: false, diff --git a/tests/ember-data__request/package.json b/tests/ember-data__request/package.json index d2f0e796667..221a5c7a005 100644 --- a/tests/ember-data__request/package.json +++ b/tests/ember-data__request/package.json @@ -28,9 +28,6 @@ "@ember-data/private-build-infra": { "injected": true }, - "@ember-data/unpublished-test-infra": { - "injected": true - }, "@warp-drive/holodeck": { "injected": true } @@ -40,12 +37,12 @@ "@babel/runtime": "^7.23.2", "@ember-data/private-build-infra": "workspace:5.5.0-alpha.11", "@ember-data/request": "workspace:5.5.0-alpha.11", - "@ember-data/unpublished-test-infra": "workspace:5.5.0-alpha.11", "@warp-drive/holodeck": "workspace:5.5.0-alpha.11", "@ember/edition-utils": "^1.2.0", "@ember/optional-features": "^2.0.0", "@ember/string": "3.1.1", "@ember/test-helpers": "^3.2.0", + "@embroider/addon-shim": "^1.8.6", "@glimmer/component": "^1.1.2", "@glimmer/tracking": "^1.1.2", "@types/ember__owner": "^4.0.6", diff --git a/tests/ember-data__request/tests/integration/service-test.ts b/tests/ember-data__request/tests/integration/service-test.ts index 5fdc776ec16..ad500d66320 100644 --- a/tests/ember-data__request/tests/integration/service-test.ts +++ b/tests/ember-data__request/tests/integration/service-test.ts @@ -2,11 +2,11 @@ import { getOwner } from '@ember/application'; import Service, { inject as service } from '@ember/service'; import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import Resolver from 'ember-resolver'; import RequestManager from '@ember-data/request'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; module('RequestManager | Ember Service Setup', function (hooks) { setupTest(hooks, { resolver: new Resolver() }); diff --git a/tests/ember-data__request/tests/integration/stateful-handler-test.ts b/tests/ember-data__request/tests/integration/stateful-handler-test.ts index 6db3a43c6bc..ae555329c49 100644 --- a/tests/ember-data__request/tests/integration/stateful-handler-test.ts +++ b/tests/ember-data__request/tests/integration/stateful-handler-test.ts @@ -2,13 +2,13 @@ import { setOwner } from '@ember/owner'; import { service } from '@ember/service'; import { module, test } from '@warp-drive/diagnostic'; +import { setupTest } from '@warp-drive/diagnostic/ember'; import Resolver from 'ember-resolver'; import RequestManager from '@ember-data/request'; import type { Context as HandlerRequestContext } from '@ember-data/request/-private/context'; import type { NextFn } from '@ember-data/request/-private/types'; -import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; module('RequestManager | Stateful Handlers', function (hooks) { setupTest(hooks, { resolver: new Resolver() }); diff --git a/tests/ember-data__request/tests/test-helper.js b/tests/ember-data__request/tests/test-helper.js index 1177647b20b..5766a1a5ff4 100644 --- a/tests/ember-data__request/tests/test-helper.js +++ b/tests/ember-data__request/tests/test-helper.js @@ -1,60 +1,18 @@ import { setupGlobalHooks } from '@warp-drive/diagnostic'; +import { configure } from '@warp-drive/diagnostic/ember'; import { start } from '@warp-drive/diagnostic/runners/dom'; import { setTestId } from '@warp-drive/holodeck'; -import AbstractTestLoader from 'ember-cli-test-loader/test-support/index'; - -import configureAsserts from '@ember-data/unpublished-test-infra/test-support/asserts'; - -let moduleLoadFailures = []; - setupGlobalHooks((hooks) => { - configureAsserts(hooks); - hooks.beforeEach(function (assert) { setTestId(this, assert.test.testId); }); hooks.afterEach(function () { setTestId(this, null); }); - - hooks.onSuiteFinish(() => { - let length = moduleLoadFailures.length; - - try { - if (length === 0) { - // do nothing - } else if (length === 1) { - throw moduleLoadFailures[0]; - } else { - throw new Error('\n' + moduleLoadFailures.join('\n')); - } - } finally { - // ensure we release previously captured errors. - moduleLoadFailures = []; - } - }); }); -export class TestLoader extends AbstractTestLoader { - moduleLoadFailure(moduleName, error) { - moduleLoadFailures.push(error); - } -} - -/** - Load tests following the default patterns: - - * The module name ends with `-test` - * The module name ends with `.jshint` - - @method loadTests - */ -export function loadTests() { - new TestLoader().loadModules(); -} - -loadTests(); +configure(); start({ tryCatch: false,