Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Meta
create-react-app
Commits
31243283
Commit
31243283
authored
7 years ago
by
Joe Haddad
Committed by
GitHub
7 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Add linked modules test (#1913)
parent
f61cba10
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
packages/react-scripts/fixtures/kitchensink/.template.dependencies.json
+2
-1
...-scripts/fixtures/kitchensink/.template.dependencies.json
packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js
+8
-0
...-scripts/fixtures/kitchensink/integration/webpack.test.js
packages/react-scripts/fixtures/kitchensink/src/App.js
+4
-0
packages/react-scripts/fixtures/kitchensink/src/App.js
packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.js
+20
-0
...ixtures/kitchensink/src/features/webpack/LinkedModules.js
packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.test.js
+25
-0
...es/kitchensink/src/features/webpack/LinkedModules.test.js
tasks/e2e-kitchensink.sh
+14
-3
tasks/e2e-kitchensink.sh
with
73 additions
and
4 deletions
+73
-4
packages/react-scripts/fixtures/kitchensink/.template.dependencies.json
+
2
-
1
View file @
31243283
...
...
@@ -5,6 +5,7 @@
"babel-polyfill"
:
"6.20.0"
,
"chai"
:
"3.5.0"
,
"jsdom"
:
"9.8.3"
,
"mocha"
:
"3.2.0"
"mocha"
:
"3.2.0"
,
"test-integrity"
:
"1.0.0"
}
}
This diff is collapsed.
Click to expand it.
packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js
+
8
-
0
View file @
31243283
...
...
@@ -44,6 +44,14 @@ describe('Integration', () => {
);
});
it
(
'
linked modules
'
,
async
()
=>
{
const
doc
=
await
initDOM
(
'
linked-modules
'
);
expect
(
doc
.
getElementById
(
'
feature-linked-modules
'
).
textContent
).
to
.
equal
(
'
2.0.0
'
);
});
it
(
'
svg inclusion
'
,
async
()
=>
{
const
doc
=
await
initDOM
(
'
svg-inclusion
'
);
...
...
This diff is collapsed.
Click to expand it.
packages/react-scripts/fixtures/kitchensink/src/App.js
+
4
-
0
View file @
31243283
...
...
@@ -111,6 +111,10 @@ class App extends Component {
import
(
'
./features/webpack/JsonInclusion
'
).
then
(
f
=>
this
.
setFeature
(
f
.
default
));
break
;
case
'
linked-modules
'
:
import
(
'
./features/webpack/LinkedModules
'
).
then
(
f
=>
this
.
setFeature
(
f
.
default
));
break
;
case
'
node-path
'
:
import
(
'
./features/env/NodePath
'
).
then
(
f
=>
this
.
setFeature
(
f
.
default
));
break
;
...
...
This diff is collapsed.
Click to expand it.
packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.js
0 → 100644
+
20
-
0
View file @
31243283
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import
React
from
'
react
'
;
import
'
./assets/style.css
'
;
import
{
test
,
version
}
from
'
test-integrity
'
;
export
default
()
=>
{
const
v
=
version
();
if
(
!
test
()
||
v
!==
'
2.0.0
'
)
{
throw
new
Error
(
'
Functionality test did not pass.
'
);
}
return
<
p
id
=
"
feature-linked-modules
"
>
{
v
}
<
/p>
;
};
This diff is collapsed.
Click to expand it.
packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.test.js
0 → 100644
+
25
-
0
View file @
31243283
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
import
React
from
'
react
'
;
import
ReactDOM
from
'
react-dom
'
;
import
{
test
,
version
}
from
'
test-integrity
'
;
import
LinkedModules
from
'
./LinkedModules
'
;
describe
(
'
linked modules
'
,
()
=>
{
it
(
'
has integrity
'
,
()
=>
{
expect
(
test
());
expect
(
version
()
===
'
2.0.0
'
);
});
it
(
'
renders without crashing
'
,
()
=>
{
const
div
=
document
.
createElement
(
'
div
'
);
ReactDOM
.
render
(
<
LinkedModules
/>
,
div
);
});
});
This diff is collapsed.
Click to expand it.
tasks/e2e-kitchensink.sh
+
14
-
3
View file @
31243283
...
...
@@ -14,17 +14,18 @@
# Start in tasks/ even if run from root directory
cd
"
$(
dirname
"
$0
"
)
"
# CLI
and app
temporary locations
# CLI
, app, and test module
temporary locations
# http://unix.stackexchange.com/a/84980
temp_cli_path
=
`
mktemp
-d
2>/dev/null
||
mktemp
-d
-t
'temp_cli_path'
`
temp_app_path
=
`
mktemp
-d
2>/dev/null
||
mktemp
-d
-t
'temp_app_path'
`
temp_module_path
=
`
mktemp
-d
2>/dev/null
||
mktemp
-d
-t
'temp_module_path'
`
function
cleanup
{
echo
'Cleaning up.'
ps
-ef
|
grep
'react-scripts'
|
grep
-v
grep
|
awk
'{print $2}'
| xargs
kill
-s
9
cd
"
$root_path
"
# TODO: fix "Device or resource busy" and remove ``|| $CI`
rm
-rf
"
$temp_cli_path
"
$temp_app_path
||
$CI
rm
-rf
"
$temp_cli_path
"
"
$temp_app_path
"
"
$temp_module_path
"
||
$CI
}
# Error messages are redirected to stderr
...
...
@@ -111,17 +112,24 @@ npm install "$cli_path"
cd
$temp_app_path
create_react_app
--scripts-version
=
"
$scripts_path
"
--internal-testing-template
=
"
$root_path
"
/packages/react-scripts/fixtures/kitchensink test-kitchensink
# Install the test module
cd
"
$temp_module_path
"
npm
install
test-integrity@^2.0.1
# ******************************************************************************
# Now that we used create-react-app to create an app depending on react-scripts,
# let's make sure all npm scripts are in the working state.
# ******************************************************************************
# Enter the app directory
cd
test-kitchensink
cd
"
$temp_app_path
/
test-kitchensink
"
# Link to our preset
npm
link
"
$root_path
"
/packages/babel-preset-react-app
# Link to test module
npm
link
"
$temp_module_path
/node_modules/test-integrity"
# Test the build
REACT_APP_SHELL_ENV_MESSAGE
=
fromtheshell
\
NODE_PATH
=
src
\
...
...
@@ -183,6 +191,9 @@ npm link "$root_path"/packages/eslint-config-react-app
npm
link
"
$root_path
"
/packages/react-dev-utils
npm
link
"
$root_path
"
/packages/react-scripts
# Link to test module
npm
link
"
$temp_module_path
/node_modules/test-integrity"
# Test the build
REACT_APP_SHELL_ENV_MESSAGE
=
fromtheshell
\
NODE_PATH
=
src
\
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment