【发布时间】:2019-02-17 14:39:55
【问题描述】:
我有一个 CoffeeScript 测试,我只想在 Node 版本为 8 或更高版本时运行它。对于任何较低的版本号,我想跳过测试。
文件扩展名为.spec.coffee,测试采用以下结构:
it.skip '测试名称', ->
# __dirname is the 'test/' folder, so go up then find the SDK path
path = path.join __dirname, '..', 'folder1', 'folder2'
# run `npm run tstest`
exec = util.promisify(process.exec)
return exec 'npm run test', cwd: path
.then (data) ->
expect(data.stderr).to.eql ''
expect(data.stdout).to.exist
据我了解,util.promisify 在 Node 版本 7 或更低版本中不可用,因此我希望在这些版本上运行时跳过此测试。
这可能吗?如果可以,我该怎么做?
【问题讨论】:
-
抱歉。附加信息已添加到问题中。
-
正如答案所暗示的,promsify 是 polyfillable,并且有一个 polyfill,github.com/ljharb/util.promisify
标签: javascript node.js testing coffeescript