Skip to content

Coverage fails in dev mode (ember serve) on 2.0.3 #403

Closed

Description

@olyckne

From what I can see the only change introduced in 2.0.3 is #387 and after upgrading it fails coverage in our application when running COVERAGE=true ember serve and running tests by visiting http://localhost:4200/tests. It works when running COVERAGE=true ember test.

Our app is running 4.12.3 and isn't using Embroider but I have tried in a branch where we are running Embroider with maximum backward compatibility and it fails in both cases.

I've also tried in a new Ember app (currently 5.5.0) by running ember new ember-code-coverage and getting the same issue.

Works:
COVERAGE=true ember test
COVERAGE=true ember test --server

Fails:
COVERAGE=true ember serve

Getting the same problem if I clone this repo and runs the test in my-app

Error:

TypeError: Cannot destructure property 'root' of 'options' as it is undefined.
    at writeCoverage (/Code/ember-code-coverage/node_modules/ember-cli-code-coverage/lib/attach-middleware.js:146:9)
    at coverageHandler (/Code/ember-code-coverage/node_modules/ember-cli-code-coverage/lib/attach-middleware.js:191:3)
    at /Code/ember-code-coverage/node_modules/ember-cli-code-coverage/lib/attach-middleware.js:206:7
    at Layer.handle [as handle_request] (/Code/ember-code-coverage/node_modules/express/lib/router/layer.js:95:5)
    at next (/Code/ember-code-coverage/node_modules/express/lib/router/route.js:144:13)
    at /Code/ember-code-coverage/node_modules/body-parser/lib/read.js:137:5
    at AsyncResource.runInAsyncScope (node:async_hooks:206:9)
    at invokeCallback (/Code/ember-code-coverage/node_modules/raw-body/index.js:231:16)
    at done (/Code/ember-code-coverage/node_modules/raw-body/index.js:220:7)
    at IncomingMessage.onEnd (/Code/ember-code-coverage/node_modules/raw-body/index.js:280:7)
    at IncomingMessage.emit (node:events:514:28)
    at endReadableNT (node:internal/streams/readable:1589:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Activity

  1. olyckne commented on Mar 1, 2024

    @olyckne
    Author

    After updating to 2.1.1 the whole Ember application crashes due to this issue.
    Tried to investigate a bit and if I revert this change
    494396b#diff-220612c243d58fc738e2512fd4efbd91e7700e2b8b547032a3e260df5fb7ee9dL119-R129

    it seems to be working again, but I'm not sure why that change was made.

    With the current code

    serverMiddleware(startOptions, config) {
      attachMiddleware.serverMiddleware(startOptions.app, config);
    },

    If I understand it correctly ember serve automatically calls serverMiddleware but only with startOptions which will make config undefined.

    When running ember test --server it will use testemMiddleware which will call serverMiddleware with a correct config

  2. krasnoukhov commented on Apr 5, 2024

    @krasnoukhov
    Contributor

    Nice find @olyckne, created a PR for this, hopefully will get accepted 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions