MithrilJS / ospec

Noiseless testing framework
MIT License
48 stars 13 forks source link

ospec: Asynchronous tests doesn't work with arrow functions #1

Closed kesara closed 2 years ago

kesara commented 4 years ago

ospec: Asynchronous tests doesn't work with arrow functions

ospec version: 4.0.1

Browser and OS: MacOS

Code

Following test works:

o("setTimeout calls callback", function(done) {
    setTimeout(done, 10)
})

But this test with arrow function gives and error:

o("setTimeout calls callback", (done) => {
    setTimeout(done, 10)
})

Steps to Reproduce

  1. Create a test.js file with following:
    
    var o = require("ospec")

o("setTimeout calls callback", (done) => { setTimeout(done, 10) })

2. Run `ospec test.js`

## Expected Behavior

–––––– The 1 assertion passed in 23ms


## Current Behavior

ospec.js:181 else throw e ^

(done)() should be called at least once at Object. (/Users/kesara/Lab/ospec-test/test.js:3:1)



## Context
<!--
Optional: How is this issue affecting you? What are you trying to do? Providing
us context helps us reach a solution that best fits your particular needs.
-->
ospec should treat the arrow functions as same as regular functions.
pygy commented 2 years ago

This has long been fixed