Strange bug in circleci docker env: `node tap.js` pass but `tap tap.js` will fail



I’m using nodejs v6, with node-tap:

Recently, my project unit test code(which is using TAP) are always fail in circleci. What very strange is, at the same time, they can pass in appveyor and my dev box.

after digged it for serval hours, I find the reason is the follow code:

function func({
  a = 'default'
  , b
} = {}) {
  return a

const a = func({ b: 1 })
console.log('a should be "default". actual a = "' + a + '"')

in the above code, a in func has a default value default. after we call the func without a, we should get func return value “default”.

when we use node v6 to run this code, there’s no problem.
when I use tap to run this code, this no problem, too.

But when this code is ran inside CircleCI & Travis-CI , the func will return undefined instead of default.

this cause my unit test fail.

a example CI failure can be found here: . Notice the following line:

ERR! PuppetWeb init exception: Watchdog onFeed: unsupport type undefined

the undefined should have a default value.

I can reproduce this bug inside the CirclerCI “Debug via SSH” feature, use the following script:

mkdir a
cd a

npm init --yes

mkdir b
cd b

cat > bug.js <<__CODE__
const test  = require('tap').test
const func = require('../w.js')

test('func param test', function(t) {
        const type = func({ data: 'direct call' })

        t.equal(type, 'default', 'should be default')

cat > ../w.js <<__CODE__
module.exports = function func(options) {
        const { type = 'default', data } = options || {}
        console.log('type=' + type + ', data=' + data)
        return type

npm install tap --save-dev

node bug.js
tap bug.js

The output is like the following(copy/paste from my console)

  1. use node bug.js can get the default value
ubuntu@box571:~/a/b$ node bug.js
TAP version 13
    # Subtest: func param test
type=default, data=direct call
    ok 1 - should be default
ok 1 - func param test # time=11.414ms

# time=38.53ms
  1. at the same time, the same tap.js, run by tap, will fail.
ubuntu@box571:~/a/b$ tap bug.js

bug.js type=undefined, data=direct call
bug.js ................................................ 0/1 932ms
  func param test
  not ok should be default
    +++ found                                                          
    --- wanted                                                         
    compare: ===