forked from jestjs/jest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclearCache.test.ts
More file actions
35 lines (29 loc) · 1.03 KB
/
clearCache.test.ts
File metadata and controls
35 lines (29 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import fs from 'fs';
import os from 'os';
import path from 'path';
import runJest from '../runJest';
const CACHE = path.resolve(os.tmpdir(), 'clear-cache-directory');
describe('jest --clearCache', () => {
test('normal run results in cache directory being written', () => {
const {status} = runJest('clear-cache', [`--cacheDirectory=${CACHE}`]);
expect(fs.existsSync(CACHE)).toBe(true);
expect(status).toBe(0);
});
test('clearCache results in deleted directory and exit status 0', () => {
expect(fs.existsSync(CACHE)).toBe(true);
const {status, stdout, stderr} = runJest('clear-cache', [
'--clearCache',
`--cacheDirectory=${CACHE}`,
]);
expect(fs.existsSync(CACHE)).toBe(false);
expect(stdout).toBe(`Cleared ${CACHE}`);
expect(stderr).toBe('');
expect(status).toBe(0);
});
});