Skip to content

test(test): remove temp files after test run #960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion @packages/test/src/fix.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import tmp from 'tmp';
import fs from 'fs-extra';
import path from 'path';
import pkgDir from 'pkg-dir';

declare global {
var tmp: typeof import('tmp');
}

export async function bootstrap(fixture?: string, directory?: string) {
const tmpDir = tmp.dirSync({
keep: false,
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
preset: 'ts-jest/presets/js-with-babel',
testEnvironment: 'node',
testEnvironment: './test/tmp-environment.js',
testRegex: undefined,
testMatch: [
'**/*.test.ts?(x)',
Expand Down
16 changes: 16 additions & 0 deletions test/tmp-environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// https://github.com/raszi/node-tmp/issues/229

const NodeEnvironment = require('jest-environment-node');
const tmp = require('tmp');

tmp.setGracefulCleanup();

class TmpEnvironment extends NodeEnvironment {
async setup() {
await super.setup();

this.global.tmp = tmp;
}
}

module.exports = TmpEnvironment;
12 changes: 1 addition & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2036,21 +2036,11 @@
resolved "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==

"@types/node@*":
version "12.0.2"
resolved "https://registry.npmjs.org/@types/node/-/node-12.0.2.tgz#3452a24edf9fea138b48fad4a0a028a683da1e40"
integrity sha512-5tabW/i+9mhrfEOUcLDu2xBPsHJ+X5Orqy9FKpale3SjDA17j5AEpYq5vfy3oAeAHGcvANRCO3NV3d2D6q3NiA==

"@types/[email protected]":
"@types/node@*", "@types/[email protected]", "@types/node@>= 8":
version "12.12.26"
resolved "https://registry.npmjs.org/@types/node/-/node-12.12.26.tgz#213e153babac0ed169d44a6d919501e68f59dea9"
integrity sha512-UmUm94/QZvU5xLcUlNR8hA7Ac+fGpO1EG/a8bcWVz0P0LqtxFmun9Y2bbtuckwGboWJIT70DoWq1r3hb56n3DA==

"@types/node@>= 8":
version "13.5.0"
resolved "https://registry.npmjs.org/@types/node/-/node-13.5.0.tgz#4e498dbf355795a611a87ae5ef811a8660d42662"
integrity sha512-Onhn+z72D2O2Pb2ql2xukJ55rglumsVo1H6Fmyi8mlU9SvKdBk/pUSUAiBY/d9bAOF7VVWajX3sths/+g6ZiAQ==

"@types/normalize-package-data@^2.4.0":
version "2.4.0"
resolved "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"
Expand Down