How can I convert this function to use the async/await style:
it.only("should bump the 'minor' version attribute", () => {
const writeFile = util.promisify(require("fs").writeFile);
return writeFile("bump-minor.json", "contents").then(function() {
console.log('done');
});
});
I tried using this but it doesn't work:
const writeFile = util.promisify(require("fs").writeFile);
await writeFile("bump-minor.json", "contents");
console.log('done');
It shows the following error on line 2:
Parsing error: Unexpected token writeFile
If I add "async" to the mocha test function:
it.only("should bump the 'minor' version attribute", async () => {
const writeFile = util.promisify(require("fs").writeFile);
return writeFile("bump-minor.json", "contents").then(function() {
console.log('done');
});
});
Then I get this error on line 1:
Parsing error: Unexpected token =>
I'm probably missing some fundamental of how async/await and util.promisify works together in node
Using node 8.7.0.
async
keyword? – skirtle Oct 21 '17 at 12:41