question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error while opening file under mocha test

See original GitHub issue

I have implemented a yauzl.open(path, { lazyEntries: true}, (error, zipfile) => {}); that works fine for normal operation.

The failure happens when I try to do the same inside a mocha test, where the file gives an error when trying to open the zip file as shown here:

Error: end of central directory record signature not found
    at /myproject/node_modules/yauzl/index.js:187:14
    at /myproject/node_modules/yauzl/index.js:631:5
    at /myproject/node_modules/fd-slicer/index.js:32:7
    at FSReqWrap.wrapper [as oncomplete] (fs.js:658:17)

After running the test, the zip file is corrupted and if you try to extract it, you get a .zip.cpgz (Im using MacOS Mojave)

Note that is the same file that works when running from the main code. The mocha test use a tdd style. For context, Im using the VScode extension test test runner since I am working on a extension.

If there is anything I can add please let me know.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
brianignacio5commented, Apr 18, 2019

The issue had nothing to do with yauzl, another test was breaking the file. Sorry for the inconvenience.

0reactions
brianignacio5commented, Apr 1, 2019

Yes, sorry I was not clear. So 'end' event I am referring to is the one from zip file. Will update on first post. In the write stream close event Im doing the same as Cpp tools extension here : https://github.com/Microsoft/vscode-cpptools/blob/master/Extension/src/packageManager.ts#L376

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mocha Test Exception occurred while loading your tests
I'm experiencing a problem with testing my Vue.js project. We have mocha-webpack to compile and run the test files.
Read more >
Error when loading tests · Issue #7 · hbenl/vscode-mocha-test ...
I got another error when load tests.: [2018-08-01 13:50:56.037] [INFO] Loading test files of c:\Users\Daniel\Desktop\SoluCX\baseimporter ...
Read more >
Getting Started with Node.js and Mocha - Semaphore Tutorial
Mocha is a simple, extensible and fast testing library for Node.js. This article will walk you through its installation, configuration and usage.
Read more >
Testing with Mocha and local files - CloudAppie
When writing the test cases there are a few scenario's you want to test, things like success and failure when working with the...
Read more >
Running Tests and Interpreting Output with Mocha and Chai
To run tests for your projects, first open the root project directory in your terminal. ... mocha will log that error in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found