ui5-test-runner 3.3.5 โ†’ 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +9 -16
  2. package/package.json +17 -18
  3. package/src/browsers.js +9 -1
  4. package/src/capabilities/index.js +6 -6
  5. package/src/capabilities/tests/screenshot/index.html +13 -3
  6. package/src/capabilities/tests/screenshot/index.js +11 -5
  7. package/src/capabilities/tests/traces/index.js +1 -1
  8. package/src/coverage.js +51 -42
  9. package/src/defaults/puppeteer.js +10 -20
  10. package/src/defaults/report/progress.js +11 -0
  11. package/src/endpoints.js +8 -0
  12. package/src/get-job-progress.js +9 -0
  13. package/src/inject/opa-iframe-coverage.js +0 -1
  14. package/src/inject/post.js +4 -4
  15. package/src/inject/qunit-hooks.js +18 -2
  16. package/src/inject/qunit-intercept.js +6 -0
  17. package/src/inject/ui5-coverage.js +6 -0
  18. package/src/job-mode.js +0 -1
  19. package/src/job.js +10 -10
  20. package/src/options.js +4 -0
  21. package/src/output.js +56 -24
  22. package/src/qunit-hooks.js +43 -29
  23. package/src/symbols.js +2 -1
  24. package/src/tests.js +6 -1
  25. package/src/add-test-pages.spec.js +0 -95
  26. package/src/browser.spec.js +0 -724
  27. package/src/cors.spec.js +0 -41
  28. package/src/coverage.spec.js +0 -120
  29. package/src/csv-reader.spec.js +0 -42
  30. package/src/csv-writer.spec.js +0 -77
  31. package/src/error.spec.js +0 -17
  32. package/src/get-job-progress.spec.js +0 -175
  33. package/src/inject/post.spec.js +0 -147
  34. package/src/job.spec.js +0 -418
  35. package/src/npm.spec.js +0 -98
  36. package/src/options.spec.js +0 -141
  37. package/src/qunit-hooks.spec.js +0 -747
  38. package/src/simulate.spec.js +0 -547
  39. package/src/timeout.spec.js +0 -39
  40. package/src/tools.spec.js +0 -90
  41. package/src/unhandled.spec.js +0 -63
package/src/job.js CHANGED
@@ -7,7 +7,7 @@ const { name, description, version } = require(join(__dirname, '../package.json'
7
7
  const { getOutput } = require('./output')
8
8
  const { $valueSources, $remoteOnLegacy } = require('./symbols')
9
9
  const { buildAndCheckMode } = require('./job-mode')
10
- const { boolean, integer, timeout, url, arrayOf, regex, percent } = require('./options')
10
+ const { boolean, integer, timeout, url, arrayOf, regex, percent, string } = require('./options')
11
11
 
12
12
  const $status = Symbol('status')
13
13
 
@@ -105,9 +105,10 @@ function getCommand (cwd) {
105
105
  .option('--no-npm-install', '[๐Ÿ’ป๐Ÿ”—๐Ÿงช] Prevent any NPM install (execution may fail if a dependency is missing)')
106
106
  .option('-bt, --browser-close-timeout <timeout>', '[๐Ÿ’ป๐Ÿ”—๐Ÿงช] Maximum waiting time for browser close', timeout, 2000)
107
107
  .option('-br, --browser-retry <count>', '[๐Ÿ’ป๐Ÿ”—๐Ÿงช] Browser instantiation retries : if the command fails unexpectedly, it is re-executed (0 means no retry)', 1)
108
+ .option('-oi, --output-interval <interval>', '[๐Ÿ’ป๐Ÿ”—๐Ÿงช] Interval for reporting progress on non interactive output (CI/CD) (0 means no output)', timeout, 30000)
108
109
 
109
110
  // Common to legacy and url
110
- .option('-qs, --qunit-strict', '[๐Ÿ’ป๐Ÿ”—] Strict mode on qunit execution (fails if no modules declared)', boolean, false)
111
+ .option('--webapp <path>', '[๐Ÿ’ป๐Ÿ”—] Base folder of the web application (relative to cwd)', 'webapp')
111
112
  .option('-pf, --page-filter <regexp>', '[๐Ÿ’ป๐Ÿ”—] Filter out pages not matching the regexp')
112
113
  .option('-pp, --page-params <params>', '[๐Ÿ’ป๐Ÿ”—] Add parameters to page URL')
113
114
  .option('-t, --global-timeout <timeout>', '[๐Ÿ’ป๐Ÿ”—] Limit the pages execution time, fail the page if it takes longer than the timeout (0 means no timeout)', timeout, 0)
@@ -115,7 +116,7 @@ function getCommand (cwd) {
115
116
  .option('--no-screenshot', '[๐Ÿ’ป๐Ÿ”—] Disable screenshots')
116
117
  .option('-st, --screenshot-timeout <timeout>', '[๐Ÿ’ป๐Ÿ”—] Maximum waiting time for browser screenshot', timeout, 5000)
117
118
  .option('-rg, --report-generator <path...>', '[๐Ÿ’ป๐Ÿ”—] Report generator paths (relative to cwd or use $/ for provided ones)', ['$/report.js'])
118
- .option('-pp, --progress-page <path>', '[๐Ÿ’ป๐Ÿ”—] progress page path (relative to cwd or use $/ for provided ones)', '$/report/default.html')
119
+ .option('--progress-page <path>', '[๐Ÿ’ป๐Ÿ”—] progress page path (relative to cwd or use $/ for provided ones)', '$/report/default.html')
119
120
 
120
121
  .option('--coverage [flag]', '[๐Ÿ’ป๐Ÿ”—] Enable or disable code coverage', boolean)
121
122
  .option('--no-coverage', '[๐Ÿ’ป๐Ÿ”—] Disable code coverage')
@@ -135,8 +136,7 @@ function getCommand (cwd) {
135
136
  .option('--libs <lib...>', '[๐Ÿ’ป] Library mapping (<relative>=<path> or <path>)', arrayOf(lib))
136
137
  .option('--mappings <mapping...>', '[๐Ÿ’ป] Custom mapping (<match>=<file|url>(<config>))', arrayOf(mapping))
137
138
  .option('--cache <path>', '[๐Ÿ’ป] Cache UI5 resources locally in the given folder (empty to disable)')
138
- .option('--webapp <path>', '[๐Ÿ’ป] Base folder of the web application (relative to cwd)', 'webapp')
139
- .option('--testsuite <path>', '[๐Ÿ’ป] Path of the testsuite file (relative to webapp)', 'test/testsuite.qunit.html')
139
+ .option('--testsuite <path>', '[๐Ÿ’ป] Path of the testsuite file (relative to webapp, URL parameters are supported)', 'test/testsuite.qunit.html')
140
140
  .option('-w, --watch [flag]', '[๐Ÿ’ป] Monitor the webapp folder and re-execute tests on change', boolean, false)
141
141
 
142
142
  // Specific to coverage in url mode (experimental)
@@ -150,8 +150,8 @@ function getCommand (cwd) {
150
150
  .addOption(new Option('--debug-keep-report', DEBUG_OPTION, boolean).hideHelp())
151
151
  .addOption(new Option('--debug-capabilities-test <name>', DEBUG_OPTION).hideHelp())
152
152
  .addOption(new Option('--debug-capabilities-no-timeout', DEBUG_OPTION, boolean).hideHelp())
153
- .addOption(new Option('--debug-coverage', DEBUG_OPTION, boolean).hideHelp())
154
153
  .addOption(new Option('--debug-coverage-no-custom-fs', DEBUG_OPTION, boolean).hideHelp())
154
+ .addOption(new Option('--debug-verbose <module...>', DEBUG_OPTION, arrayOf(string), []).hideHelp())
155
155
 
156
156
  return command
157
157
  }
@@ -227,7 +227,9 @@ function finalize (job) {
227
227
  job.mode = buildAndCheckMode(job)
228
228
  if (job.mode === 'legacy') {
229
229
  checkAccess({ path: job.webapp, label: 'webapp folder' })
230
- const testsuitePath = toAbsolute(job.testsuite, job.webapp)
230
+
231
+ const [, testsuiteFile] = job.testsuite.match(/([^?]*)(\?.*)?$/)
232
+ const testsuitePath = toAbsolute(testsuiteFile, job.webapp)
231
233
  checkAccess({ path: testsuitePath, label: 'testsuite', file: true })
232
234
  } else if (job.mode === 'url') {
233
235
  if (job[$valueSources].coverage !== 'cli') {
@@ -261,9 +263,7 @@ function finalize (job) {
261
263
  if (job.coverage) {
262
264
  function overrideIfNotSet (option, valueFromSettings) {
263
265
  if (valueFromSettings && job[$valueSources][option] !== 'cli') {
264
- if (job.debugCoverage) {
265
- output.wrap(() => console.log(`${option} extracted from nyc settings : ${valueFromSettings}`))
266
- }
266
+ output.debug('coverage', `${option} extracted from nyc settings : ${valueFromSettings}`)
267
267
  job[option] = valueFromSettings
268
268
  }
269
269
  }
package/src/options.js CHANGED
@@ -41,6 +41,10 @@ module.exports = {
41
41
 
42
42
  integer,
43
43
 
44
+ string (value) {
45
+ return value
46
+ },
47
+
44
48
  timeout (value) {
45
49
  const int = integer(value)
46
50
  if (value.endsWith('ms')) {
package/src/output.js CHANGED
@@ -14,6 +14,7 @@ const { filename, noop, pad } = require('./tools')
14
14
  const inJest = typeof jest !== 'undefined'
15
15
  const interactive = process.stdout.columns !== undefined && !inJest
16
16
  const $output = Symbol('output')
17
+ const $outputStart = Symbol('output-start')
17
18
 
18
19
  if (!interactive) {
19
20
  const UTF8_BOM_CODE = '\ufeff'
@@ -31,6 +32,15 @@ if (inJest) {
31
32
  cons = console
32
33
  }
33
34
 
35
+ const formatTime = duration => {
36
+ duration = Math.ceil(duration / 1000)
37
+ const seconds = duration % 60
38
+ const minutes = (duration - seconds) / 60
39
+ return minutes.toString().padStart(2, '0') + ':' + seconds.toString().padStart(2, '0')
40
+ }
41
+
42
+ const getElapsed = job => formatTime(Date.now() - job[$outputStart])
43
+
34
44
  const write = (...parts) => parts.forEach(part => process.stdout.write(part))
35
45
 
36
46
  function clean (job) {
@@ -84,8 +94,16 @@ function bar (ratio, msg) {
84
94
  const TICKS = ['\u280b', '\u2819', '\u2839', '\u2838', '\u283c', '\u2834', '\u2826', '\u2827', '\u2807', '\u280f']
85
95
 
86
96
  function progress (job, cleanFirst = true) {
87
- if (cleanFirst) {
88
- clean(job)
97
+ if (interactive) {
98
+ if (cleanFirst) {
99
+ clean(job)
100
+ }
101
+ } else {
102
+ if (job[$browsers]) {
103
+ write(`${getElapsed(job)} โ”‚ Progress\nโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€\n`)
104
+ } else {
105
+ return
106
+ }
89
107
  }
90
108
  const output = job[$output]
91
109
  output.lines = 1
@@ -131,11 +149,26 @@ function progress (job, cleanFirst = true) {
131
149
  }
132
150
  }
133
151
 
134
- function output (job, ...texts) {
135
- writeFileSync(join(job.reportDir, 'output.txt'), texts.map(t => t.toString()).join(' ') + '\n', {
136
- encoding: 'utf-8',
137
- flag: 'a'
138
- })
152
+ function output (job, ...args) {
153
+ writeFileSync(
154
+ join(job.reportDir, 'output.txt'),
155
+ args.map(arg => {
156
+ if (typeof arg === 'object') {
157
+ return JSON.stringify(arg, undefined, 2)
158
+ }
159
+ if (arg === undefined) {
160
+ return 'undefined'
161
+ }
162
+ if (arg === null) {
163
+ return 'null'
164
+ }
165
+ return arg.toString()
166
+ }).join(' ') + '\n',
167
+ {
168
+ encoding: 'utf-8',
169
+ flag: 'a'
170
+ }
171
+ )
139
172
  }
140
173
 
141
174
  function log (job, ...texts) {
@@ -185,13 +218,6 @@ function browserIssue (job, { type, url, code, dir }) {
185
218
  log(job, p`โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€${pad.x('โ”€')}โ”˜`)
186
219
  }
187
220
 
188
- const formatTime = duration => {
189
- duration = Math.ceil(duration / 1000)
190
- const seconds = duration % 60
191
- const minutes = (duration - seconds) / 60
192
- return minutes.toString().padStart(2, '0') + ':' + seconds.toString().padStart(2, '0')
193
- }
194
-
195
221
  function build (job) {
196
222
  let wrap
197
223
  if (interactive) {
@@ -206,8 +232,7 @@ function build (job) {
206
232
  } else {
207
233
  wrap = method => method
208
234
  }
209
- const outputStart = Date.now()
210
- const getElapsed = () => formatTime(Date.now() - outputStart)
235
+ job[$outputStart] = Date.now()
211
236
 
212
237
  return {
213
238
  lastTick: 0,
@@ -225,6 +250,13 @@ function build (job) {
225
250
  log(job, p80()`Server running at ${pad.lt(url)}`)
226
251
  },
227
252
 
253
+ debug: wrap((module, ...args) => {
254
+ if (job.debugVerbose && job.debugVerbose.includes(module)) {
255
+ console.log(`๐Ÿž${module}`, ...args)
256
+ output(job, `๐Ÿž${module}`, ...args)
257
+ }
258
+ }),
259
+
228
260
  redirected: wrap(({ method, url, statusCode, timeSpent }) => {
229
261
  if (url.startsWith('/_/progress')) {
230
262
  return // avoids pollution
@@ -245,7 +277,7 @@ function build (job) {
245
277
  } else {
246
278
  method = log
247
279
  }
248
- const text = `${getElapsed()} โ”‚ ${status}`
280
+ const text = `${getElapsed(job)} โ”‚ ${status}`
249
281
  method(job, '')
250
282
  method(job, text)
251
283
  method(job, 'โ”€โ”€โ”€โ”€โ”€โ”€โ”ด'.padEnd(text.length, 'โ”€'))
@@ -262,6 +294,8 @@ function build (job) {
262
294
  reportOnJobProgress () {
263
295
  if (interactive) {
264
296
  this.reportIntervalId = setInterval(progress.bind(null, job), 250)
297
+ } else if (job.outputInterval) {
298
+ this.reportIntervalId = setInterval(progress.bind(null, job), job.outputInterval)
265
299
  }
266
300
  },
267
301
 
@@ -305,7 +339,7 @@ function build (job) {
305
339
  },
306
340
 
307
341
  browserStart (url) {
308
- const text = p80()`${getElapsed()} >> ${pad.lt(url)} [${filename(url)}]`
342
+ const text = p80()`${getElapsed(job)} >> ${pad.lt(url)} [${filename(url)}]`
309
343
  if (interactive) {
310
344
  output(job, text)
311
345
  } else {
@@ -319,7 +353,7 @@ function build (job) {
319
353
  if (page) {
320
354
  duration = ' (' + formatTime(page.end - page.start) + ')'
321
355
  }
322
- const text = p80()`${getElapsed()} << ${pad.lt(url)} ${duration} [${filename(url)}]`
356
+ const text = p80()`${getElapsed(job)} << ${pad.lt(url)} ${duration} [${filename(url)}]`
323
357
  if (interactive) {
324
358
  output(job, text)
325
359
  } else {
@@ -412,10 +446,6 @@ function build (job) {
412
446
  log(job, p80()`Skipping nyc instrumentation (--url)`)
413
447
  }),
414
448
 
415
- qunitEarlyStart: wrap(url => {
416
- log(job, p80()`QUnit start without tests in ${pad.lt(url)}`)
417
- }),
418
-
419
449
  endpointError: wrap(({ api, url, data, error }) => {
420
450
  const p = p80()
421
451
  log(job, p`โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€${pad.x('โ”€')}โ”`)
@@ -508,7 +538,9 @@ function build (job) {
508
538
  stop () {
509
539
  if (this.reportIntervalId) {
510
540
  clearInterval(this.reportIntervalId)
511
- clean(job)
541
+ if (interactive) {
542
+ clean(job)
543
+ }
512
544
  }
513
545
  }
514
546
  }
@@ -17,12 +17,38 @@ function invalidTestId (job, url, testId) {
17
17
  error(job, url, `No QUnit unit test found with id ${testId}`)
18
18
  }
19
19
 
20
- function get (job, urlWithHash, testId) {
20
+ function merge (targetModules, modules) {
21
+ let count = 0
22
+ modules.forEach(module => {
23
+ const { name } = module
24
+ const targetModule = targetModules.filter(({ name: targetName }) => name === targetName)[0]
25
+ if (targetModule === undefined) {
26
+ targetModules.push(module)
27
+ } else {
28
+ module.tests.forEach(test => {
29
+ const targetTest = targetModule.tests.filter(({ testId }) => test.testId === testId)[0]
30
+ if (!targetTest) {
31
+ targetModule.tests.push(test)
32
+ }
33
+ })
34
+ }
35
+ count += module.tests.length
36
+ })
37
+ return count
38
+ }
39
+
40
+ function get (job, urlWithHash, { testId, modules, isOpa } = {}) {
21
41
  const url = stripUrlHash(urlWithHash)
22
42
  const page = job.qunitPages && job.qunitPages[url]
23
43
  if (!page) {
24
44
  error(job, url, `No QUnit page found for ${urlWithHash}`)
25
45
  }
46
+ if (modules && modules.length) {
47
+ page.count = merge(page.modules, modules)
48
+ }
49
+ if (!page.isOpa && isOpa) {
50
+ page.isOpa = true
51
+ }
26
52
  let testModule
27
53
  let test
28
54
  if (testId !== undefined) {
@@ -35,7 +61,7 @@ function get (job, urlWithHash, testId) {
35
61
  return false
36
62
  }
37
63
  })
38
- if (!test && job.qunitStrict) {
64
+ if (!test) {
39
65
  invalidTestId(job, url, testId)
40
66
  }
41
67
  }
@@ -44,7 +70,7 @@ function get (job, urlWithHash, testId) {
44
70
 
45
71
  async function done (job, urlWithHash, report) {
46
72
  const { url, page } = get(job, urlWithHash)
47
- if (page.earlyStart && page.count === 0) {
73
+ if (page.count === 0) {
48
74
  return // wait
49
75
  }
50
76
  if (job.browserCapabilities.screenshot) {
@@ -66,15 +92,10 @@ async function done (job, urlWithHash, report) {
66
92
  module.exports = {
67
93
  get,
68
94
 
69
- async begin (job, urlWithHash, { isOpa, totalTests, modules }) {
95
+ async begin (job, urlWithHash, details) {
96
+ getOutput(job).debug('qunit', 'begin', urlWithHash, details)
97
+ const { isOpa, totalTests, modules } = details
70
98
  const url = stripUrlHash(urlWithHash)
71
- const earlyStart = !totalTests || !modules
72
- if (earlyStart) {
73
- getOutput(job).qunitEarlyStart(url)
74
- if (job.qunitStrict) {
75
- error(job, url, 'Invalid begin hook details')
76
- }
77
- }
78
99
  if (!job.qunitPages) {
79
100
  job.qunitPages = {}
80
101
  }
@@ -87,28 +108,19 @@ module.exports = {
87
108
  count: totalTests,
88
109
  modules
89
110
  }
90
- if (earlyStart) {
91
- qunitPage.earlyStart = true
92
- }
93
111
  job.qunitPages[url] = qunitPage
94
112
  },
95
113
 
96
- async testStart (job, urlWithHash, { module, name, testId }) {
97
- let { page, testModule, test } = get(job, urlWithHash, testId)
98
- if (!testModule) {
99
- testModule = { name: module, tests: [] }
100
- page.modules.push(testModule)
101
- }
102
- if (!test) {
103
- test = { name, testId }
104
- testModule.tests.push(test)
105
- ++page.count
106
- }
114
+ async testStart (job, urlWithHash, details) {
115
+ getOutput(job).debug('qunit', 'testStart', urlWithHash, details)
116
+ const { test } = get(job, urlWithHash, details)
107
117
  test.start = new Date()
108
118
  },
109
119
 
110
- async log (job, urlWithHash, { module, name, testId, ...log }) {
111
- const { url, page, test } = get(job, urlWithHash, testId)
120
+ async log (job, urlWithHash, details) {
121
+ getOutput(job).debug('qunit', 'log', urlWithHash, details)
122
+ const { url, page, test } = get(job, urlWithHash, details)
123
+ const { isOpa, modules, module, name, testId, ...log } = details
112
124
  if (!test) {
113
125
  invalidTestId(job, url, testId)
114
126
  }
@@ -126,9 +138,11 @@ module.exports = {
126
138
  }
127
139
  },
128
140
 
129
- async testDone (job, urlWithHash, { name, module, testId, assertions, ...report }) {
141
+ async testDone (job, urlWithHash, details) {
142
+ getOutput(job).debug('qunit', 'testDone', urlWithHash, details)
143
+ const { name, module, testId, assertions, ...report } = details
130
144
  const { failed } = report
131
- const { url, page, test } = get(job, urlWithHash, testId)
145
+ const { url, page, test } = get(job, urlWithHash, { testId })
132
146
  if (!test) {
133
147
  invalidTestId(job, url, testId)
134
148
  }
package/src/symbols.js CHANGED
@@ -5,5 +5,6 @@ module.exports = {
5
5
  $testPagesStarted: Symbol('testPagesStarted'),
6
6
  $testPagesCompleted: Symbol('testPagesCompleted'),
7
7
  $valueSources: Symbol('valueSources'),
8
- $remoteOnLegacy: Symbol('remoteOnLegacy')
8
+ $remoteOnLegacy: Symbol('remoteOnLegacy'),
9
+ $proxifiedUrls: Symbol('proxifiedUrls')
9
10
  }
package/src/tests.js CHANGED
@@ -13,6 +13,7 @@ const {
13
13
  $testPagesCompleted
14
14
  } = require('./symbols')
15
15
  const { UTRError } = require('./error')
16
+ const { $proxifiedUrls } = require('./symbols')
16
17
 
17
18
  async function run (task, job) {
18
19
  const {
@@ -70,7 +71,7 @@ async function runTestPage (job, url) {
70
71
  const output = getOutput(job)
71
72
  try {
72
73
  let scripts
73
- if (job.mode === 'url' && job.browserCapabilities.scripts) {
74
+ if (job.browserCapabilities.scripts) {
74
75
  scripts = [
75
76
  'post.js',
76
77
  'qunit-intercept.js',
@@ -86,6 +87,10 @@ async function runTestPage (job, url) {
86
87
  if (job.coverageProxy) {
87
88
  const { origin } = new URL(url)
88
89
  const proxifiedUrl = url.replace(origin, `http://localhost:${job.port}`)
90
+ if (!job[$proxifiedUrls]) {
91
+ job[$proxifiedUrls] = {}
92
+ }
93
+ job[$proxifiedUrls][proxifiedUrl] = url
89
94
  await start(job, proxifiedUrl, scripts)
90
95
  job.qunitPages[url] = job.qunitPages[proxifiedUrl]
91
96
  delete job.qunitPages[proxifiedUrl]
@@ -1,95 +0,0 @@
1
- jest.mock('./browsers.js', () => ({
2
- stop: jest.fn()
3
- }))
4
- const { stop } = require('./browsers')
5
- const { join } = require('path')
6
- const { createDir } = require('./tools')
7
-
8
- const {
9
- addTestPages
10
- } = require('./add-test-pages')
11
-
12
- describe('src/add-test-pages', () => {
13
- const url = 'http://localhost:8045/index.html'
14
- const reportDir = join(__dirname, '../tmp/add-test-pages')
15
- let job
16
-
17
- beforeAll(() => createDir(reportDir))
18
-
19
- beforeEach(() => {
20
- stop.mockClear()
21
- job = {
22
- reportDir
23
- }
24
- })
25
-
26
- describe('addTestPages', () => {
27
- it('keeps track of added test pages and stops browser', async () => {
28
- await addTestPages(job, url, [
29
- '/page1.html',
30
- 'page2.html'
31
- ])
32
- expect(job.testPageUrls).toEqual([
33
- 'http://localhost:8045/page1.html',
34
- 'http://localhost:8045/page2.html'
35
- ])
36
- expect(stop).toHaveBeenCalledWith(job, url)
37
- })
38
-
39
- it('supports regexp filtering', async () => {
40
- job.pageFilter = 'page(1|3)'
41
- await addTestPages(job, url, [
42
- '/page1.html',
43
- 'page2.html',
44
- 'page3.html'
45
- ])
46
- expect(job.testPageUrls).toEqual([
47
- 'http://localhost:8045/page1.html',
48
- 'http://localhost:8045/page3.html'
49
- ])
50
- expect(stop).toHaveBeenCalledWith(job, url)
51
- })
52
-
53
- it('supports parameters injection', async () => {
54
- job.pageParams = 'a&b'
55
- await addTestPages(job, url, [
56
- '/page1.html',
57
- 'page2.html?test'
58
- ])
59
- expect(job.testPageUrls).toEqual([
60
- 'http://localhost:8045/page1.html?a&b',
61
- 'http://localhost:8045/page2.html?test&a&b'
62
- ])
63
- expect(stop).toHaveBeenCalledWith(job, url)
64
- })
65
-
66
- it('filters out duplicates', async () => {
67
- await addTestPages(job, url, [
68
- '/page1.html',
69
- 'page1.html'
70
- ])
71
- expect(job.testPageUrls).toEqual([
72
- 'http://localhost:8045/page1.html'
73
- ])
74
- expect(stop).toHaveBeenCalledWith(job, url)
75
- })
76
-
77
- it('supports multiple calls', async () => {
78
- await addTestPages(job, url, ['/page1.html'])
79
- await addTestPages(job, url, ['page1.html', '/page2.html'])
80
- expect(job.testPageUrls).toEqual([
81
- 'http://localhost:8045/page1.html',
82
- 'http://localhost:8045/page2.html'
83
- ])
84
- })
85
-
86
- it('supports absolute urls', async () => {
87
- await addTestPages(job, url, ['/page1.html'])
88
- await addTestPages(job, url, ['http://localhost:8045/page2.html'])
89
- expect(job.testPageUrls).toEqual([
90
- 'http://localhost:8045/page1.html',
91
- 'http://localhost:8045/page2.html'
92
- ])
93
- })
94
- })
95
- })