diff --git a/babel.test.config.mjs b/babel.test.config.mjs index f83bb403a1f..dad707aeaf6 100644 --- a/babel.test.config.mjs +++ b/babel.test.config.mjs @@ -9,12 +9,24 @@ import { createRequire } from 'node:module'; import baseConfig from './babel.config.mjs'; +import { buildMacros } from '@embroider/macros/babel'; // eslint-disable-next-line no-redeclare const require = createRequire(import.meta.url); const buildDebugMacroPlugin = require('./broccoli/build-debug-macro-plugin.cjs'); const isProduction = process.env.EMBER_ENV === 'production'; +// @ember/test-helpers and @ember/test-waiters use @embroider/macros. +// +// buildMacros() reads NODE_ENV, but our builds select the mode with EMBER_ENV. +const macros = buildMacros({ + configure(config) { + if (!isProduction) { + config.enablePackageDevelopment(process.cwd()); + } + }, +}); + export default { ...baseConfig, @@ -27,5 +39,5 @@ export default { ], ], - plugins: [...baseConfig.plugins, ...buildDebugMacroPlugin(!isProduction)], + plugins: [...baseConfig.plugins, ...macros.babelMacros, ...buildDebugMacroPlugin(!isProduction)], }; diff --git a/package.json b/package.json index dfac084f3da..26b3917add8 100644 --- a/package.json +++ b/package.json @@ -106,6 +106,7 @@ "@babel/plugin-transform-typescript": "^7.26.8", "@babel/preset-env": "^7.16.11", "@babel/types": "^7.22.5", + "@ember/test-helpers": "^5.5.0", "@embroider/macros": "^1.20.2", "@embroider/shared-internals": "^3.0.2", "@embroider/vite": "^1.7.2", diff --git a/packages/ember/tests/routing/router_service_test/transitionTo_test.js b/packages/ember/tests/routing/router_service_test/transitionTo_test.js index 1416976c3ee..2378177d65d 100644 --- a/packages/ember/tests/routing/router_service_test/transitionTo_test.js +++ b/packages/ember/tests/routing/router_service_test/transitionTo_test.js @@ -3,11 +3,11 @@ import Component from '@glimmer/component'; import Route from '@ember/routing/route'; import NoneLocation from '@ember/routing/none-location'; import Controller from '@ember/controller'; -import { run } from '@ember/runloop'; import { action, get } from '@ember/object'; import { precompileTemplate } from '@ember/template-compilation'; import { setComponentTemplate } from '@glimmer/manager'; import { RouterTestCase, moduleFor } from 'internal-test-helpers'; +import { settled } from '@ember/test-helpers'; import { InternalTransition as Transition } from 'router_js'; moduleFor( @@ -96,7 +96,7 @@ moduleFor( }); } - ['@test RouterService#transitionTo with basic route'](assert) { + async ['@test RouterService#transitionTo with basic route'](assert) { assert.expect(1); let componentInstance; @@ -122,16 +122,15 @@ moduleFor( ) ); - return this.visit('/').then(() => { - run(function () { - componentInstance.transitionToSister(); - }); + await this.visit('/'); - assert.equal(this.routerService.get('currentRouteName'), 'parent.sister'); - }); + componentInstance.transitionToSister(); + await settled(); + + assert.equal(this.routerService.get('currentRouteName'), 'parent.sister'); } - ['@test RouterService#transitionTo with basic route using URL'](assert) { + async ['@test RouterService#transitionTo with basic route using URL'](assert) { assert.expect(1); let componentInstance; @@ -157,13 +156,12 @@ moduleFor( ) ); - return this.visit('/').then(() => { - run(function () { - componentInstance.transitionToSister(); - }); + await this.visit('/'); - assert.equal(this.routerService.get('currentRouteName'), 'parent.sister'); - }); + componentInstance.transitionToSister(); + await settled(); + + assert.equal(this.routerService.get('currentRouteName'), 'parent.sister'); } async ['@test RouterService#transitionTo with dynamic segment'](assert) { @@ -196,9 +194,8 @@ moduleFor( await this.visit('/'); - run(function () { - componentInstance.transitionToDynamic(); - }); + componentInstance.transitionToDynamic(); + await settled(); assert.equal(this.routerService.get('currentRouteName'), 'dynamic'); assert.equal(this.routerService.get('currentURL'), '/dynamic/1'); @@ -244,9 +241,8 @@ moduleFor( await this.visit('/'); - run(function () { - componentInstance.transitionToDynamic(); - }); + componentInstance.transitionToDynamic(); + await settled(); assert.equal(this.routerService.get('currentRouteName'), 'dynamic'); assert.equal(this.routerService.get('currentURL'), '/dynamic/1'); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 73af5a19048..2f53d3c07d5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -91,6 +91,9 @@ importers: '@babel/types': specifier: ^7.22.5 version: 7.29.7 + '@ember/test-helpers': + specifier: ^5.5.0 + version: 5.5.0(@babel/core@7.29.7) '@embroider/macros': specifier: ^1.20.2 version: 1.20.3(@babel/core@7.29.7) diff --git a/rollup.config.mjs b/rollup.config.mjs index 4491f00f19c..95266380d4d 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -16,6 +16,9 @@ const buildDebugMacroPlugin = require('./broccoli/build-debug-macro-plugin.cjs') const canaryFeatures = require('./broccoli/canary-features.cjs'); const testDependencies = [ + '@ember/test-helpers', + '@ember/test-waiters', + 'dom-element-descriptors', 'qunit', 'vite', 'js-reporters',