-
-
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.
feat: implement support for transforming snapshot resolvers (#8829)
- Loading branch information
Showing
21 changed files
with
1,181 additions
and
106 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
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
10 changes: 10 additions & 0 deletions
10
e2e/transform/transform-snapshotResolver/__tests__/snapshot.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,10 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
test('snapshots are written to custom location', () => { | ||
expect('foobar').toMatchSnapshot(); | ||
}); |
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,18 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
module.exports = { | ||
presets: [ | ||
'@babel/preset-typescript', | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: {node: 'current'}, | ||
}, | ||
], | ||
], | ||
}; |
22 changes: 22 additions & 0 deletions
22
e2e/transform/transform-snapshotResolver/customSnapshotResolver.ts
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,22 @@ | ||
/** | ||
* 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 {SnapshotResolver} from 'jest-snapshot'; | ||
|
||
const snapshotResolver: SnapshotResolver = { | ||
resolveSnapshotPath: (testPath, snapshotExtension) => | ||
testPath.replace('__tests__', '__snapshots__') + snapshotExtension, | ||
|
||
resolveTestPath: (snapshotFilePath, snapshotExtension) => | ||
snapshotFilePath | ||
.replace('__snapshots__', '__tests__') | ||
.slice(0, -(snapshotExtension || '').length), | ||
|
||
testPathForConsistencyCheck: 'foo/__tests__/bar.test.js', | ||
}; | ||
|
||
export default snapshotResolver; |
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,10 @@ | ||
{ | ||
"jest": { | ||
"testEnvironment": "node", | ||
"snapshotResolver": "<rootDir>/customSnapshotResolver.ts" | ||
}, | ||
"dependencies": { | ||
"@babel/preset-env": "^7.0.0", | ||
"@babel/preset-typescript": "^7.0.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs" | ||
} | ||
} |
Oops, something went wrong.