-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add clearCache cli command * fix lint issue - sort-keys * clear all projects cacheDirectory - map over all configs * improve wording in arg description * use path.join instead of string concat - rename path arg to directoryPath for less confusion * remove clearDirectory function in favor of rimraf * allow clearCache loop to run before failing with exit 1 * 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 * fix integration test - actually create directory with real test - check for directory, then delete - use rimraf.sync - remove temp var * changes per PR comments * update license headers to MIT * add check for cache_dir before deletion * update license to MIT for pass_with_no_tests.test.js * fix lint error
- Loading branch information
Showing
7 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. 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. | ||
* | ||
* @flow | ||
*/ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const os = require('os'); | ||
const path = require('path'); | ||
const runJest = require('../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}\n`); | ||
expect(stderr.trim()).toBe(''); | ||
expect(status).toBe(0); | ||
}); | ||
}); |
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
11 changes: 11 additions & 0 deletions
11
integration_tests/clear_cache/__tests__/clear_cache.test.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. 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. | ||
* | ||
* @flow | ||
*/ | ||
'use strict'; | ||
|
||
test('stub', () => expect(1).toBe(1)); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"jest": { | ||
"testEnvironment": "node" | ||
} | ||
} |
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
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
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