Created
May 19, 2021 09:56
-
-
Save marufsiddiqui/b699b9e054357e24b07d80dcb7eb391f to your computer and use it in GitHub Desktop.
Revisions
-
marufsiddiqui created this gist
May 19, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ const fs = require('fs') const _prependNodeDocBlock = filePath => { const docBlock = `/** * @jest-environment node */ ` fs.readFile(filePath, 'utf8', (error, result) => { if (error && error.code !== 'ENOENT') { return console.log(error) } if (result) { const content = docBlock + '\n' + result fs.writeFile(filePath, content, err => { if (!err) { console.log('updated file', filePath) } }) } }) } module.exports = runResults => { for (const testResult of runResults.testResults) { if (!testResult.failureMessage) { _prependNodeDocBlock(testResult.testFilePath) } } return runResults }