Skip to content

Commit

Permalink
chore: Add test for CLI crash
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Nov 8, 2021
1 parent 3f1e586 commit fbec705
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/index.js
Expand Up @@ -138,6 +138,28 @@ describe('v8flags', function () {
});
});

it('fails with an error if the CLI crashes', function (done) {
if (os.platform() === 'win32') {
this.skip();
}

eraseHome();
var v8flags = require('../');

// Save original execPath
var execPath = process.execPath;
// Set execPath to our fake-bin
process.execPath = __dirname + '/throw-bin';

v8flags(function (err, flags) {
expect(err).not.toBeNull();
expect(flags).toBeUndefined();
// Restore original execPath
process.execPath = execPath;
done();
});
});

it('should back with an empty array if the runtime is electron', function (done) {
process.versions.electron = 'set';
var v8flags = require('../');
Expand Down
3 changes: 3 additions & 0 deletions test/throw-bin
@@ -0,0 +1,3 @@
#!/usr/bin/env node

throw new Error("Boom");

0 comments on commit fbec705

Please sign in to comment.