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