-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
add tests for named-asset-imports plugin #5575
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e78928a
add tests for named-asset-imports plugin
NShahri fc8b25b
add ticketFormats store/saga
NShahri 3086cf5
Merge branch 'master' of github.com:facebook/create-react-app into na…
NShahri 3af34d5
change import to require on test file to avoid using babel when runni…
NShahri 7f89098
remove all babel dependencies as not needed more for running tests
NShahri 148d828
update tests and rename file to index.test.js
NShahri d6c7d36
remove npmignore as it is whitelisted in package.json
NShahri e2c4115
add babel-plugin-named-asset-import tests to e2e
NShahri 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const pluginTester = require('babel-plugin-tester'); | ||
const namedAssetImport = require('./index'); | ||
|
||
pluginTester({ | ||
plugin: namedAssetImport, | ||
pluginOptions: { | ||
loaderMap: { | ||
svg: { | ||
ReactComponent: '@svgr/webpack?-prettier,-svgo![path]', | ||
}, | ||
}, | ||
}, | ||
pluginName: 'named-asset-import', | ||
snapshot: false, | ||
tests: { | ||
defaultImport: { | ||
code: 'import logo from "logo";', | ||
output: 'import logo from "logo";', | ||
}, | ||
namedImport: { | ||
code: 'import { logo } from "logo";', | ||
output: 'import { logo } from "logo";', | ||
}, | ||
namedImportRenamed: { | ||
code: 'import { Url as logo1 } from "logo";', | ||
output: 'import { Url as logo1 } from "logo";', | ||
}, | ||
svgDefaultImport: { | ||
code: 'import logo from "logo.svg";', | ||
output: 'import logo from "logo.svg";', | ||
}, | ||
svgNamedImport: { | ||
code: 'import { logo } from "logo.svg";', | ||
output: 'import { logo } from "logo.svg";', | ||
}, | ||
svgReactComponentNamedImport: { | ||
code: 'import { ReactComponent as logo } from "logo.svg";', | ||
output: | ||
'import { ReactComponent as logo } from "@svgr/webpack?-prettier,-svgo!logo.svg";', | ||
}, | ||
svgMultipleImport: { | ||
code: | ||
'import logo, { logoUrl , ReactComponent as Logo } from "logo.svg";', | ||
output: | ||
'import logo from "logo.svg";\n' + | ||
'import { logoUrl } from "logo.svg";\n' + | ||
'import { ReactComponent as Logo } from "@svgr/webpack?-prettier,-svgo!logo.svg";', | ||
}, | ||
}, | ||
}); |
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 |
---|---|---|
|
@@ -118,6 +118,10 @@ cd packages/react-dev-utils/ | |
yarn test | ||
cd ../.. | ||
|
||
cd packages/babel-plugin-named-asset-import/ | ||
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. @Timer tests run as part of e2e |
||
yarn test | ||
cd ../.. | ||
|
||
cd packages/confusing-browser-globals/ | ||
yarn test | ||
cd ../.. | ||
|
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.
Is there a reason these don't include the file name? Why not
import logo from 'logo.svg';
?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.
The first 3 tests are testing cases when file extension does NOT match to plugin config (
.svg
in here),and rest can cover tests when imported file extension matches to config
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.
svgDefaultImport
covers default import oflogo.svg