Added the jest-junit reporter. (#11047)
This commit is contained in:
@@ -7,39 +7,42 @@ const dirPrefixTmp = 'brave-browser-test-calculate-file-checksum-'
|
||||
const testFile1Name = 'file1'
|
||||
const testFile1InitialContent = 'this is a test'
|
||||
const encoding = 'utf8'
|
||||
let testDirPath, testFile1Path
|
||||
|
||||
beforeEach(async function () {
|
||||
// Test directory
|
||||
testDirPath = await fs.mkdtemp(path.join(os.tmpdir(), dirPrefixTmp))
|
||||
// Initial test file
|
||||
testFile1Path = path.join(testDirPath, testFile1Name)
|
||||
await fs.writeFile(testFile1Path, testFile1InitialContent, encoding)
|
||||
})
|
||||
describe('calculateFileChecksum', function() {
|
||||
let testDirPath, testFile1Path
|
||||
|
||||
afterEach(async function () {
|
||||
// Remove test directory
|
||||
try {
|
||||
await fs.remove(testDirPath)
|
||||
} catch (err) {
|
||||
console.warn('Test cleanup: could not remove temp directory at ' + testDirPath)
|
||||
}
|
||||
})
|
||||
beforeEach(async function () {
|
||||
// Test directory
|
||||
testDirPath = await fs.mkdtemp(path.join(os.tmpdir(), dirPrefixTmp))
|
||||
// Initial test file
|
||||
testFile1Path = path.join(testDirPath, testFile1Name)
|
||||
await fs.writeFile(testFile1Path, testFile1InitialContent, encoding)
|
||||
})
|
||||
|
||||
test('generates a checksum', async function () {
|
||||
const checksum1 = await calculateFileChecksum(testFile1Path)
|
||||
expect(checksum1).toBeTruthy()
|
||||
})
|
||||
afterEach(async function () {
|
||||
// Remove test directory
|
||||
try {
|
||||
await fs.remove(testDirPath)
|
||||
} catch (err) {
|
||||
console.warn('Test cleanup: could not remove temp directory at ' + testDirPath)
|
||||
}
|
||||
})
|
||||
|
||||
test('checksum is stable', async function () {
|
||||
const checksum1 = await calculateFileChecksum(testFile1Path)
|
||||
const checksum2 = await calculateFileChecksum(testFile1Path)
|
||||
expect(checksum2).toBe(checksum1)
|
||||
})
|
||||
test('generates a checksum', async function () {
|
||||
const checksum1 = await calculateFileChecksum(testFile1Path)
|
||||
expect(checksum1).toBeTruthy()
|
||||
})
|
||||
|
||||
test('checksum changes when file contents change', async function () {
|
||||
const checksum1 = await calculateFileChecksum(testFile1Path)
|
||||
await fs.writeFile(testFile1Path, testFile1InitialContent + testFile1InitialContent, encoding)
|
||||
const checksum2 = await calculateFileChecksum(testFile1Path)
|
||||
expect(checksum2).not.toBe(checksum1)
|
||||
test('checksum is stable', async function () {
|
||||
const checksum1 = await calculateFileChecksum(testFile1Path)
|
||||
const checksum2 = await calculateFileChecksum(testFile1Path)
|
||||
expect(checksum2).toBe(checksum1)
|
||||
})
|
||||
|
||||
test('checksum changes when file contents change', async function () {
|
||||
const checksum1 = await calculateFileChecksum(testFile1Path)
|
||||
await fs.writeFile(testFile1Path, testFile1InitialContent + testFile1InitialContent, encoding)
|
||||
const checksum2 = await calculateFileChecksum(testFile1Path)
|
||||
expect(checksum2).not.toBe(checksum1)
|
||||
})
|
||||
})
|
||||
|
||||
Generated
+47
@@ -14888,6 +14888,47 @@
|
||||
"throat": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"jest-junit": {
|
||||
"version": "13.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jest-junit/-/jest-junit-13.0.0.tgz",
|
||||
"integrity": "sha512-JSHR+Dhb32FGJaiKkqsB7AR3OqWKtldLd6ZH2+FJ8D4tsweb8Id8zEVReU4+OlrRO1ZluqJLQEETm+Q6/KilBg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"mkdirp": "^1.0.4",
|
||||
"strip-ansi": "^6.0.1",
|
||||
"uuid": "^8.3.2",
|
||||
"xml": "^1.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-regex": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
|
||||
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
|
||||
"dev": true
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
|
||||
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
|
||||
"dev": true
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
|
||||
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"uuid": {
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"jest-leak-detector": {
|
||||
"version": "26.6.2",
|
||||
"resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-26.6.2.tgz",
|
||||
@@ -23662,6 +23703,12 @@
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.4.tgz",
|
||||
"integrity": "sha512-zP9z6GXm6zC27YtspwH99T3qTG7bBFv2VIkeHstMLrLlDJuzA7tQ5ls3OJ1hOGGCzTQPniNJoHXIAOS0Jljohg=="
|
||||
},
|
||||
"xml": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz",
|
||||
"integrity": "sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=",
|
||||
"dev": true
|
||||
},
|
||||
"xml-name-validator": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz",
|
||||
|
||||
@@ -317,6 +317,7 @@
|
||||
"fs-extra": "8.1.0",
|
||||
"identity-obj-proxy": "3.0.0",
|
||||
"jest": "26.6.3",
|
||||
"jest-junit": "13.0.0",
|
||||
"less": "3.13.1",
|
||||
"less-loader": "4.1.0",
|
||||
"log-update": "3.4.0",
|
||||
|
||||
Reference in New Issue
Block a user