Skip to content

Commit da4c6e7

Browse files
committed
3.4.0 Add Fixtures for Easier Compares
1 parent cf6d197 commit da4c6e7

File tree

112 files changed

+2837
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+2837
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "kitchensink",
3+
"main": "template.json",
4+
"version": "1.0.0"
5+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"package": {
3+
"dependencies": {
4+
"bootstrap": "4.3.1",
5+
"jest": "24.9.0",
6+
"node-sass": "4.12.0",
7+
"normalize.css": "7.0.0",
8+
"prop-types": "15.7.2",
9+
"test-integrity": "2.0.1"
10+
}
11+
}
12+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
REACT_APP_X = x-from-original-env
2+
REACT_APP_ORIGINAL_1 = from-original-env-1
3+
REACT_APP_ORIGINAL_2 = from-original-env-2
4+
REACT_APP_BASIC = basic
5+
REACT_APP_BASIC_EXPAND = ${REACT_APP_BASIC}
6+
REACT_APP_BASIC_EXPAND_SIMPLE = $REACT_APP_BASIC
7+
REACT_APP_EXPAND_EXISTING = $REACT_APP_SHELL_ENV_MESSAGE
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
REACT_APP_X = x-from-development-env
2+
REACT_APP_DEVELOPMENT = development
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
REACT_APP_X = x-from-original-local-env
2+
REACT_APP_ORIGINAL_2 = override-from-original-local-env-2
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
REACT_APP_X = x-from-production-env
2+
REACT_APP_PRODUCTION = production
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[ignore]
2+
<PROJECT_ROOT>/node_modules/fbjs/.*
3+
4+
[include]
5+
6+
[libs]
7+
8+
[options]
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Contributing to Create React App's E2E tests
2+
3+
This is an end to end kitchensink test suite, but has multiple usages in it.
4+
5+
## Running the test suite
6+
7+
Tests are automatically run by the CI tools.
8+
In order to run them locally, without having to manually install and configure everything, the `yarn e2e:docker` CLI command can be used.
9+
10+
This is a script that runs a **Docker** container, where the node version, git branch to clone, test suite, and whether to run it with `yarn` or `npm` can be chosen.
11+
Run `yarn e2e:docker --help` to get additional info.
12+
13+
If you need guidance installing **Docker**, you should follow their [official docs](https://docs.docker.com/engine/installation/).
14+
15+
## Writing tests
16+
17+
Each time a new feature is added, it is advised to add at least one test covering it.
18+
19+
Features are categorized by their scope:
20+
21+
- _env_, all those which deal with environment variables (e.g. `NODE_PATH`)
22+
23+
- _syntax_, all those which showcase a single EcmaScript syntax feature that is expected to be transpiled by **Babel**
24+
25+
- _webpack_, all those which make use of webpack settings, loaders or plugins
26+
27+
### Using it as Unit Tests
28+
29+
In it's most basic for this serve as a collection of unit tests on a single functionality.
30+
31+
Unit tests are written in a `src/features/**/*.test.js` file located in the same folder as the feature they test, and usually consist of a `ReactDOM.render` call.
32+
33+
These tests are run by **jest** and the environment is `test`, so that it resembles how a **Create React App** application is tested.
34+
35+
### Using it as Integration Tests
36+
37+
This suite tests how the single features as before behave while development and in production.
38+
A local HTTP server is started, then every single feature is loaded, one by one, to be tested.
39+
40+
Test are written in `integration/{env|syntax|webpack}.test.js`, depending on their scope.
41+
42+
For every test case added there is only a little chore to do:
43+
44+
- a `case` statement must be added in `src/App.js`, which performs a dynamic `import()` of the feature
45+
46+
- add a test case in the appropriate integration test file, which calls and awaits `initDOM` with the previous `SwitchCase` string
47+
48+
A usual flow for the test itself is something similar to:
49+
50+
- add an `id` attribute in a target HTML tag in the feature itself
51+
52+
- since `initDOM` returns a `Document` element, the previous `id` attribute is used to target the feature's DOM and `expect` accordingly
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# dependencies
4+
node_modules
5+
6+
# testing
7+
coverage
8+
9+
# production
10+
build
11+
12+
# misc
13+
.DS_Store
14+
.env
15+
npm-debug.log
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import initDOM from './initDOM';
9+
10+
describe('Integration', () => {
11+
describe('jsconfig.json/tsconfig.json', () => {
12+
let doc;
13+
14+
afterEach(() => {
15+
doc && doc.defaultView.close();
16+
doc = undefined;
17+
});
18+
19+
it('Supports setting baseUrl to src', async () => {
20+
doc = await initDOM('base-url');
21+
22+
expect(doc.getElementById('feature-base-url').childElementCount).toBe(4);
23+
});
24+
});
25+
});

0 commit comments

Comments
 (0)