Skip to content

Commit 17fba90

Browse files
committed
add script to test against multiple versions
1 parent 43018c4 commit 17fba90

8 files changed

+109
-8897
lines changed

_test-bootstrap.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
/* global it, expect */
3+
'use strict';
4+
var React = require('react');
5+
var testsContext = require.context("./test", true, /\.browser\.(js$|jsx$)/);
6+
7+
if ( typeof __REACT_VERSION__ !== 'undefined' ) {
8+
it('Ensure we are testing against the correct version of React: ' + __REACT_VERSION__, ()=>{
9+
expect(React.version).to.equal(__REACT_VERSION__)
10+
})
11+
}
12+
13+
testsContext.keys().forEach(testsContext);

_test-versions.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
'use strict';
2+
var server = require('karma').server
3+
, webpack = require('webpack')
4+
, webpackConfig = require('./webpack.configs').test;
5+
6+
var plugins = webpackConfig.plugins || [];
7+
8+
webpackConfig.externals = {
9+
'react': 'window.React',
10+
'react/addons': 'window.React'
11+
}
12+
13+
var SUPPORTED_VERSIONS = ["0.12.2", "0.13.0"];
14+
15+
series(SUPPORTED_VERSIONS, function(version, idx, next){
16+
console.log('-------------------------------------------');
17+
console.log('------- Testing React version: ' + version );
18+
console.log('-------------------------------------------');
19+
20+
server.start(
21+
config(version)
22+
, function(exitCode) {
23+
if ( exitCode )
24+
process.exit(exitCode)
25+
26+
next();
27+
});
28+
}, function(){
29+
process.exit(0)
30+
})
31+
32+
function config(version){
33+
34+
webpackConfig.plugins = plugins.concat(
35+
new webpack.DefinePlugin({
36+
'__REACT_VERSION__': JSON.stringify(version),
37+
})
38+
)
39+
40+
return {
41+
42+
basePath: '',
43+
44+
frameworks: ['mocha', 'expect'],
45+
46+
files: [
47+
'./vendor/phantomjs-shim.js',
48+
'https://cdnjs.cloudflare.com/ajax/libs/react/'+ version + '/react-with-addons.js',
49+
'./vendor/sinon-1.10.3.js',
50+
'./vendor/jquery-1.11.2.min.js',
51+
'_test-bootstrap.js',
52+
],
53+
54+
reporters: ['mocha'],
55+
56+
port: 9876,
57+
colors: true,
58+
autoWatch: false,
59+
singleRun: true,
60+
61+
logLevel: 'INFO',
62+
63+
browsers: ['PhantomJS'],
64+
65+
preprocessors: {
66+
'_test-bootstrap.js': ['webpack']
67+
},
68+
69+
webpack: webpackConfig,
70+
webpackServer: {
71+
noInfo: true
72+
}
73+
}
74+
}
75+
76+
77+
function series(versions, iter, cb){
78+
79+
(function next(idx){
80+
if( idx === versions.length)
81+
return cb && cb()
82+
83+
iter(versions[idx], idx, next.bind(null, idx + 1))
84+
85+
})(0)
86+
}

0 commit comments

Comments
 (0)