bcaudan/jasmine-spec-reporter

Uncaught exception when using `displayStacktrace: 'pretty'` option

murrple-1 opened this issue · 7 comments

Bug report

Current behavior
When using the config { spec: { displayStacktrace: 'pretty' } }, I am getting an error and stacktrace like:

[12:17:39] E/launcher - ENOENT: no such file or directory, open 'fs.js'
[12:17:39] E/launcher - Error: ENOENT: no such file or directory, open 'fs.js'
    at Object.openSync (fs.js:440:3)
    at Object.readFileSync (fs.js:342:35)
    at PrettyStacktraceProcessor.retrieveErrorContext (C:\[project]\node_modules\jasmine-spec-reporter\built\processors\pretty-stacktrace-processor.js:60:28)
    at Array.forEach (<anonymous>)
    at PrettyStacktraceProcessor.prettifyStack (C:\[project]\node_modules\jasmine-spec-reporter\built\processors\pretty-stacktrace-processor.js:48:35)
    at PrettyStacktraceProcessor.displayErrorMessages (C:\[project]\node_modules\jasmine-spec-reporter\built\processors\pretty-stacktrace-processor.js:38:32)
    at PrettyStacktraceProcessor.displaySpecErrorMessages (C:\[project]\node_modules\jasmine-spec-reporter\built\processors\pretty-stacktrace-processor.js:27:109)
    at C:\[project]\node_modules\jasmine-spec-reporter\built\display\execution-display.js:55:45
    at C:\[project]\node_modules\jasmine-spec-reporter\built\display\logger.js:21:19

Expected behavior
The 'pretty' option should work.
Minimal reproduction of the problem with instructions
I think it's a simple as getting a getting a stacktrace to fire via the tests, and then the pretty formatter attempts to display it. Should be noted, it happens on my Windows 10 PC, as well as the Docker/Linux image I'm using on CircleCI.
Workaround
Use the 'raw' or 'none' option for now.

Hi @murrple-1!

Thanks for opening this issue.

I would like a bit more info to be sure to understand the problem:

If this exception is raised for every failed expect(), can you try to reproduce it with one of the examples?

If it is raised only for some particular cases, can you give me an exemple of a 'raw' stacktrace that provoke the exception?

I wasn't able to recreate it using the examples. I'm of course worried that the example is contrived, or that the issue isn't in jasmine-spec-reporter itself. However, I have given it a shot.

I was able to create a minimal repo using the full stack. It's an Angular project, which I am hopeful you are familiar with. The only external dependencies I am able to determine are I am using Chrome and Yarn. Node version is v12.14.0. Let me know if the setup is a) infeasible for you, or b) doesn't display the error when you run it, and I will try and set up a Travis CI example using the repo.

https://github.com/murrple-1/jasmine-spec-reporter-issue-1

Thanks for the repo, I have been able to reproduce your issue with it.
The issue should be fixed with jasmine-spec-reporter@5.0.2.

I'm still seeing this with 6.0.0:

      internal/timers.js:461:21
      jasmine-spec-reporter: unable to open 'internal/timers.js'
      Error: ENOENT: no such file or directory, open 'internal/timers.js'

The same happens when I downgrade to 5.0.2.

Hi @squidfunk,

  • jasmine-spec-reporter: unable to open 'internal/timers.js' is the expected behavior cf implementation
  • Error: ENOENT: no such file or directory, open 'internal/timers.js' no clue where this error could come from then 🤔

Could you try to reproduce it on a minimal repo?

@bcaudan I have a repository, which you can check out and see the behavior: https://github.com/squidfunk/isotopes
Just check it out, run npm install, throw an error in one of the tests, and run npm test:

IsotopeSelect
      ✗ should return all items by default
        - Error: Oops!

        .../isotopes/tests/suites/unit/isotopes/select/index.spec.ts:40:13
            /* Test: should return all items by default */
            it("should return all items by default", () => {
              throw new Error("Oops!")
                    ~
              const select = new IsotopeSelect({
                domain: "domain",

        internal/timers.js:461:21
        jasmine-spec-reporter: unable to open 'internal/timers.js'
        Error: ENOENT: no such file or directory, open 'internal/timers.js'

Thanks for the repo!

In fact this is the expected behavior 🙃
I though Error: ENOENT: no such file or directory, open 'internal/timers.js' was breaking your test execution but in fact it is just displaying the error that prevent jasmine-spec-reporter to get the source information.

`jasmine-spec-reporter: unable to open '${filename}'\n${error}`

I've missed the \n${error} when I previously checked the implementation 🤦

Displaying the original error can indeed be confusing and does not seem to bring much value.
I am considering to remove it unless you have a better suggestion.