Skip to content

Commit

Permalink
add failing tests for initialisers
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed Jun 27, 2024
1 parent 348b946 commit bb60534
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/default.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('basic functionality', function () {
let result;

try {
result = await execa('pnpm', ['test'], {
result = await execa('pnpm', ['test:ember'], {

Check failure on line 52 in tests/default.test.mjs

View workflow job for this annotation

GitHub Actions / Lint & Test

tests/default.test.mjs > basic functionality > successfully runs tests

ExecaError: Command failed with exit code 1: pnpm 'test:ember' (!) outDir /tmp/tmp-1897-BUSJXWDLwV2U/fancy-app-in-test/dist is not inside project root and will not be emptied. Use --emptyOutDir to override. <script src="/@embroider/core/vendor.js"> in "/index.html" can't be bundled without type="module" attribute <script src="/testem.js"> in "/tests/index.html" can't be bundled without type="module" attribute <script src="/@embroider/core/vendor.js"> in "/tests/index.html" can't be bundled without type="module" attribute <script src="/@embroider/core/test-support.js"> in "/tests/index.html" can't be bundled without type="module" attribute /assets/fancy-app-in-test.css doesn't exist at build time, it will remain unchanged to be resolved at runtime DEPRECATION: The parts property on path nodes is deprecated, use head and tail instead DEPRECATION: The this property on path nodes is deprecated, use head.type instead DEPRECATION: The parts property on path nodes is deprecated, use head and tail instead DEPRECATION: The parts property on path nodes is deprecated, use head and tail instead DEPRECATION: The this property on path nodes is deprecated, use head.type instead DEPRECATION: The parts property on path nodes is deprecated, use head and tail instead DEPRECATION: The parts property on path nodes is deprecated, use head and tail instead DEPRECATION: The this property on path nodes is deprecated, use head.type instead DEPRECATION: The parts property on path nodes is deprecated, use head and tail instead DEPRECATION: The parts property on path nodes is deprecated, use head and tail instead DEPRECATION: The this property on path nodes is deprecated, use head.type instead DEPRECATION: The parts property on path nodes is deprecated, use head and tail instead DEPRECATION: The this property on path nodes is deprecated, use head.type instead DEPRECATION: The parts property on path nodes is deprecated, use head and tail instead DEPRECATION: The this property on path nodes is deprecated, use head.type instead [plugin:vite:reporter] [plugin vite:reporter] (!) /tmp/tmp-1897-BUSJXWDLwV2U/fancy-app-in-test/tmp/rewritten-app/tests/test-helper.js is dynamically imported by embroider_virtual:/tmp/tmp-1897-BUSJXWDLwV2U/fancy-app-in-test/tmp/rewritten-app/-embroider-test-entrypoint.js but also statically imported by embroider_virtual:/tmp/tmp-1897-BUSJXWDLwV2U/fancy-app-in-test/tmp/rewritten-app/-embroider-test-entrypoint.js, dynamic import will not move module into another chunk. (!) Some chunks are larger than 500 kB after minification. Consider: - Using dynamic import() to code-split the application - Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks - Adjust chunk size limit for this warning via build.chunkSizeWarningLimit. Testem finished with non-zero exit code. Tests failed. > [email protected] test:ember /tmp/tmp-1897-BUSJXWDLwV2U/fancy-app-in-test > vite build --mode test && ember test --path dist vite v5.3.1 building for test... Building Environment: test building... cleaning up cleaning up... Built project successfully. Stored in "dist/". transforming... ✓ 357 modules transformed. rendering chunks... computing gzip size... ../../dist/@embroider/core/test-support.js 0.46 kB ../../dist/testem.js 0.68 kB ../../dist/index.html 1.25 kB │ gzip: 0.63 kB ../../dist/tests/index.html 1.94 kB │ gzip: 0.91 kB ../../dist/@embroider/core/vendor.js 9.31 kB ../../dist/ember-welcome-page/images/construction.png 91.11 kB ../../dist/assets/fancy-app-in-test.css 0.16 kB │ gzip: 0.15 kB ../../dist/assets/-embroider-entrypoint-B9YwGhao.css 1.87 kB │ gzip: 0.61 kB ../../dist/assets/tests-BZEWdZSW.css 8.37 kB │ gzip: 2.34 kB ../../dist/assets/tests-BKRoe06T.js 386.91 kB │ gzip: 84.93 kB ../../dist/assets/-embroider-entrypoint-NVZG5csB.js
cwd: join(tmpDir.path, appName),
});
} catch (err) {
Expand Down
6 changes: 6 additions & 0 deletions tests/fixture/app/initializers/test-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
name: 'test-init',
initialize(application) {
application.__test_init = 'coming from the initializer';
},
};
6 changes: 6 additions & 0 deletions tests/fixture/app/instance-initializers/test-instance-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
name: 'test-instance-initializers',
initialize(instance) {
instance.__instance_test_init = 'set in the instance initializer';
},
};
13 changes: 13 additions & 0 deletions tests/fixture/tests/acceptance/app-init-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { module, test } from 'qunit';
import { getApplication } from '@ember/test-helpers';
import { setupApplicationTest } from '<%= name %>/tests/helpers';

module('Acceptance | app route', function (hooks) {
setupApplicationTest(hooks);

test('loaded initializers /', async function (assert) {
const app = getApplication();
assert.strictEqual([...app._applicationInstances][0].__instance_test_init, 'set in the instance initializer');
assert.strictEqual(app.__test_init, 'coming from the initializer');
});
});

0 comments on commit bb60534

Please sign in to comment.