Skip to content

Commit 51a66ee

Browse files
committed
add clear_cache integration test
- yarn run jest -- -t 'jest --clearCache' $ node ./packages/jest-cli/bin/jest.js "-t" "jest --clearCache" PASS integration_tests/__tests__/clear_cache.test.js Test Suites: 165 skipped, 1 passed, 1 of 166 total Tests: 1573 skipped, 1 passed, 1574 total Snapshots: 0 total
1 parent 1312b6c commit 51a66ee

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
3+
*
4+
* This source code is licensed under the BSD-style license found in the
5+
* LICENSE file in the root directory of this source tree. An additional grant
6+
* of patent rights can be found in the PATENTS file in the same directory.
7+
*
8+
* @flow
9+
*/
10+
'use strict';
11+
12+
const fs = require('fs');
13+
const os = require('os');
14+
const path = require('path');
15+
const {cleanup, writeFiles} = require('../utils');
16+
const runJest = require('../runJest');
17+
const skipOnWindows = require('../../scripts/skip_on_windows');
18+
19+
const CACHE = path.resolve(os.tmpdir(), 'clear_cache_directory');
20+
const DIR = path.resolve(os.tmpdir(), 'clear_cache');
21+
22+
skipOnWindows.suite();
23+
24+
beforeEach(() => cleanup(DIR));
25+
afterAll(() => cleanup(DIR));
26+
27+
describe('jest --clearCache', () => {
28+
test('clearing cache results in exit status 0', () => {
29+
writeFiles(DIR, {
30+
'.watchmanconfig': '',
31+
'package.json': '{}',
32+
});
33+
34+
const {status, stdout, stderr} = runJest(DIR, [
35+
'--clearCache',
36+
`--cacheDirectory=${CACHE}`,
37+
]);
38+
39+
expect(fs.existsSync(CACHE)).toBe(false);
40+
expect(stdout).toBe(`Cleared ${CACHE}\n`);
41+
expect(stderr.trim()).toBe('');
42+
expect(status).toBe(0);
43+
});
44+
});

0 commit comments

Comments
 (0)