embroider-build / embroider

Compiling Ember apps into spec-compliant, modern Javascript.
MIT License
331 stars 137 forks source link

`ember test` fails to run tests #780

Closed timiyay closed 3 years ago

timiyay commented 3 years ago

We're experimenting with embroider adoption on a new Ember 3.24 app.

We're using 0.39, to avoid the issue where @embroider/webpack wants webpack 5, but other embroider packages or dependencies want webpack 4.

"@embroider/compat": "0.39.0",
"@embroider/core": "0.39.0",
"@embroider/webpack": "0.39.0",
"webpack": "^4.46.0",

Our test suite won't run when using embroider builds - the build completes but the tests never start.

$ ember test

Environment: test
⠋ Buildingbroccoli-babel-transpiler is opting out of caching due to a plugin that does not provide a caching strategy: `function TransformTestSelectorParamsToHashPairs() {
  this.syntax = null;
}`.
⠹ building... [OneShot > Babel: my-addon3 > applyPatches]broccoli-babel-transpiler is opting out of caching due to a plugin that does not provide a caching strategy: `function TransformTestSelectorParamsToHashPairs() {
  this.syntax = null;
}`.
⠦ building... [CSSModules]Building into /private/var/folders/1n/vdckwbw10md6ltblrlff8k6m0000gn/T/embroider/93e967
⠋ building... [@embroider/compat/app]WARNING: Your build is slower because some babel plugins are non-serializable
⠇ building... [@embroider/webpack][BABEL] Note: The code generator has deoptimised the styling of /Users/tasquith/Blake/my-ember-app/node_modules/axe-core/axe.js as it exceeds the max of 500KB.
⠴ building... [@embroider/webpack]Hash: aab2e6330492a12f11ae
Version: webpack 4.44.2
Child
    Hash: aab2e6330492a12f11ae
    Time: 13749ms
    Built at: 27/04/2021 10:21:57 am
                            Asset      Size                                                   Chunks                                Chunk Names
    chunk.46822e32daf463bfa117.js   322 KiB                                           assets/test.js  [emitted] [immutable]  [big]  assets/test.js
    chunk.52c43ca7ce4038c20152.js  6.41 KiB                         assets/my-ember-app.js  [emitted] [immutable]         assets/my-ember-app.js
    chunk.6c95fd2602af60083ec1.js  1.21 MiB                                   vendors~assets/test.js  [emitted] [immutable]  [big]  vendors~assets/test.js
    chunk.9acea14b95c04a47fa14.js  5.07 MiB  vendors~assets/my-ember-app.js~assets/test.js  [emitted] [immutable]  [big]  vendors~assets/my-ember-app.js~assets/test.js
    chunk.e7b20fbd581776679976.js   524 KiB          assets/my-ember-app.js~assets/test.js  [emitted] [immutable]  [big]  assets/my-ember-app.js~assets/test.js
    Entrypoint assets/my-ember-app.js [big] = chunk.9acea14b95c04a47fa14.js chunk.e7b20fbd581776679976.js chunk.52c43ca7ce4038c20152.js
    Entrypoint assets/test.js [big] = chunk.9acea14b95c04a47fa14.js chunk.6c95fd2602af60083ec1.js chunk.e7b20fbd581776679976.js chunk.46822e32daf463bfa117.js
    [./activity/model.ts] 3.59 KiB {assets/my-ember-app.js~assets/test.js} [built]
    [./activity/service.ts] 3.7 KiB {assets/my-ember-app.js~assets/test.js} [built]
    [./adapters/-json-api.js] 55 bytes {assets/my-ember-app.js~assets/test.js} [built]
    [./app.ts] 669 bytes {assets/my-ember-app.js~assets/test.js} [built]
    [./application/adapter.ts] 467 bytes {assets/my-ember-app.js~assets/test.js} [built]
    [./application/log-adapter.ts] 67 bytes {assets/my-ember-app.js~assets/test.js} [built]
    [./application/route.ts] 2.56 KiB {assets/my-ember-app.js~assets/test.js} [built]
    [./application/serializer.ts] 98 bytes {assets/my-ember-app.js~assets/test.js} [built]
    [./application/template.hbs] 400 bytes {assets/my-ember-app.js~assets/test.js} [built]
    [./assets/my-ember-app.js] 21.6 KiB {assets/my-ember-app.js~assets/test.js} [built]
    [./assets/test.js] 10.8 KiB {assets/test.js} [built]
    [./component-managers/glimmer.js] 94 bytes {assets/my-ember-app.js~assets/test.js} [built]
        + 1299 hidden modules

    WARNING in ./utils/storage-adapter.js 1:0-85
    "export 'default' was not found in '../node_modules/my-addon1/utils/storage-adapter'
     @ ./assets/my-ember-app.js

    WARNING in ./utils/token-result.js 1:0-82
    "export 'default' was not found in '../node_modules/my-addon1/utils/token-result'
     @ ./assets/my-ember-app.js

    WARNING in ./utils/rollbar.js 1:0-76
    "export 'default' was not found in '../node_modules/my-addon2/utils/rollbar'
     @ ./assets/my-ember-app.js

    WARNING in ./node_modules/ember-inflector/index.js 4:0-48
    "export 'defaultRules' was not found in './lib/system'
     @ ./initializers/custom-inflector-rules.ts
     @ ./assets/my-ember-app.js
cleaning up...
Built project successfully. Stored in "/var/folders/1n/vdckwbw10md6ltblrlff8k6m0000gn/T/tests-dist-2021327-28559-1td8xb5.arsk".

After the Built project successfully output, the process hangs indefinitely until Ctrl+C is pressed. No tests are run.

This issue happens when running ember test with the default test environment, which is why I opened a new issue instead of commenting on the production-specific https://github.com/embroider-build/embroider/issues/724

timiyay commented 3 years ago

Gah, I got stuck on this for a while, as soon as I open an issue I make progress 😬

This issue was caused by me copypasta'ing config from https://github.com/embroider-build/embroider#configuring-asset-urls:

packagerOptions: {
    publicAssetURL: 'https://your-cdn-here.com/', // This should be a URL ending in "/"
}

publicAssetURL should not be used for development and test builds, which is default behaviour in legacy builds. Once I made it conditional on production builds, my tests started running.

The tests don't complete, they hang after the last test, and require Ctrl+C to be pressed to exit and receive results.

ef4 commented 3 years ago

I'm glad you were able to fix your problem and thanks for sharing the solution for future searchers who may hit the same issue.

But also, please file an issue for:

We're using 0.39, to avoid the issue where @embroider/webpack wants webpack 5, but other embroider packages or dependencies want webpack 4.

Because that is definitely not supposed to be a thing and I don't see any way to reproduce it.

timiyay commented 3 years ago

Follow-up issue opened at https://github.com/embroider-build/embroider/issues/783