8000 Properly display test failures using jest · actions/dependency-review-action@b4ae47c · GitHub
[go: up one dir, main page]

Skip to content

Commit b4ae47c

Browse files
authored
Properly display test failures using jest
1 parent d85edeb commit b4ae47c

File tree

1 file changed

+21
-31
lines changed

1 file changed

+21
-31
lines changed

__tests__/spdx.test.ts

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {expect, test} from '@jest/globals'
1+
import {expect, test, describe} from '@jest/globals'
22
import * as spdx from '../src/spdx'
33

4-
test('satisfiesAny', () => {
4+
describe('satisfiesAny', () => {
55
const units = [
66
{
77
candidate: 'MIT',
@@ -59,17 +59,14 @@ test('satisfiesAny', () => {
5959
]
6060

6161
for (const unit of units) {
62-
let got: boolean = spdx.satisfiesAny(unit.candidate, unit.licenses)
63-
if (got != unit.expected) {
64-
console.log(
65-
`failing unit test inputs: candidate(${unit.candidate}) licenses(${unit.licenses})`
66-
)
67-
}
68-
expect(got).toBe(unit.expected)
62+
const got: boolean = spdx.satisfiesAny(unit.candidate, unit.licenses)
63+
test(`should return ${unit.expected} for ("${unit.candidate}", "${unit.licenses}")`, () => {
64+
expect(got).toBe(unit.expected)
65+
})
6966
}
7067
})
7168

72-
test('satisfiesAll', () => {
69+
describe('satisfiesAll', () => {
7370
const units = [
7471
{
7572
candidate: 'MIT',
@@ -137,17 +134,14 @@ test('satisfiesAll', () => {
137134
]
138135

139136
for (const unit of units) {
140-
let got: boolean = spdx.satisfiesAll(unit.candidate, unit.licenses)
141-
if (got != unit.expected) {
142-
console.log(
143-
`failing unit test inputs: candidate(${unit.candidate}) licenses(${unit.licenses})`
144-
)
145-
}
146-
expect(got).toBe(unit.expected)
137+
const got: boolean = spdx.satisfiesAll(unit.candidate, unit.licenses)
138+
test(`should return ${unit.expected} for ("${unit.candidate}", "${unit.licenses}")`, () => {
139+
expect(got).toBe(unit.expected)
140+
})
147141
}
148142
})
149143

150-
test('satisfies', () => {
144+
describe('satisfies', () => {
151145
const units = [
152146
{
153147
candidate: 'MIT',
@@ -220,17 +214,14 @@ test('satisfies', () => {
220214
]
221215

222216
for (const unit of units) {
223-
let got: boolean = spdx.satisfies(unit.candidate, unit.constraint)
224-
if (got != unit.expected) {
225-
console.log(
226-
`failing unit test inputs: candidateExpr(${unit.candidate}) constraintExpr(${unit.constraint})`
227-
)
228-
}
229-
expect(got).toBe(unit.expected)
217+
const got: boolean = spdx.satisfies(unit.candidate, unit.constraint)
218+
test(`should return ${unit.expected} for ("${unit.candidate}", "${unit.constraint}")`, () => {
219+
expect(got).toBe(unit.expected)
220+
})
230221
}
231222
})
232223

233-
test('isValid', () => {
224+
describe('isValid', () => {
234225
const units = [
235226
{
236227
candidate: 'MIT',
@@ -258,10 +249,9 @@ test('isValid', () => {
258249
}
259250
]
260251
for (const unit of units) {
261-
let got: boolean = spdx.isValid(unit.candidate)
262-
if (got != unit.expected) {
263-
console.log(`failing unit test inputs: candidateExpr(${unit.candidate})`)
264-
}
265-
expect(got).toBe(unit.expected)
252+
const got: boolean = spdx.isValid(unit.candidate)
253+
test(`should return ${unit.expected} for ("${unit.candidate}")`, () => {
254+
expect(got).toBe(unit.expected)
255+
})
266256
}
267257
})

0 commit comments

Comments
 (0)
0