|
12 | 12 | const fs = require('fs'); |
13 | 13 | const os = require('os'); |
14 | 14 | const path = require('path'); |
15 | | -const {cleanup, writeFiles} = require('../utils'); |
16 | 15 | const runJest = require('../runJest'); |
17 | 16 | const skipOnWindows = require('../../scripts/skip_on_windows'); |
| 17 | +const rimraf = require('rimraf'); |
18 | 18 |
|
19 | 19 | const CACHE = path.resolve(os.tmpdir(), 'clear_cache_directory'); |
20 | | -const DIR = path.resolve(os.tmpdir(), 'clear_cache'); |
21 | 20 |
|
22 | 21 | skipOnWindows.suite(); |
23 | 22 |
|
24 | | -beforeEach(() => cleanup(DIR)); |
25 | | -afterAll(() => cleanup(DIR)); |
26 | | - |
27 | 23 | describe('jest --clearCache', () => { |
28 | | - test('clearing cache results in exit status 0', () => { |
29 | | - writeFiles(DIR, { |
30 | | - '.watchmanconfig': '', |
31 | | - 'package.json': '{}', |
32 | | - }); |
| 24 | + test('normal run results in cache directory being written', () => { |
| 25 | + const {status} = runJest('clear_cache', [`--cacheDirectory=${CACHE}`]); |
33 | 26 |
|
34 | | - const {status, stdout, stderr} = runJest(DIR, [ |
| 27 | + expect(fs.existsSync(CACHE)).toBe(true); |
| 28 | + expect(status).toBe(0); |
| 29 | + }); |
| 30 | + test('clearCache results in deleted directory and exit status 0', () => { |
| 31 | + const {status, stdout, stderr} = runJest('clear_cache', [ |
35 | 32 | '--clearCache', |
36 | 33 | `--cacheDirectory=${CACHE}`, |
37 | 34 | ]); |
|
0 commit comments