From be078eea768fb9325bc3067f86cbd8d115b5b9b6 Mon Sep 17 00:00:00 2001 From: Paul Hawxby Date: Thu, 5 Apr 2018 10:26:04 +0100 Subject: [PATCH] Fix broken test --- __tests__/testResultProcessor.test.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/__tests__/testResultProcessor.test.js b/__tests__/testResultProcessor.test.js index 0d0cb25..0216d75 100644 --- a/__tests__/testResultProcessor.test.js +++ b/__tests__/testResultProcessor.test.js @@ -1,11 +1,5 @@ 'use strict'; -const fs = require('fs'); -const libxmljs = require("libxmljs"); -const path = require('path'); - -const testResultProcessor = require('../'); - jest.mock('mkdirp', () => { return Object.assign( {}, @@ -26,16 +20,22 @@ jest.mock('fs', () => { ) }); +const fs = require('fs'); +const libxmljs = require("libxmljs"); +const path = require('path'); + +const testResultProcessor = require('../'); + describe('jest-junit', () => { it('should generate valid xml', () => { const noFailingTestsReport = require('../__mocks__/no-failing-tests.json'); const result = testResultProcessor(noFailingTestsReport); // Ensure fs.writeFileSync is called - expect(fs.writeFileSync.mock.calls.length).toBe(1); + expect(fs.writeFileSync).toHaveBeenCalledTimes(1); // Ensure file would have been generated - expect(fs.writeFileSync.mock.calls[0][0]).toBe(path.resolve('junit.xml')); + expect(fs.writeFileSync).toHaveBeenLastCalledWith(path.resolve('junit.xml'), expect.any(String)); // Ensure generated file is valid xml const xmlDoc = libxmljs.parseXml(fs.writeFileSync.mock.calls[0][1]);