mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-04-27 00:14:57 +08:00
Test module scoping (#2198)
* Correct readme * Add tests * Update README.md
This commit is contained in:
@@ -228,6 +228,25 @@ function verify_env_url {
|
||||
mv package.json.orig package.json
|
||||
}
|
||||
|
||||
function verify_module_scope {
|
||||
# Create stub json file
|
||||
echo "{}" >> sample.json
|
||||
|
||||
# Save App.js, we're going to modify it
|
||||
cp src/App.js src/App.js.bak
|
||||
|
||||
# Add an out of scope import
|
||||
echo "import sampleJson from '../sample'" | cat - src/App.js > src/App.js.temp && mv src/App.js.temp src/App.js
|
||||
|
||||
# Make sure the build fails
|
||||
npm run build; test $? -eq 1 || exit 1
|
||||
# TODO: check for error message
|
||||
|
||||
# Restore App.js
|
||||
rm src/App.js
|
||||
mv src/App.js.bak src/App.js
|
||||
}
|
||||
|
||||
# Enter the app directory
|
||||
cd test-app
|
||||
|
||||
@@ -251,6 +270,9 @@ npm start -- --smoke-test
|
||||
# Test environment handling
|
||||
verify_env_url
|
||||
|
||||
# Test reliance on webpack internals
|
||||
verify_module_scope
|
||||
|
||||
# ******************************************************************************
|
||||
# Finally, let's check that everything still works after ejecting.
|
||||
# ******************************************************************************
|
||||
@@ -287,5 +309,8 @@ npm start -- --smoke-test
|
||||
# Test environment handling
|
||||
verify_env_url
|
||||
|
||||
# Test reliance on webpack internals
|
||||
verify_module_scope
|
||||
|
||||
# Cleanup
|
||||
cleanup
|
||||
|
||||
Reference in New Issue
Block a user