Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions __tests__/buildJsonResults.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,21 @@ describe('buildJsonResults', () => {
expect(slash(jsonResults.testsuites[1].testsuite[2].testcase[0]._attr.file)).toBe('packages/foobar/path/to/test/__tests__/foo.test.js');
});

it('should expand <rootDir> in filePathPrefix', () => {
// Ignore junit errors for this attribute
// It is added for circle-ci and is known to not generate
// jenkins-compatible junit
ignoreJunitErrors = true;

const noFailingTestsReport = require('../__mocks__/no-failing-tests.json');
jsonResults = buildJsonResults(noFailingTestsReport, '/',
Object.assign({}, constants.DEFAULT_OPTIONS, {
addFileAttribute: "true",
filePathPrefix: "<rootDir>/packages/foobar"
}), '/tmp/project');
expect(slash(jsonResults.testsuites[1].testsuite[2].testcase[0]._attr.file)).toBe('/tmp/project/packages/foobar/path/to/test/__tests__/foo.test.js');
});

it('should show output of console if includeConsoleOutput is true', () => {
const reportWithConsoleOutput = require('../__mocks__/test-with-console-output.json');
jsonResults = buildJsonResults(reportWithConsoleOutput, '/',
Expand Down
4 changes: 3 additions & 1 deletion utils/buildJsonResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,10 @@ module.exports = function (report, appDirectory, options, rootDir = null) {
addErrorTestResult(suite);
}

const filePathPrefix = replaceRootDirInOutput(rootDir, suiteOptions.filePathPrefix);

// Build variables for suite name
const filepath = path.join(suiteOptions.filePathPrefix, path.relative(appDirectory, suite.testFilePath));
const filepath = path.join(filePathPrefix, path.relative(appDirectory, suite.testFilePath));
const filename = path.basename(filepath);
const suiteTitle = suite.testResults[0].ancestorTitles[0];
const displayName = typeof suite.displayName === 'object'
Expand Down
Loading