Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion babel.test.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -27,5 +39,5 @@ export default {
],
],

plugins: [...baseConfig.plugins, ...buildDebugMacroPlugin(!isProduction)],
plugins: [...baseConfig.plugins, ...macros.babelMacros, ...buildDebugMacroPlugin(!isProduction)],
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading