Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-M, --context-timeout is ignored; test passed even it is not triggered #729

Closed
jagin opened this issue Jul 28, 2017 · 1 comment
Assignees
Labels
bug
Milestone

Comments

@jagin
Copy link

@jagin jagin commented Jul 28, 2017

Hi,

I have the following test:

const Code = require('code')
const Lab = require('lab')
const lab = exports.lab = Lab.script()

const describe = lab.describe
const it = lab.it
const before = lab.before
const expect = Code.expect

before(done => {
 setTimeout(() => {
   console.log('## before ##')
   done()
 }, 3000)
})

describe('TEST', () => {
 it('test it', done => {
   console.log('## test ##')

   expect(1).to.equal(1)
   done()
 })
})

I run it with lab and result is as follow:

TEST                                                                                                               
  √ 6) test it (0 ms)                                                                                              
                                                                                                                   
                                                                                                                   
Test script errors:                                                                                                
                                                                                                                   
Timed out (2000ms) - Before                                                                                        
      at Timeout.setTimeout (c:\Users\Jarek\Projects\test\node_modules\lab\lib\runner.js:582:23)     
      at ontimeout (timers.js:365:14)                                                                              
      at tryOnTimeout (timers.js:237:5)                                                                            
      at Timer.listOnTimeout (timers.js:207:5)                                                                     
                                                                                                                   
There were 1 test script error(s).                                                                                 
                                                                                                                   
1 tests complete                                                                                                   
Test duration: 2009 ms                                                                                             
No global variable leaks detected                                                                                  
  1. I got timeout on before even the -M is not set and the documentation says:

-M, --context-timeout - default timeouts for before, after, beforeEach and afterEach in milliseconds. Disabled by default.

  1. Even we got timeout on before the report shows us that the test passed (it is green) but no console.log was executed

Running the test with lab -M 5000 it works perfectly:

## before ##
## test ##       
TEST                               
  √ 6) test it (3 ms)              
                                   
                                   
1 tests complete                   
Test duration: 3014 ms             
No global variable leaks detected  
@geek

This comment has been minimized.

Copy link
Member

@geek geek commented Jul 28, 2017

@jagin good catch. This is a bug, the before/after timeout should be disabled by default as indicated by the documentation.

@geek geek added the bug label Jul 28, 2017
@geek geek added this to the 16.0.0 milestone Jul 25, 2018
@geek geek self-assigned this Jul 25, 2018
@geek geek closed this in #844 Jul 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.