Reputation: 7256
I have a CoffeeScript test which I only want to run if the Node version is 8 or greater. For any lower version number, I'd like to skip the test.
The file has the extension .spec.coffee
and the test takes the following structure:
it.skip 'test name', ->
# __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
As I understand it, util.promisify
is not available in Node versions 7 or lower so I'd like this test to skip when running on these versions.
Is this possible and if so, how do I do it?
Upvotes: 0
Views: 27
Reputation: 20155
You can get node's version inside a script with
process.versions.node
As I understand it, util.promisify
instead of skipping the test, find a polyfill for that function.
Upvotes: 2