diff --git a/__tests__/processor/Processor.test.ts b/__tests__/processor/Processor.test.ts index 07cfe8404..7e1904240 100644 --- a/__tests__/processor/Processor.test.ts +++ b/__tests__/processor/Processor.test.ts @@ -7,6 +7,7 @@ import { inspect } from "util"; import { Logger } from "../../src/utils/Logger"; import { IResultsProcessorInput } from "../../src/processor/doc/jest/IResultsProcessorInput"; import { ISubstitute } from "../../src/processor/doc/ISubstitute"; +import { Constants } from "../../src/processor/Constants"; const simplePassingTests: IResultsProcessorInput = require("../__resources__/simplePassingTests.json"); @@ -28,7 +29,7 @@ describe("Processor tests", () => { }); (Processor as any).logger = log; - const processed = Processor.run(simplePassingTests, {log: false}); + const processed = Processor.run(simplePassingTests, { log: false }); expect((log as any).writeStdout).not.toHaveBeenCalled(); expect((log as any).writeStderr).not.toHaveBeenCalled(); }); @@ -88,6 +89,20 @@ describe("Processor tests", () => { expect(processed).toMatchSnapshot(); }); + + it("should create file names correctly when default 'resultDir' is used", async () => { + IO.mkdirsSync = jest.fn( + () => { + // do nothing + } + ); + const processed = Processor.run(simplePassingTests, { resultDir: undefined }); // don't specify result dir + // old version left off the slash after the default result directory + expect(IO.mkdirsSync).toHaveBeenCalledWith(Constants.DEFAULT_RESULTS_DIR + "/css/"); + expect(IO.mkdirsSync).toHaveBeenCalledWith(Constants.DEFAULT_RESULTS_DIR + "/js/"); + }); + + it("should error when called without input", () => { let error; try { diff --git a/__tests__/processor/__snapshots__/Processor.test.ts.snap b/__tests__/processor/__snapshots__/Processor.test.ts.snap index 9ec792a60..8da13c006 100644 --- a/__tests__/processor/__snapshots__/Processor.test.ts.snap +++ b/__tests__/processor/__snapshots__/Processor.test.ts.snap @@ -3,12 +3,12 @@ exports[`Processor tests should accept override html and JSON file name 1`] = ` Object { "jestStareConfig": Object { - "resultDir": "./jest-stare", + "resultDir": "./jest-stare/", "resultHtml": "index.html", "resultJson": "jest-results.json", }, "rawJestStareConfig": "{ - \\"resultDir\\": \\"./jest-stare\\", + \\"resultDir\\": \\"./jest-stare/\\", \\"resultHtml\\": \\"index.html\\", \\"resultJson\\": \\"jest-results.json\\" }", @@ -304,14 +304,14 @@ Object { exports[`Processor tests should accept override html and JSON file name 2`] = ` Object { "jestStareConfig": Object { - "resultDir": "./jest-stare", + "resultDir": "./jest-stare/", "resultHtml": "test.html", "resultJson": "test.json", }, "rawJestStareConfig": "{ \\"resultHtml\\": \\"test.html\\", \\"resultJson\\": \\"test.json\\", - \\"resultDir\\": \\"./jest-stare\\" + \\"resultDir\\": \\"./jest-stare/\\" }", "rawResults": "{ \\"numFailedTestSuites\\": \\"0\\", diff --git a/package.json b/package.json index bc008f7d9..ad97d1cd1 100644 --- a/package.json +++ b/package.json @@ -110,7 +110,6 @@ "testResultsProcessor": "./" }, "jest-stare": { - "resultDir": "results/jest-stare", "additionalResultsProcessors": [ "jest-html-reporter", "jest-junit" diff --git a/src/processor/Config.ts b/src/processor/Config.ts index 2bb917a43..f5a9b9022 100644 --- a/src/processor/Config.ts +++ b/src/processor/Config.ts @@ -18,7 +18,7 @@ export class Config { * @param {IJestStareConfig} mExplicitConfig - explicit configuration * @memberof Config */ - constructor(private mLogger: Logger, private mExplicitConfig: IJestStareConfig, private mProcessParms: IProcessParms) {} + constructor(private mLogger: Logger, private mExplicitConfig: IJestStareConfig, private mProcessParms: IProcessParms) { } /** * Build config from explicit config, package.json, and defaults @@ -47,7 +47,7 @@ export class Config { } if (config.resultDir == null) { - config.resultDir = Constants.DEFAULT_RESULTS_DIR; + config.resultDir = Constants.DEFAULT_RESULTS_DIR + "/"; } else { config.resultDir = config.resultDir + "/"; // append an extra slash in case the user didn't add one }