forked from tastejs/todomvc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cya.js
105 lines (94 loc) · 2.4 KB
/
cya.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
require('console.table')
const path = require('path')
const fs = require('fs')
const figlet = require('figlet')
const chalk = require('chalk')
const cypress = require('cypress')
const Promise = require('bluebird')
const pluralize = require('pluralize')
const R = require('ramda')
const excludedFrameworks = require('./excluded')
const args = require('minimist')(process.argv.slice(2), {
string: ['framework', 'browser'],
number: 'times',
boolean: 'main', // run list of main apps
boolean: 'problems', // run list of problematic apps
alias: {
framework: 'f',
times: 't',
problems: 'p'
},
default: {
times: 1
}
})
if (typeof args.framework === 'string') {
args.framework = [args.framework]
}
const examplesFolder = path.join(__dirname, '..', 'examples')
const names = fs.readdirSync(examplesFolder)
const allFrameworks = R.difference(names, excludedFrameworks)
const mainFrameworks = [
'backbone',
'dojo',
'react',
'vue',
'angularjs',
'knockback',
'mithril',
'backbone_marionette',
'emberjs',
'canjs',
'ampersand',
'troopjs_require',
'knockoutjs',
'polymer',
'flight'
]
const problematicFrameworks = ['js_of_ocaml', 'flight']
const frameworksToTest = args.framework
? args.framework
: args.main
? mainFrameworks
: args.problems ? problematicFrameworks : allFrameworks
if (R.isEmpty(frameworksToTest)) {
console.log('nothing to test ⚠️')
process.exit(1)
}
console.log('testing %s', pluralize('framework', frameworksToTest.length, true))
if (args.times) {
console.log('running all tests %s', pluralize('time', args.times, true))
}
if (args.browser) {
console.log('in browser %s', args.browser)
}
const testApp = app => {
console.log(
figlet.textSync(app, {
font: 'Varsity'
})
)
const colorFailures = n => (n ? chalk.red(n) : chalk.green(n))
const addColors = R.over(R.lensProp('failures'), colorFailures)
return cypress
.run({
browser: args.browser,
record: true,
key: '6f32e649-6348-4d6e-8ec0-4b57774965d1',
env: {
framework: app,
times: args.times
}
})
.then(R.omit(['screenshots', 'video', 'version']))
.then(R.set(R.lensProp('app'), app))
.then(addColors)
}
Promise.mapSeries(frameworksToTest, testApp)
.then(results => {
console.table('TodoMVC results', results)
})
.catch(e => {
console.error('problem testing frameworks')
console.error(e)
})