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.

Skipped test with 'toThrow' assertion crashes the test runner

See original GitHub issue

See:

https://github.com/ColinEberhardt/assemblyscript-regex/blob/as-pect-error/assembly/__spec_tests__/generated.spec.ts

I have a single skipped test:

xit("line: 1185 - matches ab{3cd against 'ab{3cd'", () => {
  expect(() => new RegExp("ab{3cd")).toThrow();
});

When I run npm run asp, the runner crashes as follows:

Error [AssertionError]: assertion failed
    at t.assert (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:645440)
    at p.canOverflow (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:229337)
    at T.compileReturnedExpression (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:436254)
    at T.compileFunctionBody (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:407593)
    at T.compileFunction (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:406316)
    at T.compileFunctionExpression (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:501251)
    at T.compileExpression (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:434922)
    at T.compileCallDirect (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:484985)
    at T.compileCallExpression (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:480093)
    at T.compileExpression (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:434709)
    at T.compileCallExpression (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:480026)
    at T.compileExpression (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:434709)
    at T.compileExpressionStatement (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:422187)
    at T.compileStatement (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:418026)
    at T.compileStatements (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:419054)
    at T.compileFunctionBody (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:407392)
    at T.compileFunction (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:406316)
    at T.compileFunctionExpression (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:501251)
    at T.compileExpression (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:434922)
    at T.compileCallDirect (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:484985)
    at T.compileCallExpression (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:480093)
    at T.compileExpression (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:434709)
    at T.compileExpressionStatement (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:422187)
    at T.compileStatement (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:418026)
    at T.compileTopLevelStatement (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:417552)
    at T.compileFile (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:399267)
    at T.compile (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:390142)
    at Object.t.compile (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/dist/assemblyscript.js:7:666244)
    at /Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/cli/asc.js:710:29
    at measure (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/cli/asc.js:1101:3)
    at Object.main (/Users/colineberhardt/Projects/as-regex/node_modules/assemblyscript/cli/asc.js:709:24)
    at /Users/colineberhardt/Projects/as-regex/node_modules/@as-pect/cli/lib/run.js:602:17
    at Array.forEach (<anonymous>)
    at run (/Users/colineberhardt/Projects/as-regex/node_modules/@as-pect/cli/lib/run.js:600:36)
    at Object.asp (/Users/colineberhardt/Projects/as-regex/node_modules/@as-pect/cli/lib/index.js:64:9)
    at Object.<anonymous> (/Users/colineberhardt/Projects/as-regex/node_modules/@as-pect/cli/lib/test.js:2:28)
    at Module._compile (node:internal/modules/cjs/loader:1102:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
    at Module.load (node:internal/modules/cjs/loader:967:32)
    at Function.Module._load (node:internal/modules/cjs/loader:807:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47

Modifying the skipped test as follows fixes the problem:

xit("line: 1185 - matches ab{3cd against 'ab{3cd'", () => {
  expect(() => throw new Error("Whoops")).toThrow();
});

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jtennercommented, Feb 2, 2021

Yes. This looks like a compiler error. I would file a complaint with assemblyscript about this assertion error.

I also think waiting may be a wise decision because I don’t know if this issue is already fixed.

0reactions
jtennercommented, Mar 1, 2021

Closing, because this error was related to AssemblyScript and not aspect

Read more comments on GitHub >

github_iconTop Results From Across the Web

Test result is Skipped when an exception has been thrown ...
No warnings have been asserted prior to the exception being thrown. That means that for example, code with the following is reported as...
Read more >
PHPUnit assert that an exception was thrown? - Stack Overflow
Simple assertion OK (1 test, 1 assertion). you may be surprised by failing the exception test: <?php use PHPUnit\Framework\TestCase; ...
Read more >
Successfully Throwing Async Errors with the Jest Testing Library
Today, I'll discuss how to successfully test expected errors are thrown with the popular JavaScript testing library Jest, so you can rest easier ......
Read more >
Jest Testing like a Pro - Tips and tricks
If you forgot either the async / await or the return, the test will exit immediately, way before the data is loaded, and...
Read more >
Asserts - Node Tap
The Test object has a collection of assertion methods. ... skip Set to boolean true or a String to mark this as skipped;...
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