-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adds modifyBabelConfig #235
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ad7f114
set up modifyBabelConfig in base config and add it to buildConfigs fo…
jaredmcdonald 931af3b
use modifyBabelConfig in jest preprocessor
jaredmcdonald 350c1a0
move call to modifyBabelConfig to config/babel instead of tying it to…
jaredmcdonald 00ffded
add basic test for config/babel
jaredmcdonald db9dce1
test error path for config/babel
jaredmcdonald 835f0a3
improve expectation readability
jaredmcdonald 3b57e11
fix double call of modifyBabelConfig in test preprocessor
jaredmcdonald 5e3dad7
adds test for utils/jest/preprocessor
jaredmcdonald 5c51659
add assertion for the addition of default identity function in kytCon…
jaredmcdonald bb9c7be
don't modify this comment anymore
jaredmcdonald b789da3
add debug option to log out merged babelrc
jaredmcdonald 52965aa
merged -> modified
jaredmcdonald File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const fakeTransformer = {}; | ||
|
||
jest.setMock('babel-jest', { | ||
createTransformer: jest.fn(() => fakeTransformer), | ||
}); | ||
const babelJest = require('babel-jest'); | ||
|
||
const fakeBabelResult = {}; | ||
|
||
jest.setMock('../../../config/babel', jest.fn(() => fakeBabelResult)); | ||
const babel = require('../../../config/babel'); | ||
|
||
describe('preprocessor', () => { | ||
it('calls the babel utility and babel-jest\'s createTransformer', () => { | ||
const preprocessor = require('../preprocessor'); // eslint-disable-line global-require | ||
expect(preprocessor).toBe(fakeTransformer); | ||
expect(babel.mock.calls[0][0]).toEqual({ | ||
type: 'test', | ||
environment: 'test', | ||
}); | ||
expect(babelJest.createTransformer).toBeCalledWith(fakeBabelResult); | ||
}); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for adding this test!! 🙏 |
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 |
---|---|---|
@@ -1,17 +1,10 @@ | ||
const mergeAll = require('ramda').mergeAll; | ||
const babel = require('../../config/babel')(); | ||
const babelJest = require('babel-jest'); | ||
const buildConfigs = require('../buildConfigs'); | ||
const config = require('../kytConfig')(); | ||
|
||
const { clientConfig } = buildConfigs(config); | ||
const options = { | ||
type: 'test', | ||
environment: 'test', | ||
}; | ||
|
||
// Merge userland babel config with our babel config | ||
// This should go away after https://github.com/NYTimes/kyt/issues/134 | ||
const clientBabelConfig = clientConfig.module.loaders | ||
.find(loader => loader.loader === 'babel-loader') | ||
.query; | ||
|
||
const babelConfigForJest = mergeAll([{}, babel, clientBabelConfig]); | ||
const babelConfigForJest = require('../../config/babel')(options); | ||
|
||
module.exports = babelJest.createTransformer(babelConfigForJest); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this just testing Jest's ability to mock?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha yeah I suppose, I'll drop this assertion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
although, wait, I added it to verify that
preprocessor
exports the result ofcreateTransformer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok gotcha!