Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions test/parallel/test-vm-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const vm = require('vm');
// Test 1: Timeout of 100ms executing endless loop
assert.throws(function() {
vm.runInThisContext('while(true) {}', { timeout: 100 });
}, function(err) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using a regexp as the second argument would be more succinct: /^Error: Script execution timed out\.$/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha I agree with you before when I tried /^Script execution timed out.$/ it didn't work, so I did the above approached. I didn't realize that "Error: " was included also. Awesome I will correct it!

const re = /^Script execution timed out\.$/;
if ((err instanceof Error) && re.test(err.message)) { return true; }
});

// Test 2: Timeout must be >= 0ms
Expand Down