forked from qunitjs/qunit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
161 lines (139 loc) · 4.46 KB
/
Gruntfile.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/* eslint-env node */
const fs = require( "fs" );
const path = require( "path" );
const { preprocess } = require( "./build/dist-replace.js" );
var isCI = process.env.CI || process.env.JENKINS_HOME;
module.exports = function( grunt ) {
var connectPort = Number( grunt.option( "connect-port" ) ) || 4000;
grunt.loadNpmTasks( "grunt-contrib-connect" );
grunt.loadNpmTasks( "grunt-contrib-copy" );
grunt.loadNpmTasks( "grunt-contrib-qunit" );
grunt.loadNpmTasks( "grunt-search" );
grunt.initConfig( {
connect: {
base: {
options: {
// grunt-contrib-connect supports 'useAvailablePort' which
// automatically finds a suitable port, but we can't use that here because
// the grunt-contrib-qunit task needs to know the url ahead of time.
port: connectPort,
base: "."
}
}
},
copy: {
options: { process: preprocess },
"src-css": {
src: "src/qunit.css",
dest: "qunit/qunit.css"
}
},
search: {
options: {
// Ensure that the only HTML entities used are those with a special status in XHTML
// and that any common singleton/empty HTML elements end with the XHTML-compliant
// "/>"rather than ">"
searchString: /(&(?!gt|lt|amp|quot)[A-Za-z0-9]+;|<(?:hr|HR|br|BR|input|INPUT)(?![^>]*\/>)(?:\s+[^>]*)?>)/g,
logFormat: "console",
failOnMatch: true
},
xhtml: [
"src/**/*.js"
]
},
qunit: {
all: {
options: {
timeout: 30000,
puppeteer: {
args: isCI ?
// For CI
[ "--no-sandbox" ] :
// For local development
// Allow Docker-based developer environmment to
// inject --no-sandbox as-needed for Chrome.
( process.env.CHROMIUM_FLAGS || "" ).split( " " )
},
inject: [
path.resolve( "./build/coverage-bridge.js" ),
require.resolve( "grunt-contrib-qunit/chrome/bridge" )
],
// @HTML_FILES
urls: [
"test/index.html",
"test/amd.html",
"test/autostart.html",
"test/events-filters.html",
"test/events-in-test.html",
"test/headless.html",
"test/logs.html",
"test/module-skip.html",
"test/module-todo.html",
"test/only-each.html",
"test/overload.html",
"test/performance-mark.html",
"test/preconfigured.html",
"test/reorder.html",
"test/reorderError1.html",
"test/reorderError2.html",
"test/reporter-urlparams.html",
"test/sandboxed-iframe.html",
"test/seed.html",
"test/startError.html",
"test/urlparams-module.html",
"test/urlparams-moduleId.html",
"test/urlparams-testId.html",
"test/webWorker.html",
"test/reporter-html/hidepassed.html?hidepassed=true",
"test/reporter-html/legacy-markup.html",
"test/reporter-html/no-qunit-element.html",
"test/reporter-html/config-testId.html",
"test/reporter-html/urlparams-filter.html",
"test/reporter-html/window-onerror-preexisting-handler.html",
"test/reporter-html/window-onerror.html",
"test/reporter-html/xhtml-escape-details-source.xhtml",
"test/reporter-html/xhtml-config-testId.xhtml"
].map( file => `http://localhost:${connectPort}/${file}` )
}
}
},
"test-on-node": {
files: [
// Sync with test/index.html
"test/main/assert.js",
"test/main/assert-step.js",
"test/main/assert-timeout.js",
"test/main/async.js",
"test/main/deepEqual.js",
"test/main/dump.js",
"test/main/each.js",
"test/main/modules.js",
"test/main/onError.js",
"test/main/onUncaughtException.js",
"test/main/promise.js",
"test/main/setTimeout.js",
"test/main/stack.js",
"test/main/test.js",
"test/main/utilities.js",
// Sync with test/*.html files that also make sense for Node.js
"test/events-in-test.js",
"test/logs.js",
"test/module-skip.js",
"test/module-todo.js",
"test/node/storage-1.js",
"test/node/storage-2.js",
"test/es2018/async-functions.js",
"test/es2018/rejects.js",
"test/es2018/throws.js"
]
}
} );
grunt.event.on( "qunit.coverage", function( file, coverage ) {
var testName = file.split( "/test/" ).pop().replace( ".html", "" ).replace( /[/\\]/g, "--" );
var reportPath = path.join( ".nyc_output", "browser--" + testName + ".json" );
fs.mkdirSync( path.dirname( reportPath ), { recursive: true } );
fs.writeFileSync( reportPath, JSON.stringify( coverage ) + "\n" );
} );
grunt.loadTasks( "build/tasks" );
grunt.registerTask( "test", [ "search", "test-on-node", "connect:base", "qunit" ] );
};