Skip to content

Commit

Permalink
Add manual build fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Jan 5, 2017
1 parent 0e6f784 commit bff912e
Show file tree
Hide file tree
Showing 30 changed files with 465 additions and 0 deletions.
49 changes: 49 additions & 0 deletions fixtures/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Manual Testing Fixtures

This folder exists for **React contributors** only.
If you use React you don't need to worry about it.

These fixtures verify that the built React distributions are usable in different environments.
**They are not running automatically.** (At least not yet, feel free to contribute to automate them.)

Run them when you make changes to how we package React, ReactDOM, and addons.

## How to Run

First, build React and the fixtures:

```
cd react
npm run build
cd fixtures
node build-all.js
```

Then run a local server at the root of the repo, e.g.

```
npm i -g pushstate-server
cd ..
pushstate-server .
```

(Too complicated? Send a PR to simplify this :-).

Then open the corresponding URLs, for example:

```
open http://localhost:9000/fixtures/globals.html
open http://localhost:9000/fixtures/requirejs.html
open http://localhost:9000/fixtures/systemjs.html
open http://localhost:9000/fixtures/browserify/index.html
open http://localhost:9000/fixtures/rjs/index.html
open http://localhost:9000/fixtures/systemjs-builder/index.html
open http://localhost:9000/fixtures/webpack/index.html
open http://localhost:9000/fixtures/webpack-alias/index.html
```

You should see two things:

* "Hello World" fading in with an animation.
* No errors in the console.
1 change: 1 addition & 0 deletions fixtures/browserify/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output.js
16 changes: 16 additions & 0 deletions fixtures/browserify/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<html>
<body>
<style>
.example-appear {
opacity: 0.01;
}

.example-appear.example-appear-active {
opacity: 1;
transition: opacity .5s ease-in;
}
</style>
<div id="container"></div>
<script src="output.js"></script>
</body>
</html>
16 changes: 16 additions & 0 deletions fixtures/browserify/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var React = require('react')
var CSSTransitionGroup = require('react-addons-css-transition-group')
var ReactDOM = require('react-dom');

ReactDOM.render(
React.createElement(CSSTransitionGroup, {
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0,
}, React.createElement('h1', null,
'Hello World!'
)),
document.getElementById('container')
);
10 changes: 10 additions & 0 deletions fixtures/browserify/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "webpack-test",
"private": true,
"dependencies": {
"browserify": "^13.3.0"
},
"scripts": {
"build": "rm output.js && NODE_PATH=../../build/packages browserify ./input.js -o output.js"
}
}
30 changes: 30 additions & 0 deletions fixtures/build-all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
var fs = require('fs');
var path = require('path');
var { spawnSync } = require('child_process');

var fixtureDirs = fs.readdirSync(__dirname).filter((file) => {
return fs.statSync(path.join(__dirname, file)).isDirectory();
});

var cmdArgs = [
{cmd: 'npm', args: ['install']},
{cmd: 'npm', args: ['run', 'build']}
];

for (const dir of fixtureDirs) {
for (const cmdArg of cmdArgs) {
const opts = {
cwd: path.join(__dirname, dir),
stdio: 'inherit'
};
let result = spawnSync(cmdArg.cmd, cmdArg.args, opts);
if (result.status !== 0) {
throw new Error('Failed to build fixtures.');
}
}
}

console.log('-------------------------');
console.log('All fixtures were built!');
console.log('Now make sure to open each HTML file in this directory and each index.html in subdirectories.');
console.log('-------------------------');
32 changes: 32 additions & 0 deletions fixtures/globals.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<html>
<body>
<script src="../build/react-with-addons.js"></script>
<script src="../build/react-dom.js"></script>
<style>
.example-appear {
opacity: 0.01;
}

.example-appear.example-appear-active {
opacity: 1;
transition: opacity .5s ease-in;
}
</style>
<div id="container"></div>
<script>
var CSSTransitionGroup = React.addons.CSSTransitionGroup;
ReactDOM.render(
React.createElement(CSSTransitionGroup, {
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0,
}, React.createElement('h1', null,
'Hello World!'
)),
document.getElementById('container')
);
</script>
</body>
</html>
40 changes: 40 additions & 0 deletions fixtures/requirejs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<html>
<body>
<script src="https://unpkg.com/requirejs@2.3.2/require.js"></script>
<style>
.example-appear {
opacity: 0.01;
}

.example-appear.example-appear-active {
opacity: 1;
transition: opacity .5s ease-in;
}
</style>
<div id="container"></div>
<script>
requirejs.config({
paths: {
react: '../build/react-with-addons',
'react-dom': '../build/react-dom'
}
});

