A real version of this will be released soon that can then be installed using npm/yarn.
Last active
February 6, 2020 00:54
-
-
Save silkentrance/f0e1ff1d689891e124e2a8b73bd31299 to your computer and use it in GitHub Desktop.
A jest test environment for use with node tmp - temporary work around for https://github.com/raszi/node-tmp/issues/229
This file contains 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 characters
module.exports = { | |
testEnvironment: './test/util/TmpEnvironment' // change this to the location where you put TmpEnvironment.js | |
} |
This file contains 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 characters
// you can access tmp directly from global scope | |
const t = tmp.fileSync(); |
This file contains 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 characters
// NOTE: place this under e.g. test/util/TmpEnvironment.js | |
const NodeEnvironment = require('jest-environment-node'); | |
const tmp = require('tmp'); | |
// you may want to set | |
// tmp.setGracefulCleanup() | |
class TmpEnvironment extends NodeEnvironment { | |
async setup() { | |
await super.setup(); | |
this.global.tmp = tmp; | |
} | |
} | |
module.exports = TmpEnvironment; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for projects that uses typescript: