ui5-test-runner 2.0.2 → 2.0.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ui5-test-runner",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Standalone test runner for UI5",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -142,7 +142,7 @@ describe('src/browser', () => {
142
142
  })
143
143
  await probe(job)
144
144
  expect(job.browserCapabilities.modules).toStrictEqual(['reserve', 'dependentModule'])
145
- expect(job.browserModules.reserve).toStrictEqual(join(__dirname, '../node_modules/reserve'))
145
+ expect(job.browserModules.reserve).toStrictEqual('reserve')
146
146
  expect(job.browserModules.dependentModule).toStrictEqual(join(npmGlobal, 'dependentModule'))
147
147
  })
148
148
 
@@ -1,8 +1,10 @@
1
1
  'use strict'
2
2
 
3
+ // Based on specification from llg[.]cubic[.]org/docs/junit/
4
+
3
5
  const { join } = require('path')
4
6
  const { writeFile } = require('fs').promises
5
- const [,, reportDir] = process.argv
7
+ const [, , reportDir] = process.argv
6
8
 
7
9
  const output = []
8
10
  function o (text) {
@@ -38,12 +40,17 @@ async function main () {
38
40
  if (test.skip) {
39
41
  o(' <skipped></skipped>')
40
42
  } else if (test.report.failed) {
41
- const log = test.logs.filter(({ result }) => !result)[0]
42
- o(` <failure
43
+ test.logs
44
+ .filter(({ result }) => !result)
45
+ .forEach(log => {
46
+ o(` <failure
43
47
  message="${xmlEscape(log.message)}"
44
48
  >`)
45
- o(xmlEscape(log.source))
46
- o(' </failure>')
49
+ if (log.source) {
50
+ o(xmlEscape(log.source))
51
+ }
52
+ o(' </failure>')
53
+ })
47
54
  }
48
55
  o(' </testcase>')
49
56
  }
package/src/npm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const { exec } = require('child_process')
2
2
  const { join } = require('path')
3
- const { stat, readFile } = require('fs/promises')
3
+ const { stat } = require('fs/promises')
4
4
  const { UTRError } = require('./error')
5
5
  const { getOutput } = require('./output')
6
6
 
@@ -38,33 +38,40 @@ module.exports = {
38
38
  },
39
39
 
40
40
  async resolvePackage (job, name) {
41
- if (!localRoot) {
42
- [localRoot, globalRoot] = await Promise.all([
43
- npm(job, 'root'),
44
- npm(job, 'root', '--global')
45
- ])
46
- }
47
41
  let modulePath
48
42
  let justInstalled = false
49
- const localPath = join(localRoot, name)
50
- if (await folderExists(localPath)) {
51
- modulePath = localPath
52
- } else {
53
- const globalPath = join(globalRoot, name)
54
- if (!await folderExists(globalPath)) {
55
- if (!job.npmInstall) {
56
- throw UTRError.NPM_DEPENDENCY_NOT_FOUND(name)
43
+ try {
44
+ require(name)
45
+ modulePath = name
46
+ } catch (e) {
47
+ }
48
+ if (!modulePath) {
49
+ if (!localRoot) {
50
+ [localRoot, globalRoot] = await Promise.all([
51
+ npm(job, 'root'),
52
+ npm(job, 'root', '--global')
53
+ ])
54
+ }
55
+ const localPath = join(localRoot, name)
56
+ if (await folderExists(localPath)) {
57
+ modulePath = localPath
58
+ } else {
59
+ const globalPath = join(globalRoot, name)
60
+ if (!await folderExists(globalPath)) {
61
+ if (!job.npmInstall) {
62
+ throw UTRError.NPM_DEPENDENCY_NOT_FOUND(name)
63
+ }
64
+ const previousStatus = job.status
65
+ job.status = `Installing ${name}...`
66
+ await npm(job, 'install', name, '-g')
67
+ justInstalled = true
68
+ job.status = previousStatus
57
69
  }
58
- const previousStatus = job.status
59
- job.status = `Installing ${name}...`
60
- await npm(job, 'install', name, '-g')
61
- justInstalled = true
62
- job.status = previousStatus
70
+ modulePath = globalPath
63
71
  }
64
- modulePath = globalPath
65
72
  }
66
73
  const output = getOutput(job)
67
- const installedPackage = JSON.parse((await readFile(join(modulePath, 'package.json'))).toString())
74
+ const installedPackage = require(join(modulePath, 'package.json'))
68
75
  const { version: installedVersion } = installedPackage
69
76
  output.resolvedPackage(name, modulePath, installedVersion)
70
77
  if (!justInstalled) {
package/src/npm.spec.js CHANGED
@@ -40,7 +40,7 @@ describe('src/npm', () => {
40
40
 
41
41
  it('detects already installed local package', async () => {
42
42
  const path = await resolvePackage(job, 'reserve')
43
- expect(path).toStrictEqual(join(__dirname, '../node_modules/reserve'))
43
+ expect(path).toStrictEqual('reserve')
44
44
  expect(output.resolvedPackage).toHaveBeenCalledTimes(1)
45
45
  expect(output.packageNotLatest).not.toHaveBeenCalled()
46
46
  })