require(['react', 'react-dom'], function(React, ReactDOM) {
var CSSTransitionGroup = React.addons.CSSTransitionGroup;
ReactDOM.render(
React.createElement(CSSTransitionGroup, {
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0,
}, React.createElement('h1', null,
'Hello World!'
)),
document.getElementById('container')
);
});
</script>
</body>
</html>
1 change: 1 addition & 0 deletions fixtures/rjs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output.js
10 changes: 10 additions & 0 deletions fixtures/rjs/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
({
baseUrl: '.',
name: 'input',
out: 'output.js',
optimize: 'none',
paths: {
react: '../../build/react-with-addons',
'react-dom': '../../build/react-dom'
}
})
17 changes: 17 additions & 0 deletions fixtures/rjs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<html>
<body>
<style>
.example-appear {
opacity: 0.01;
}

.example-appear.example-appear-active {
opacity: 1;
transition: opacity .5s ease-in;
}
</style>
<div id="container"></div>
<script src="https://unpkg.com/requirejs@2.3.2/require.js"></script>
<script src="output.js"></script>
</body>
</html>
15 changes: 15 additions & 0 deletions fixtures/rjs/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require(['react', 'react-dom'], function(React, ReactDOM) {
var CSSTransitionGroup = React.addons.CSSTransitionGroup;
ReactDOM.render(
React.createElement(CSSTransitionGroup, {
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0,
}, React.createElement('h1', null,
'Hello World!'
)),
document.getElementById('container')
);
});
10 changes: 10 additions & 0 deletions fixtures/rjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "rjs-test",
"private": true,
"dependencies": {
"requirejs": "^2.3.2"
},
"scripts": {
"build": "rm output.js && r.js -o config.js"
}
}
1 change: 1 addition & 0 deletions fixtures/systemjs-builder/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output.js
15 changes: 15 additions & 0 deletions fixtures/systemjs-builder/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var path = require("path");
var Builder = require('systemjs-builder');

// optional constructor options
var builder = new Builder('/', './config.js');

builder
.buildStatic('./input.js', './output.js')
.then(function() {
console.log('Build complete');
})
.catch(function(err) {
console.log('Build error');
console.log(err);
});
6 changes: 6 additions & 0 deletions fixtures/systemjs-builder/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
System.config({
paths: {
react: '../../build/react-with-addons.js',
'react-dom': '../../build/react-dom.js'
}
});
16 changes: 16 additions & 0 deletions fixtures/systemjs-builder/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<html>
<body>
<style>
.example-appear {
opacity: 0.01;
}

.example-appear.example-appear-active {
opacity: 1;
transition: opacity .5s ease-in;
}
</style>
<div id="container"></div>
<script src="output.js"></script>
</body>
</html>
16 changes: 16 additions & 0 deletions fixtures/systemjs-builder/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import ReactDOM from 'react-dom';

var CSSTransitionGroup = React.addons.CSSTransitionGroup;
ReactDOM.render(
React.createElement(CSSTransitionGroup, {
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0,
}, React.createElement('h1', null,
'Hello World!'
)),
document.getElementById('container')
);
10 changes: 10 additions & 0 deletions fixtures/systemjs-builder/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "systemjs-builder-test",
"private": true,
"dependencies": {
"systemjs-builder": "^0.15.34"
},
"scripts": {
"build": "rm output.js && node build.js"
}
}
46 changes: 46 additions & 0 deletions fixtures/systemjs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<html>
<body>
<script src="https://unpkg.com/systemjs@0.19.41/dist/system.js"></script>
<style>
.example-appear {
opacity: 0.01;
}

.example-appear.example-appear-active {
opacity: 1;
transition: opacity .5s ease-in;
}
</style>
<div id="container"></div>
<script>
System.config({
paths: {
react: '../build/react-with-addons.js',
'react-dom': '../build/react-dom.js'
}
});

Promise.all([
System.import("react"),
System.import("react-dom")
]).then(function (deps) {
var React = deps[0];
var ReactDOM = deps[1];

var CSSTransitionGroup = React.addons.CSSTransitionGroup;
ReactDOM.render(
React.createElement(CSSTransitionGroup, {
transitionName: 'example',
transitionAppear: true,
transitionAppearTimeout: 500,
transitionEnterTimeout: 0,
transitionLeaveTimeout: 0,
}, React.createElement('h1', null,
'Hello World!'
)),
document.getElementById('container')
);
});
</script>
</body>
</html>
1 change: 1 addition & 0 deletions fixtures/webpack-alias/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output.js
Loading

0 comments on commit bff912e

Please sign in to comment.