Skip to content

Commit

Permalink
Fix broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
phawxby committed Apr 5, 2018
1 parent 15c5842 commit be078ee
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions __tests__/testResultProcessor.test.js
Original file line number Diff line number Diff line change
@@ -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(
{},
Expand All @@ -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]);
Expand Down

0 comments on commit be078ee

Please sign in to comment.