avajs / ava

Node.js test runner that lets you develop with confidence 🚀
MIT License
20.74k stars 1.41k forks source link

Reports 'No tests found in xxx' and silences error #2846

Closed vjpr closed 3 years ago

vjpr commented 3 years ago

Please provide details about:

I'm using v4. I used --experimental-loader, and this causes an error.

I just get No tests found.

When I look in the source:

The worker-failed message just reports it as "no declared tests", but ignores the actual error.

If you enable verbose it says ✖ src/index.test.ava.ts exited due to undefined.

It should print the full error if it doesn't recognize it without even without verbose. Silent errors are really bad.

    case 'worker-failed': {
                if (fileStats.declaredTests === 0) {
                    //console.log(event) <---------
                    this.filesWithoutDeclaredTests.add(event.testFile);
                }

                if (this.verbose && !this.filesWithMissingAvaImports.has(event.testFile)) {
                    if (event.nonZeroExitCode) {
                        this.lineWriter.writeLine(colors.error(`${figures.cross} ${this.relativeFile(event.testFile)} exited with a non-zero exit code: ${event.nonZeroExitCode}`));
                    } else {
                        this.lineWriter.writeLine(colors.error(`${figures.cross} ${this.relativeFile(event.testFile)} exited due to ${event.signal}`));
                    }
                }

                break;
            }

In my case it was a ERR_MODULE_NOT_FOUND message.

And even with verbose, for other errors, it trims the stack trace which is annoying.


Here are some more errors I got afterwards, but without a stack trace is impossible to debug.

  Uncaught exception in src/index.test.ava.ts

  TypeError: require(...).getRunner is not a function

  Uncaught exception in src/index.test.ava.ts

  TypeError: Cannot read property 'chalkOptions' of undefined
            case 'uncaught-exception': {
                this.uncaughtExceptions.push(event);

                if (this.verbose) {
                    this.lineWriter.ensureEmptyLine();
                    this.lineWriter.writeLine(colors.title(`Uncaught exception in ${this.relativeFile(event.testFile)}`));
                    this.lineWriter.writeLine();
                    this.writeErr(event);
                    console.log(event.stack) <-------- This is the stack which is hidden! Please print it when in verbose mode. Maybe add a `trace` mode!
                }

                break;
            }

And now I also get internal stack traces:

node[86033]: ../src/node_file-inl.h:160:virtual node::fs::FSReqPromise<node::AliasedBufferBase<double, v8::Float64Array, void> >::~FSReqPromise() [AliasedBufferT = node::AliasedBufferBase<double, v8::Float64Array, void>]: Assertion `finished_' failed.
 1: 0x105e60405 node::Abort() (.cold.1) [/Users/Vaughan/nvm/versions/node/v16.7.0/bin/node]
 2: 0x104b57f79 node::Abort() [/Users/Vaughan/nvm/versions/node/v16.7.0/bin/node]
  ✖ src/index.test.ava.ts exited due to undefined
 3: 0x104b57db1 node::Assert(node::AssertionInfo const&) [/Users/Vaughan/nvm/versions/node/v16.7.0/bin/node]
 4: 0x104b53628 node::fs::FSReqPromise<node::AliasedBufferBase<double, v8::Float64Array, void> >::~FSReqPromise() [/Users/Vaughan/nvm/versions/node/v16.7.0/bin/node]
 5: 0x104b5cec0 node::fs::FSReqAfterScope::Clear() [/Users/Vaughan/nvm/versions/node/v16.7.0/bin/node]
 6: 0x104b5d2b8 node::fs::AfterOpenFileHandle(uv_fs_s*) [/Users/Vaughan/nvm/versions/node/v16.7.0/bin/node]
 7: 0x105510898 uv__work_done [/Users/Vaughan/nvm/versions/node/v16.7.0/bin/node]
 8: 0x1055159e3 uv__async_io [/Users/Vaughan/nvm/versions/node/v16.7.0/bin/node]
 9: 0x1055295ec uv__io_poll [/Users/Vaughan/nvm/versions/node/v16.7.0/bin/node]
10: 0x105515f51 uv_run [/Users/Vaughan/nvm/versions/node/v16.7.0/bin/node]
11: 0x104a8be74 node::SpinEventLoop(node::Environment*) [/Users/Vaughan/nvm/versions/node/v16.7.0/bin/node]
12: 0x104bfed11 node::worker::Worker::Run() [/Users/Vaughan/nvm/versions/node/v16.7.0/bin/node]
13: 0x104c0290f node::worker::Worker::StartThread(v8::FunctionCallbackInfo<v8::Value> const&)::$_3::__invoke(void*) [/Users/Vaughan/nvm/versions/node/v16.7.0/bin/node]
14: 0x7fff2046a950 _pthread_start [/usr/lib/system/libsystem_pthread.dylib]
15: 0x7fff2046647b thread_start [/usr/lib/system/libsystem_pthread.dylib]
[1]    86033 abort      ava
novemberborn commented 3 years ago

I actually came across this when working on https://github.com/avajs/ava/pull/2841 so it'll be solved as part of that.