diff --git a/.idea/runConfigurations/Integration___All.xml b/.idea/runConfigurations/Integration___All.xml index c4dc8b8..143dddc 100644 --- a/.idea/runConfigurations/Integration___All.xml +++ b/.idea/runConfigurations/Integration___All.xml @@ -1,11 +1,11 @@ - $USER_HOME$/.nvm/versions/node/v6.9.0/bin/node + project $PROJECT_DIR$/test/integration true - + diff --git a/.idea/runConfigurations/Integration___elm_test_extra_simple.xml b/.idea/runConfigurations/Integration___elm_test_extra_simple.xml index 9429342..45b6cc5 100644 --- a/.idea/runConfigurations/Integration___elm_test_extra_simple.xml +++ b/.idea/runConfigurations/Integration___elm_test_extra_simple.xml @@ -1,18 +1,18 @@ - $USER_HOME$/.nvm/versions/node/v6.9.0/bin/node + project $PROJECT_DIR$/test/integration true - + bdd --compilers ts:ts-node/register --timeout 100000 SUITE - $PROJECT_DIR$/test/integration/elm-test-extra/simple/simple.test.ts + $PROJECT_DIR$/test/integration/elm-test-extra/simple.test.ts diff --git a/.idea/runConfigurations/Integration___elm_test_simple.xml b/.idea/runConfigurations/Integration___elm_test_simple.xml index 556b80e..d2372e3 100644 --- a/.idea/runConfigurations/Integration___elm_test_simple.xml +++ b/.idea/runConfigurations/Integration___elm_test_simple.xml @@ -1,18 +1,18 @@ - $USER_HOME$/.nvm/versions/node/v6.9.0/bin/node + project $PROJECT_DIR$/test/integration true - + bdd --compilers ts:ts-node/register --timeout 100000 SUITE - $PROJECT_DIR$/test/integration/elm-test/simple/simple.test.ts + $PROJECT_DIR$/test/integration/elm-test/simple.test.ts diff --git a/.idea/runConfigurations/Unit___Mocha.xml b/.idea/runConfigurations/Unit___Mocha.xml index 2954f13..42a3da9 100644 --- a/.idea/runConfigurations/Unit___Mocha.xml +++ b/.idea/runConfigurations/Unit___Mocha.xml @@ -1,6 +1,6 @@ - $USER_HOME$/.nvm/versions/node/v6.9.0/bin/node + project $PROJECT_DIR$/test/unit true diff --git a/.travis.yml b/.travis.yml index b9d56b4..a35fccc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,8 @@ language: node_js +node_js: + - "6" + cache: directories: - sysconfcpus @@ -9,7 +12,7 @@ os: env: matrix: - - ELM_VERSION=0.18.0 TARGET_NODE_VERSION=node + - ELM_VERSION=0.18.0 before_install: - | # see https://github.com/elm-lang/elm-compiler/issues/1473#issuecomment-245704142 @@ -21,8 +24,6 @@ before_install: make && make install; cd ..; fi - - nvm install $TARGET_NODE_VERSION - - nvm use $TARGET_NODE_VERSION - node --version - npm --version - npm install -g elm@$ELM_VERSION diff --git a/README.md b/README.md index f3f55c1..97220a8 100644 --- a/README.md +++ b/README.md @@ -198,6 +198,10 @@ follows: lobo --testDirectory="test/unit" ``` +### --testFile +Specify the relative path to the main elm tests file within the tests +directory. The default value is "Tests.elm" + ### --verbose Increases the verbosity of lobo logging messages. Please use this when reporting an issue with lobo to get details about what lobo was trying diff --git a/appveyor.yml b/appveyor.yml index c71361b..203b79a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ environment: ELM_VERSION: "0.18.0" matrix: - - nodejs_version: "4.6" + - nodejs_version: "4" platform: - x64 @@ -9,10 +9,17 @@ platform: matrix: fast_finish: true +init: + # report build worker details + - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) + install: + # update node version - ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) $env:Platform - node --version - npm --version + + # install dependencies - npm install -g elm@%ELM_VERSION% - npm install @@ -23,6 +30,10 @@ test_script: - npm run test-ci on_finish: + # pause before completion when $blockRdp is true + - ps: $blockRdp = $false; + + # upload unit test results - ps: | $wc = New-Object 'System.Net.WebClient' Get-ChildItem . -Name -Recurse '*-tests.xml' | diff --git a/lib/builder.ts b/lib/builder.ts index 2a043a5..47fb93d 100644 --- a/lib/builder.ts +++ b/lib/builder.ts @@ -24,7 +24,7 @@ interface ElmPackageCompare { export interface Builder { - build(config: LoboConfig, testDirectory: string): Bluebird; + build(config: LoboConfig, testDirectory: string, testFile: string): Bluebird; } export class BuilderImp implements Builder { @@ -40,11 +40,12 @@ export class BuilderImp implements Builder { this.util = util; } - public build(config: LoboConfig, testDirectory: string): Bluebird { + public build(config: LoboConfig, testDirectory: string, testFile: string): Bluebird { this.logger.info("-----------------------------------[ BUILD ]------------------------------------"); let baseElmPackageDir = "."; let testElmPackageDir = testDirectory; + let testDir = path.dirname(testFile); let steps: Array<() => Bluebird> = []; if (config.noUpdate) { @@ -52,10 +53,10 @@ export class BuilderImp implements Builder { } else { steps = steps.concat([() => this.ensureElmPackageExists(config, baseElmPackageDir, "current"), () => this.ensureElmPackageExists(config, testElmPackageDir, "tests"), - () => this.syncTestElmPackage(config, baseElmPackageDir, testElmPackageDir)]); + () => this.syncTestElmPackage(config, baseElmPackageDir, testElmPackageDir, testDir)]); } - steps = steps.concat([() => this.installDependencies(config, testDirectory), () => this.make(config, testDirectory)]); + steps = steps.concat([() => this.installDependencies(config, testDirectory), () => this.make(config, testDirectory, testFile)]); return Bluebird.mapSeries(steps, item => item()); } @@ -88,9 +89,10 @@ export class BuilderImp implements Builder { }); } - public syncTestElmPackage(config: LoboConfig, baseElmPackageDir: string, testElmPackageDir: string): Bluebird { + public syncTestElmPackage(config: LoboConfig, baseElmPackageDir: string, testElmPackageDir: string, testDir: string): Bluebird { let steps = [() => this.readElmPackage(baseElmPackageDir, testElmPackageDir), - (result: ElmPackageCompare) => this.updateSourceDirectories(config, baseElmPackageDir, result.base, testElmPackageDir, result.test), + (result: ElmPackageCompare) => + this.updateSourceDirectories(config, baseElmPackageDir, result.base, testElmPackageDir, testDir, result.test), (result: ElmPackageCompare) => this.updateDependencies(config, result.base, testElmPackageDir, result.test)]; let value: ElmPackageCompare; @@ -118,10 +120,10 @@ export class BuilderImp implements Builder { } public updateSourceDirectories(config: LoboConfig, baseElmPackageDir: string, baseElmPackage: ElmPackageJson, testElmPackageDir: string, - testElmPackage: ElmPackageJson): Bluebird { + testDir: string, testElmPackage: ElmPackageJson): Bluebird { return new Bluebird((resolve: Resolve, reject: Reject) => { let sourceDirectories = - this.mergeSourceDirectories(baseElmPackage, baseElmPackageDir, testElmPackage, testElmPackageDir, config.testFramework); + this.mergeSourceDirectories(baseElmPackage, baseElmPackageDir, testElmPackage, testElmPackageDir, testDir, config.testFramework); let diff = _.difference(sourceDirectories, testElmPackage.sourceDirectories); if (diff.length === 0) { @@ -207,7 +209,7 @@ export class BuilderImp implements Builder { } public mergeSourceDirectories(baseElmPackage: ElmPackageJson, baseElmPackageDir: string, testElmPackage: ElmPackageJson, - testElmPackageDir: string, testFramework: PluginTestFrameworkWithConfig): string[] { + testElmPackageDir: string, testDir: string, testFramework: PluginTestFrameworkWithConfig): string[] { let sourceDirs: string[] = _.clone(testElmPackage.sourceDirectories); if (!sourceDirs) { @@ -218,6 +220,10 @@ export class BuilderImp implements Builder { sourceDirs.push("."); } + if (sourceDirs.indexOf(testDir) === -1) { + sourceDirs.push(testDir); + } + sourceDirs = this.addSourceDirectories(baseElmPackage.sourceDirectories, baseElmPackageDir, testElmPackageDir, sourceDirs); let dirPath = path.join(__dirname, ".."); @@ -297,6 +303,7 @@ export class BuilderImp implements Builder { try { // run as child process using current process stdio so that colored output is returned let options = {cwd: directory, stdio: [process.stdin, process.stdout, process.stderr]}; + this.logger.trace(command); childProcess.execSync(command, options); resolve(); } catch (err) { @@ -306,7 +313,7 @@ export class BuilderImp implements Builder { } } - public make(config: LoboConfig, testDirectory: string): Bluebird { + public make(config: LoboConfig, testDirectory: string, testFile: string): Bluebird { return new Bluebird((resolve: Resolve, reject: Reject) => { let pluginDirectory = path.resolve(__dirname, "..", "plugin"); let testStuffMainElm = path.join(pluginDirectory, config.testFramework.config.name, config.testMainElm); @@ -316,7 +323,11 @@ export class BuilderImp implements Builder { command = path.join(config.compiler, command); } - command += " " + testStuffMainElm + " --output=" + config.testFile; + if (testFile !== "Tests.elm") { + command += " " + testFile; + } + + command += ` ${testStuffMainElm} --output=${config.testFile}`; if (!config.prompt) { command += " --yes"; @@ -329,12 +340,13 @@ export class BuilderImp implements Builder { try { // run as child process using current process stdio so that colored output is returned let options = {cwd: testDirectory, stdio: [process.stdin, process.stdout, process.stderr]}; + this.logger.trace(command); childProcess.execSync(command, options); resolve(); } catch (err) { - console.log(""); - console.log(Chalk.red.bold(" BUILD FAILED")); - console.log(""); + this.logger.error(""); + this.logger.error(Chalk.bold(" BUILD FAILED")); + this.logger.error(""); this.logger.debug(err); reject(err); } diff --git a/lib/main.ts b/lib/main.ts index ed5b723..2283f20 100755 --- a/lib/main.ts +++ b/lib/main.ts @@ -113,7 +113,7 @@ export class LoboImp implements Lobo { let config = partialConfig; let stages = [ - () => this.builder.build(config, program.testDirectory), + () => this.builder.build(config, program.testDirectory, program.testFile), () => this.runner.run(config) ]; @@ -217,6 +217,7 @@ export class LoboImp implements Lobo { .option("--quiet", "only outputs build info, test summary and errors") .option("--reporter ", "name of the reporter to use", "default-reporter") .option("--testDirectory ", "directory containing the tests to run", "tests") + .option("--testFile ", "location of Tests.elm within the tests directory", "Tests.elm") .option("--verbose", "outputs more detailed logging") .option("--veryVerbose", "outputs very detailed logging") .option("--watch", "watch for file changes and automatically rerun any effected tests"); @@ -307,16 +308,18 @@ export class LoboImp implements Lobo { } } - let testsElm = program.testDirectory + "/Tests.elm"; + let testsElm = path.join(program.testDirectory, program.testFile); if (!shelljs.test("-e", testsElm)) { this.logger.error(""); - this.logger.error("Unable to find \"Tests.elm\""); + this.logger.error(`Unable to find "${path.basename(program.testFile)}"`); this.logger.error("Please check that it exists in the test directory:"); - this.logger.error(path.resolve(program.testDirectory)); + this.logger.error(path.resolve(path.dirname(testsElm))); this.logger.info(""); - this.logger.info("You can override the default location (\"./tests\") by running:"); + this.logger.info("You can override the default location (\"./tests\") by running either:"); this.logger.info("lobo --testDirectory [directory containing Tests.elm]"); + this.logger.info("or"); + this.logger.info("lobo --testFile [relative path to main test file inside --testDirectory]"); exit = true; } diff --git a/lib/test-result-formatter.ts b/lib/test-result-formatter.ts index 9185569..1f3bbe1 100644 --- a/lib/test-result-formatter.ts +++ b/lib/test-result-formatter.ts @@ -82,8 +82,8 @@ export class TestResultFormatterImp implements TestResultFormatter { if (lines[2].indexOf(TestResultFormatterImp.verticalBarMiddle + " ") !== -1) { lines[0] = TestResultFormatterImp.verticalBarStart + " " + lines[0]; - lines[1] = lines[1].replace("╷", TestResultFormatterImp.verticalBarMiddle); - lines[3] = lines[3].replace("╵", TestResultFormatterImp.verticalBarMiddle); + lines[1] = lines[1].replace(/(╵|╷)/, TestResultFormatterImp.verticalBarMiddle); + lines[3] = lines[3].replace(/(╵|╷)/, TestResultFormatterImp.verticalBarMiddle); lines[4] = TestResultFormatterImp.verticalBarEnd + " " + lines[4]; let expectMessage = lines[2].substring(2, lines[2].length); diff --git a/package.json b/package.json index 43f00ab..e97f7f4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lobo", - "version": "0.3.2", + "version": "0.3.3", "description": "Elm test runner", "keywords": [ "elm", diff --git a/plugin/elm-test-extra/plugin-config.ts b/plugin/elm-test-extra/plugin-config.ts index b11500d..aa02f36 100644 --- a/plugin/elm-test-extra/plugin-config.ts +++ b/plugin/elm-test-extra/plugin-config.ts @@ -7,7 +7,11 @@ export class ElmTestExtraConfig implements PluginTestFrameworkConfig { public dependencies: Dependencies = { "benansell/lobo-elm-test-extra": "2.0.0 <= v < 3.0.0", - "elm-community/elm-test": "4.0.0 <= v < 5.0.0", + "eeue56/elm-lazy": "1.0.0 <= v < 2.0.0", + "eeue56/elm-lazy-list": "1.0.0 <= v < 2.0.0", + "eeue56/elm-shrink": "1.0.0 <= v < 2.0.0", + "elm-community/elm-test": "4.2.0 <= v < 5.0.0", + "elm-lang/core": "5.0.0 <= v < 6.0.0", "mgold/elm-random-pcg": "5.0.0 <= v < 6.0.0" }; diff --git a/plugin/elm-test/plugin-config.ts b/plugin/elm-test/plugin-config.ts index 8ac0ec6..a6a6dfb 100644 --- a/plugin/elm-test/plugin-config.ts +++ b/plugin/elm-test/plugin-config.ts @@ -6,7 +6,11 @@ export class ElmTestConfig implements PluginTestFrameworkConfig { public sourceDirectories: string[] = ["runner", "plugin/elm-test"]; public dependencies: Dependencies = { - "elm-community/elm-test": "4.0.0 <= v < 5.0.0", + "eeue56/elm-lazy": "1.0.0 <= v < 2.0.0", + "eeue56/elm-lazy-list": "1.0.0 <= v < 2.0.0", + "eeue56/elm-shrink": "1.0.0 <= v < 2.0.0", + "elm-community/elm-test": "4.2.0 <= v < 5.0.0", + "elm-lang/core": "5.0.0 <= v < 6.0.0", "mgold/elm-random-pcg": "5.0.0 <= v < 6.0.0" }; diff --git a/test/integration/elm-lang/elm-package.json b/test/integration/elm-lang/elm-package.json index 8fae491..5ff6135 100644 --- a/test/integration/elm-lang/elm-package.json +++ b/test/integration/elm-lang/elm-package.json @@ -14,7 +14,6 @@ "elm-lang/geolocation": "1.0.2 <= v < 2.0.0", "elm-lang/html": "2.0.0 <= v < 3.0.0", "elm-lang/keyboard": "1.0.1 <= v < 2.0.0", - "elm-lang/lazy": "2.0.0 <= v < 3.0.0", "elm-lang/mouse": "1.0.1 <= v < 2.0.0", "elm-lang/navigation": "2.0.0 <= v < 3.0.0", "elm-lang/page-visibility": "1.0.1 <= v < 2.0.0", diff --git a/test/integration/elm-lang/src/ImportCheck.elm b/test/integration/elm-lang/src/ImportCheck.elm index 23ada88..bcec60d 100644 --- a/test/integration/elm-lang/src/ImportCheck.elm +++ b/test/integration/elm-lang/src/ImportCheck.elm @@ -6,7 +6,6 @@ import AnimationFrame import Dom import Geolocation import Keyboard -import Lazy import Mouse import Navigation import PageVisibility diff --git a/test/integration/elm-test-extra/performance/performance.test.ts b/test/integration/elm-test-extra/performance.test.ts similarity index 61% rename from test/integration/elm-test-extra/performance/performance.test.ts rename to test/integration/elm-test-extra/performance.test.ts index d0950be..d722ebf 100644 --- a/test/integration/elm-test-extra/performance/performance.test.ts +++ b/test/integration/elm-test-extra/performance.test.ts @@ -1,9 +1,9 @@ "use strict"; import * as chai from "chai"; -import {TestRunner} from "../../lib/test-runner"; -import reporterExpect from "../../lib/default-reporter-expect"; -import {Util} from "../../lib/util"; +import {TestRunner} from "../lib/test-runner"; +import reporterExpect from "../lib/default-reporter-expect"; +import {Util} from "../lib/util"; let expect = chai.expect; @@ -17,21 +17,17 @@ describe("elm-test-extra-performance", () => { util = new Util(); testContext = util.initializeTestContext(__dirname); util.cd(__dirname); + runner.clean(); }); - describe("1000", () => { - beforeEach(() => { - runner.contextPush(testContext, "1000"); - runner.clean(); - }); - - afterEach(() => { - runner.contextPop(testContext); - }); + beforeEach(() => { + runner.cleanBuildArtifacts(); + }); + describe("1000", () => { it("should report success", () => { // act - let result = runner.run(testContext, "elm-test-extra"); + let result = runner.run(testContext, "elm-test-extra", "performance/1000/Tests.elm"); // assert reporterExpect(result).summaryPassed(); diff --git a/test/integration/elm-test-extra/simple/simple.test.ts b/test/integration/elm-test-extra/simple.test.ts similarity index 70% rename from test/integration/elm-test-extra/simple/simple.test.ts rename to test/integration/elm-test-extra/simple.test.ts index ac51546..656a0b7 100644 --- a/test/integration/elm-test-extra/simple/simple.test.ts +++ b/test/integration/elm-test-extra/simple.test.ts @@ -1,9 +1,9 @@ "use strict"; import * as chai from "chai"; -import {TestRunner} from "../../lib/test-runner"; -import reporterExpect from "../../lib/default-reporter-expect"; -import {Util} from "../../lib/util"; +import {TestRunner} from "../lib/test-runner"; +import reporterExpect from "../lib/default-reporter-expect"; +import {Util} from "../lib/util"; let expect = chai.expect; @@ -17,21 +17,17 @@ describe("elm-test-extra-simple", () => { util = new Util(); testContext = util.initializeTestContext(__dirname); util.cd(__dirname); + runner.clean(); }); - describe("pass", () => { - beforeEach(() => { - runner.contextPush(testContext, "pass"); - runner.clean(); - }); - - afterEach(() => { - runner.contextPop(testContext); - }); + beforeEach(() => { + runner.cleanBuildArtifacts(); + }); + describe("pass", () => { it("should report success", () => { // act - let result = runner.run(testContext, "elm-test-extra"); + let result = runner.run(testContext, "elm-test-extra", "simple/pass/Tests.elm"); // assert reporterExpect(result).summaryPassed(); @@ -41,18 +37,15 @@ describe("elm-test-extra-simple", () => { }); describe("fail", () => { - beforeEach(() => { - runner.contextPush(testContext, "fail"); - runner.clean(); - }); + let testDirectory: string; - afterEach(() => { - runner.contextPop(testContext); + beforeEach(() => { + testDirectory = "simple/fail/Tests.elm"; }); it("should report failure", () => { // act - let result = runner.run(testContext, "elm-test-extra"); + let result = runner.run(testContext, "elm-test-extra", testDirectory); // assert reporterExpect(result).summaryFailed(); @@ -62,7 +55,7 @@ describe("elm-test-extra-simple", () => { it("should update message to use ┌ └ instead of ╷ ╵", () => { // act - let result = runner.run(testContext, "elm-test-extra"); + let result = runner.run(testContext, "elm-test-extra", testDirectory); // assert let startIndex = result.stdout @@ -77,7 +70,7 @@ describe("elm-test-extra-simple", () => { it("should update string equals to show diff hint", () => { // act - let result = runner.run(testContext, "elm-test-extra"); + let result = runner.run(testContext, "elm-test-extra", testDirectory); // assert let startIndex = result.stdout @@ -93,18 +86,15 @@ describe("elm-test-extra-simple", () => { }); describe("fuzz", () => { - beforeEach(() => { - runner.contextPush(testContext, "fuzz"); - runner.clean(); - }); + let testDirectory: string; - afterEach(() => { - runner.contextPop(testContext); + beforeEach(() => { + testDirectory = "simple/fuzz/Tests.elm"; }); it("should report success", () => { // act - let result = runner.run(testContext, "elm-test-extra"); + let result = runner.run(testContext, "elm-test-extra", testDirectory); // assert reporterExpect(result).summaryPassed(); @@ -117,7 +107,7 @@ describe("elm-test-extra-simple", () => { let expectedRunCount = 11; // act - let result = runner.run(testContext, "elm-test-extra", "--runCount=" + expectedRunCount); + let result = runner.run(testContext, "elm-test-extra", testDirectory, "--runCount=" + expectedRunCount); // assert reporterExpect(result).summaryPassed(); @@ -139,7 +129,7 @@ describe("elm-test-extra-simple", () => { let initialSeed = 101; // act - let result = runner.run(testContext, "elm-test-extra", "--seed=" + initialSeed); + let result = runner.run(testContext, "elm-test-extra", testDirectory, "--seed=" + initialSeed); // assert reporterExpect(result).summaryPassed(); @@ -150,18 +140,9 @@ describe("elm-test-extra-simple", () => { }); describe("nested", () => { - beforeEach(() => { - runner.contextPush(testContext, "nested"); - runner.clean(); - }); - - afterEach(() => { - runner.contextPop(testContext); - }); - it("should report success", () => { // act - let result = runner.run(testContext, "elm-test-extra"); + let result = runner.run(testContext, "elm-test-extra", "simple/nested/Tests.elm"); // assert reporterExpect(result).summaryPassed(); @@ -171,18 +152,9 @@ describe("elm-test-extra-simple", () => { }); describe("tree", () => { - beforeEach(() => { - runner.contextPush(testContext, "tree"); - runner.clean(); - }); - - afterEach(() => { - runner.contextPop(testContext); - }); - it("should report failure", () => { // act - let result = runner.run(testContext, "elm-test-extra"); + let result = runner.run(testContext, "elm-test-extra", "simple/tree/Tests.elm"); // assert reporterExpect(result).summaryFailed(); @@ -199,18 +171,9 @@ describe("elm-test-extra-simple", () => { }); describe("only", () => { - beforeEach(() => { - runner.contextPush(testContext, "only"); - runner.clean(); - }); - - afterEach(() => { - runner.contextPop(testContext); - }); - it("should report focused passed", () => { // act - let result = runner.run(testContext, "elm-test-extra", "--runCount=5"); + let result = runner.run(testContext, "elm-test-extra", "simple/only/Tests.elm", "--runCount=5"); // assert reporterExpect(result).summaryFocused(); @@ -221,18 +184,9 @@ describe("elm-test-extra-simple", () => { }); describe("skip", () => { - beforeEach(() => { - runner.contextPush(testContext, "skip"); - runner.clean(); - }); - - afterEach(() => { - runner.contextPop(testContext); - }); - it("should report inconclusive", () => { // act - let result = runner.run(testContext, "elm-test-extra"); + let result = runner.run(testContext, "elm-test-extra", "simple/skip/Tests.elm"); // assert reporterExpect(result).summaryInconclusive(); @@ -242,18 +196,9 @@ describe("elm-test-extra-simple", () => { }); describe("todo", () => { - beforeEach(() => { - runner.contextPush(testContext, "todo"); - runner.clean(); - }); - - afterEach(() => { - runner.contextPop(testContext); - }); - it("should report inconclusive", () => { // act - let result = runner.run(testContext, "elm-test-extra"); + let result = runner.run(testContext, "elm-test-extra", "simple/todo/Tests.elm"); // assert reporterExpect(result).summaryInconclusive(); diff --git a/test/integration/elm-test-extra/performance/1000/tests/Tests.elm b/test/integration/elm-test-extra/tests/performance/1000/Tests.elm similarity index 100% rename from test/integration/elm-test-extra/performance/1000/tests/Tests.elm rename to test/integration/elm-test-extra/tests/performance/1000/Tests.elm diff --git a/test/integration/elm-test-extra/simple/fail/tests/Tests.elm b/test/integration/elm-test-extra/tests/simple/fail/Tests.elm similarity index 100% rename from test/integration/elm-test-extra/simple/fail/tests/Tests.elm rename to test/integration/elm-test-extra/tests/simple/fail/Tests.elm diff --git a/test/integration/elm-test-extra/simple/fuzz/tests/Tests.elm b/test/integration/elm-test-extra/tests/simple/fuzz/Tests.elm similarity index 100% rename from test/integration/elm-test-extra/simple/fuzz/tests/Tests.elm rename to test/integration/elm-test-extra/tests/simple/fuzz/Tests.elm diff --git a/test/integration/elm-test-extra/simple/nested/tests/ChildTest.elm b/test/integration/elm-test-extra/tests/simple/nested/ChildTest.elm similarity index 100% rename from test/integration/elm-test-extra/simple/nested/tests/ChildTest.elm rename to test/integration/elm-test-extra/tests/simple/nested/ChildTest.elm diff --git a/test/integration/elm-test-extra/simple/nested/tests/GrandChildTest.elm b/test/integration/elm-test-extra/tests/simple/nested/GrandChildTest.elm similarity index 100% rename from test/integration/elm-test-extra/simple/nested/tests/GrandChildTest.elm rename to test/integration/elm-test-extra/tests/simple/nested/GrandChildTest.elm diff --git a/test/integration/elm-test-extra/simple/nested/tests/Tests.elm b/test/integration/elm-test-extra/tests/simple/nested/Tests.elm similarity index 100% rename from test/integration/elm-test-extra/simple/nested/tests/Tests.elm rename to test/integration/elm-test-extra/tests/simple/nested/Tests.elm diff --git a/test/integration/elm-test-extra/simple/only/tests/Tests.elm b/test/integration/elm-test-extra/tests/simple/only/Tests.elm similarity index 100% rename from test/integration/elm-test-extra/simple/only/tests/Tests.elm rename to test/integration/elm-test-extra/tests/simple/only/Tests.elm diff --git a/test/integration/elm-test-extra/simple/pass/tests/Tests.elm b/test/integration/elm-test-extra/tests/simple/pass/Tests.elm similarity index 100% rename from test/integration/elm-test-extra/simple/pass/tests/Tests.elm rename to test/integration/elm-test-extra/tests/simple/pass/Tests.elm diff --git a/test/integration/elm-test-extra/simple/skip/tests/Tests.elm b/test/integration/elm-test-extra/tests/simple/skip/Tests.elm similarity index 100% rename from test/integration/elm-test-extra/simple/skip/tests/Tests.elm rename to test/integration/elm-test-extra/tests/simple/skip/Tests.elm diff --git a/test/integration/elm-test-extra/simple/todo/tests/Tests.elm b/test/integration/elm-test-extra/tests/simple/todo/Tests.elm similarity index 100% rename from test/integration/elm-test-extra/simple/todo/tests/Tests.elm rename to test/integration/elm-test-extra/tests/simple/todo/Tests.elm diff --git a/test/integration/elm-test-extra/simple/tree/tests/FailingGrandChildTest.elm b/test/integration/elm-test-extra/tests/simple/tree/FailingGrandChildTest.elm similarity index 100% rename from test/integration/elm-test-extra/simple/tree/tests/FailingGrandChildTest.elm rename to test/integration/elm-test-extra/tests/simple/tree/FailingGrandChildTest.elm diff --git a/test/integration/elm-test-extra/simple/tree/tests/FirstChildTest.elm b/test/integration/elm-test-extra/tests/simple/tree/FirstChildTest.elm similarity index 100% rename from test/integration/elm-test-extra/simple/tree/tests/FirstChildTest.elm rename to test/integration/elm-test-extra/tests/simple/tree/FirstChildTest.elm diff --git a/test/integration/elm-test-extra/simple/tree/tests/FuzzyChildTest.elm b/test/integration/elm-test-extra/tests/simple/tree/FuzzyChildTest.elm similarity index 100% rename from test/integration/elm-test-extra/simple/tree/tests/FuzzyChildTest.elm rename to test/integration/elm-test-extra/tests/simple/tree/FuzzyChildTest.elm diff --git a/test/integration/elm-test-extra/simple/tree/tests/PassingGrandChildTest.elm b/test/integration/elm-test-extra/tests/simple/tree/PassingGrandChildTest.elm similarity index 100% rename from test/integration/elm-test-extra/simple/tree/tests/PassingGrandChildTest.elm rename to test/integration/elm-test-extra/tests/simple/tree/PassingGrandChildTest.elm diff --git a/test/integration/elm-test-extra/simple/tree/tests/SecondChildTest.elm b/test/integration/elm-test-extra/tests/simple/tree/SecondChildTest.elm similarity index 100% rename from test/integration/elm-test-extra/simple/tree/tests/SecondChildTest.elm rename to test/integration/elm-test-extra/tests/simple/tree/SecondChildTest.elm diff --git a/test/integration/elm-test-extra/simple/tree/tests/Tests.elm b/test/integration/elm-test-extra/tests/simple/tree/Tests.elm similarity index 100% rename from test/integration/elm-test-extra/simple/tree/tests/Tests.elm rename to test/integration/elm-test-extra/tests/simple/tree/Tests.elm diff --git a/test/integration/elm-test/performance/performance.test.ts b/test/integration/elm-test/performance.test.ts similarity index 61% rename from test/integration/elm-test/performance/performance.test.ts rename to test/integration/elm-test/performance.test.ts index 81fa250..0f0f60e 100644 --- a/test/integration/elm-test/performance/performance.test.ts +++ b/test/integration/elm-test/performance.test.ts @@ -1,9 +1,9 @@ "use strict"; import * as chai from "chai"; -import {TestRunner} from "../../lib/test-runner"; -import reporterExpect from "../../lib/default-reporter-expect"; -import {Util} from "../../lib/util"; +import {TestRunner} from "../lib/test-runner"; +import reporterExpect from "../lib/default-reporter-expect"; +import {Util} from "../lib/util"; let expect = chai.expect; @@ -17,21 +17,17 @@ describe("elm-test-performance", () => { util = new Util(); testContext = util.initializeTestContext(__dirname); util.cd(__dirname); + runner.clean(); }); - describe("1000", () => { - beforeEach(() => { - runner.contextPush(testContext, "1000"); - runner.clean(); - }); - - afterEach(() => { - runner.contextPop(testContext); - }); + beforeEach(() => { + runner.cleanBuildArtifacts(); + }); + describe("1000", () => { it("should report success", () => { // act - let result = runner.run(testContext, "elm-test"); + let result = runner.run(testContext, "elm-test", "performance/1000/Tests.elm"); // assert reporterExpect(result).summaryPassed(); diff --git a/test/integration/elm-test/simple/simple.test.ts b/test/integration/elm-test/simple.test.ts similarity index 72% rename from test/integration/elm-test/simple/simple.test.ts rename to test/integration/elm-test/simple.test.ts index 8c1cf9c..b1bce49 100644 --- a/test/integration/elm-test/simple/simple.test.ts +++ b/test/integration/elm-test/simple.test.ts @@ -1,9 +1,9 @@ "use strict"; import * as chai from "chai"; -import {TestRunner} from "../../lib/test-runner"; -import reporterExpect from "../../lib/default-reporter-expect"; -import {Util} from "../../lib/util"; +import {TestRunner} from "../lib/test-runner"; +import reporterExpect from "../lib/default-reporter-expect"; +import {Util} from "../lib/util"; let expect = chai.expect; @@ -17,21 +17,17 @@ describe("elm-test-simple", () => { util = new Util(); testContext = util.initializeTestContext(__dirname); util.cd(__dirname); + runner.clean(); }); - describe("pass", () => { - beforeEach(() => { - runner.contextPush(testContext, "pass"); - runner.clean(); - }); - - afterEach(() => { - runner.contextPop(testContext); - }); + beforeEach(() => { + runner.cleanBuildArtifacts(); + }); + describe("pass", () => { it("should report success", () => { // act - let result = runner.run(testContext, "elm-test"); + let result = runner.run(testContext, "elm-test", "simple/pass/Tests.elm"); // assert reporterExpect(result).summaryPassed(); @@ -41,18 +37,15 @@ describe("elm-test-simple", () => { }); describe("fail", () => { - beforeEach(() => { - runner.contextPush(testContext, "fail"); - runner.clean(); - }); + let testDirectory: string; - afterEach(() => { - runner.contextPop(testContext); + beforeEach(() => { + testDirectory = "simple/fail/Tests.elm"; }); it("should report failure", () => { // act - let result = runner.run(testContext, "elm-test"); + let result = runner.run(testContext, "elm-test", testDirectory); // assert reporterExpect(result).summaryFailed(); @@ -62,7 +55,7 @@ describe("elm-test-simple", () => { it("should update message to use ┌ └ instead of ╷ ╵", () => { // act - let result = runner.run(testContext, "elm-test"); + let result = runner.run(testContext, "elm-test", testDirectory); // assert let startIndex = result.stdout @@ -77,7 +70,7 @@ describe("elm-test-simple", () => { it("should update string equals to show diff hint", () => { // act - let result = runner.run(testContext, "elm-test"); + let result = runner.run(testContext, "elm-test", testDirectory); // assert let startIndex = result.stdout @@ -93,18 +86,15 @@ describe("elm-test-simple", () => { }); describe("fuzz", () => { - beforeEach(() => { - runner.contextPush(testContext, "fuzz"); - runner.clean(); - }); + let testDirectory: string; - afterEach(() => { - runner.contextPop(testContext); + beforeEach(() => { + testDirectory = "simple/fuzz/Tests.elm"; }); it("should report success", () => { // act - let result = runner.run(testContext, "elm-test"); + let result = runner.run(testContext, "elm-test", testDirectory); // assert reporterExpect(result).summaryPassed(); @@ -117,7 +107,7 @@ describe("elm-test-simple", () => { let expectedRunCount = 11; // act - let result = runner.run(testContext, "elm-test", "--runCount=" + expectedRunCount); + let result = runner.run(testContext, "elm-test", testDirectory, "--runCount=" + expectedRunCount); // assert reporterExpect(result).summaryPassed(); @@ -139,7 +129,7 @@ describe("elm-test-simple", () => { let initialSeed = 101; // act - let result = runner.run(testContext, "elm-test", "--seed=" + initialSeed); + let result = runner.run(testContext, "elm-test", testDirectory, "--seed=" + initialSeed); // assert reporterExpect(result).summaryPassed(); @@ -150,18 +140,9 @@ describe("elm-test-simple", () => { }); describe("nested", () => { - beforeEach(() => { - runner.contextPush(testContext, "nested"); - runner.clean(); - }); - - afterEach(() => { - runner.contextPop(testContext); - }); - it("should report success", () => { // act - let result = runner.run(testContext, "elm-test"); + let result = runner.run(testContext, "elm-test", "simple/nested/Tests.elm"); // assert reporterExpect(result).summaryPassed(); @@ -171,18 +152,9 @@ describe("elm-test-simple", () => { }); describe("tree", () => { - beforeEach(() => { - runner.contextPush(testContext, "tree"); - runner.clean(); - }); - - afterEach(() => { - runner.contextPop(testContext); - }); - it("should report failure", () => { // act - let result = runner.run(testContext, "elm-test"); + let result = runner.run(testContext, "elm-test", "simple/tree/Tests.elm"); // assert reporterExpect(result).summaryFailed(); @@ -200,18 +172,9 @@ describe("elm-test-simple", () => { }); describe("only", () => { - beforeEach(() => { - runner.contextPush(testContext, "only"); - runner.clean(); - }); - - afterEach(() => { - runner.contextPop(testContext); - }); - it("should report only passed", () => { // act - let result = runner.run(testContext, "elm-test", "--runCount=5"); + let result = runner.run(testContext, "elm-test", "simple/only/Tests.elm", "--runCount=5"); // assert reporterExpect(result).summaryPartial(); @@ -222,18 +185,9 @@ describe("elm-test-simple", () => { }); describe("skip", () => { - beforeEach(() => { - runner.contextPush(testContext, "skip"); - runner.clean(); - }); - - afterEach(() => { - runner.contextPop(testContext); - }); - it("should report inconclusive", () => { // act - let result = runner.run(testContext, "elm-test"); + let result = runner.run(testContext, "elm-test", "simple/skip/Tests.elm"); // assert reporterExpect(result).summaryPartial(); @@ -244,18 +198,9 @@ describe("elm-test-simple", () => { }); describe("todo", () => { - beforeEach(() => { - runner.contextPush(testContext, "todo"); - runner.clean(); - }); - - afterEach(() => { - runner.contextPop(testContext); - }); - it("should report inconclusive", () => { // act - let result = runner.run(testContext, "elm-test"); + let result = runner.run(testContext, "elm-test", "simple/todo/Tests.elm"); // assert reporterExpect(result).summaryInconclusive(); diff --git a/test/integration/elm-test/performance/1000/tests/Tests.elm b/test/integration/elm-test/tests/performance/1000/Tests.elm similarity index 100% rename from test/integration/elm-test/performance/1000/tests/Tests.elm rename to test/integration/elm-test/tests/performance/1000/Tests.elm diff --git a/test/integration/elm-test/simple/fail/tests/Tests.elm b/test/integration/elm-test/tests/simple/fail/Tests.elm similarity index 100% rename from test/integration/elm-test/simple/fail/tests/Tests.elm rename to test/integration/elm-test/tests/simple/fail/Tests.elm diff --git a/test/integration/elm-test/simple/fuzz/tests/Tests.elm b/test/integration/elm-test/tests/simple/fuzz/Tests.elm similarity index 100% rename from test/integration/elm-test/simple/fuzz/tests/Tests.elm rename to test/integration/elm-test/tests/simple/fuzz/Tests.elm diff --git a/test/integration/elm-test/simple/nested/tests/ChildTest.elm b/test/integration/elm-test/tests/simple/nested/ChildTest.elm similarity index 100% rename from test/integration/elm-test/simple/nested/tests/ChildTest.elm rename to test/integration/elm-test/tests/simple/nested/ChildTest.elm diff --git a/test/integration/elm-test/simple/nested/tests/GrandChildTest.elm b/test/integration/elm-test/tests/simple/nested/GrandChildTest.elm similarity index 100% rename from test/integration/elm-test/simple/nested/tests/GrandChildTest.elm rename to test/integration/elm-test/tests/simple/nested/GrandChildTest.elm diff --git a/test/integration/elm-test/simple/nested/tests/Tests.elm b/test/integration/elm-test/tests/simple/nested/Tests.elm similarity index 100% rename from test/integration/elm-test/simple/nested/tests/Tests.elm rename to test/integration/elm-test/tests/simple/nested/Tests.elm diff --git a/test/integration/elm-test/simple/only/tests/Tests.elm b/test/integration/elm-test/tests/simple/only/Tests.elm similarity index 100% rename from test/integration/elm-test/simple/only/tests/Tests.elm rename to test/integration/elm-test/tests/simple/only/Tests.elm diff --git a/test/integration/elm-test/simple/pass/tests/Tests.elm b/test/integration/elm-test/tests/simple/pass/Tests.elm similarity index 100% rename from test/integration/elm-test/simple/pass/tests/Tests.elm rename to test/integration/elm-test/tests/simple/pass/Tests.elm diff --git a/test/integration/elm-test/simple/skip/tests/Tests.elm b/test/integration/elm-test/tests/simple/skip/Tests.elm similarity index 100% rename from test/integration/elm-test/simple/skip/tests/Tests.elm rename to test/integration/elm-test/tests/simple/skip/Tests.elm diff --git a/test/integration/elm-test/simple/todo/tests/Tests.elm b/test/integration/elm-test/tests/simple/todo/Tests.elm similarity index 100% rename from test/integration/elm-test/simple/todo/tests/Tests.elm rename to test/integration/elm-test/tests/simple/todo/Tests.elm diff --git a/test/integration/elm-test/simple/tree/tests/ConcatChildTest.elm b/test/integration/elm-test/tests/simple/tree/ConcatChildTest.elm similarity index 100% rename from test/integration/elm-test/simple/tree/tests/ConcatChildTest.elm rename to test/integration/elm-test/tests/simple/tree/ConcatChildTest.elm diff --git a/test/integration/elm-test/simple/tree/tests/FailingGrandChildTest.elm b/test/integration/elm-test/tests/simple/tree/FailingGrandChildTest.elm similarity index 100% rename from test/integration/elm-test/simple/tree/tests/FailingGrandChildTest.elm rename to test/integration/elm-test/tests/simple/tree/FailingGrandChildTest.elm diff --git a/test/integration/elm-test/simple/tree/tests/FirstChildTest.elm b/test/integration/elm-test/tests/simple/tree/FirstChildTest.elm similarity index 100% rename from test/integration/elm-test/simple/tree/tests/FirstChildTest.elm rename to test/integration/elm-test/tests/simple/tree/FirstChildTest.elm diff --git a/test/integration/elm-test/simple/tree/tests/FuzzyChildTest.elm b/test/integration/elm-test/tests/simple/tree/FuzzyChildTest.elm similarity index 100% rename from test/integration/elm-test/simple/tree/tests/FuzzyChildTest.elm rename to test/integration/elm-test/tests/simple/tree/FuzzyChildTest.elm diff --git a/test/integration/elm-test/simple/tree/tests/PassingGrandChildTest.elm b/test/integration/elm-test/tests/simple/tree/PassingGrandChildTest.elm similarity index 100% rename from test/integration/elm-test/simple/tree/tests/PassingGrandChildTest.elm rename to test/integration/elm-test/tests/simple/tree/PassingGrandChildTest.elm diff --git a/test/integration/elm-test/simple/tree/tests/SecondChildTest.elm b/test/integration/elm-test/tests/simple/tree/SecondChildTest.elm similarity index 100% rename from test/integration/elm-test/simple/tree/tests/SecondChildTest.elm rename to test/integration/elm-test/tests/simple/tree/SecondChildTest.elm diff --git a/test/integration/elm-test/simple/tree/tests/Tests.elm b/test/integration/elm-test/tests/simple/tree/Tests.elm similarity index 100% rename from test/integration/elm-test/simple/tree/tests/Tests.elm rename to test/integration/elm-test/tests/simple/tree/Tests.elm diff --git a/test/integration/lib/test-runner.ts b/test/integration/lib/test-runner.ts index 53ea572..77327f0 100644 --- a/test/integration/lib/test-runner.ts +++ b/test/integration/lib/test-runner.ts @@ -15,24 +15,24 @@ export class TestRunner { this.util.cd(".."); } - public contextPush(context: string[], name: string): void { - context.push(name); - this.util.cd(name); - } - - public contextPop(context: string[]): void { - context.pop(); + public cleanBuildArtifacts(): void { + this.util.cd("tests"); + this.util.cleanBuildArtifacts(); this.util.cd(".."); } - public run(context: string[], framework: string, args?: string): ExecOutputReturnValue { + public run(context: string[], framework: string, testFile?: string, args?: string): ExecOutputReturnValue { let baseDir = _.repeat("../", context.length); - let command = "node " + baseDir + "bin/lobo.js --prompt=no --verbose"; + let command = `node ${baseDir}bin/lobo.js --prompt=no --verbose`; if (framework) { command += " --framework=" + framework; } + if (testFile) { + command += " --testFile=" + testFile; + } + if (args) { command += " " + args; } diff --git a/test/integration/lib/util.ts b/test/integration/lib/util.ts index f638f47..47c1a94 100644 --- a/test/integration/lib/util.ts +++ b/test/integration/lib/util.ts @@ -39,6 +39,10 @@ export class Util { this.rmDir("elm-stuff"); } + public cleanBuildArtifacts(): void { + this.rmDir("elm-stuff/build-artifacts"); + } + public initializeTestContext(dirName: string): string[] { let dir = dirName; let testContext = []; diff --git a/test/unit/lib/builder.test.ts b/test/unit/lib/builder.test.ts index 778f632..620146c 100644 --- a/test/unit/lib/builder.test.ts +++ b/test/unit/lib/builder.test.ts @@ -69,7 +69,7 @@ describe("lib builder", () => { builder.make = Sinon.stub(); // act - let actual = builder.build(config, "bar"); + let actual = builder.build(config, "bar", "baz"); // assert actual.then(() => { @@ -86,7 +86,7 @@ describe("lib builder", () => { builder.make = Sinon.stub(); // act - let actual = builder.build(config, "bar"); + let actual = builder.build(config, "bar", "baz"); // assert actual.then(() => { @@ -103,7 +103,7 @@ describe("lib builder", () => { builder.make = Sinon.stub(); // act - let actual = builder.build(config, "bar"); + let actual = builder.build(config, "bar", "baz"); // assert actual.then(() => { @@ -120,7 +120,7 @@ describe("lib builder", () => { builder.make = Sinon.stub(); // act - let actual = builder.build(config, "bar"); + let actual = builder.build(config, "bar", "baz"); // assert actual.then(() => { @@ -137,7 +137,7 @@ describe("lib builder", () => { builder.make = Sinon.stub(); // act - let actual = builder.build(config, "bar"); + let actual = builder.build(config, "bar", "baz"); // assert actual.then(() => { @@ -154,7 +154,7 @@ describe("lib builder", () => { builder.make = Sinon.stub(); // act - let actual = builder.build(config, "bar"); + let actual = builder.build(config, "bar", "baz"); // assert actual.then(() => { @@ -171,7 +171,7 @@ describe("lib builder", () => { builder.make = Sinon.spy(); // act - let actual = builder.build(config, "bar"); + let actual = builder.build(config, "bar", "baz"); // assert actual.then(() => { @@ -188,11 +188,11 @@ describe("lib builder", () => { builder.make = Sinon.spy(); // act - let actual = builder.build(config, "bar"); + let actual = builder.build(config, "bar", "baz"); // assert actual.then(() => { - expect(builder.syncTestElmPackage).to.have.been.calledWith(config, Sinon.match.any, Sinon.match.any); + expect(builder.syncTestElmPackage).to.have.been.calledWith(config, Sinon.match.any, Sinon.match.any, Sinon.match.any); }); }); @@ -205,11 +205,11 @@ describe("lib builder", () => { builder.make = Sinon.spy(); // act - let actual = builder.build(config, "bar"); + let actual = builder.build(config, "bar", "baz"); // assert actual.then(() => { - expect(builder.syncTestElmPackage).to.have.been.calledWith(Sinon.match.any, ".", Sinon.match.any); + expect(builder.syncTestElmPackage).to.have.been.calledWith(Sinon.match.any, ".", Sinon.match.any, Sinon.match.any); }); }); @@ -222,11 +222,28 @@ describe("lib builder", () => { builder.make = Sinon.spy(); // act - let actual = builder.build(config, "bar"); + let actual = builder.build(config, "bar", "baz"); // assert actual.then(() => { - expect(builder.syncTestElmPackage).to.have.been.calledWith(Sinon.match.any, Sinon.match.any, "bar"); + expect(builder.syncTestElmPackage).to.have.been.calledWith(Sinon.match.any, Sinon.match.any, "bar", Sinon.match.any); + }); + }); + + it("should call syncTestElmPackage with the supplied test file directory", () => { + // arrange + let config = {testFile: "foo", noUpdate: false}; + builder.ensureElmPackageExists = Sinon.stub(); + builder.syncTestElmPackage = Sinon.stub(); + builder.installDependencies = Sinon.stub(); + builder.make = Sinon.spy(); + + // act + let actual = builder.build(config, "bar", "baz/Tests.elm"); + + // assert + actual.then(() => { + expect(builder.syncTestElmPackage).to.have.been.calledWith(Sinon.match.any, Sinon.match.any, Sinon.match.any, "baz"); }); }); @@ -239,7 +256,7 @@ describe("lib builder", () => { builder.make = Sinon.spy(); // act - let actual = builder.build(config, "bar"); + let actual = builder.build(config, "bar", "baz"); // assert actual.then(() => { @@ -256,7 +273,7 @@ describe("lib builder", () => { builder.make = Sinon.spy(); // act - let actual = builder.build(config, "bar"); + let actual = builder.build(config, "bar", "baz"); // assert actual.then(() => { @@ -273,7 +290,7 @@ describe("lib builder", () => { builder.make = Sinon.spy(); // act - let actual = builder.build(config, "bar"); + let actual = builder.build(config, "bar", "baz"); // assert actual.then(() => { @@ -290,7 +307,7 @@ describe("lib builder", () => { builder.make = Sinon.spy(); // act - let actual = builder.build(config, "bar"); + let actual = builder.build(config, "bar", "baz"); // assert actual.then(() => { @@ -415,7 +432,7 @@ describe("lib builder", () => { (builder.updateDependencies).resolves({}); // act - let actual = builder.syncTestElmPackage(config, "bar", "baz"); + let actual = builder.syncTestElmPackage(config, "bar", "baz", "qux"); // assert actual.then(() => { @@ -434,7 +451,7 @@ describe("lib builder", () => { (builder.updateDependencies).resolves({}); // act - let actual = builder.syncTestElmPackage(config, "bar", "baz"); + let actual = builder.syncTestElmPackage(config, "bar", "baz", "qux"); // assert actual.then(() => { @@ -453,11 +470,12 @@ describe("lib builder", () => { (builder.updateDependencies).resolves({}); // act - let actual = builder.syncTestElmPackage(config, "bar", "baz"); + let actual = builder.syncTestElmPackage(config, "bar", "baz", "qux"); // assert actual.then(() => { - expect(builder.updateSourceDirectories).to.have.been.calledWith(config, Sinon.match.any, Sinon.match.any, Sinon.match.any, Sinon.match.any); + expect(builder.updateSourceDirectories).to.have.been.calledWith(config, Sinon.match.any, Sinon.match.any, Sinon.match.any, + Sinon.match.any, Sinon.match.any); }); }); @@ -472,12 +490,12 @@ describe("lib builder", () => { (builder.updateDependencies).resolves({}); // act - let actual = builder.syncTestElmPackage(config, "bar", "baz"); + let actual = builder.syncTestElmPackage(config, "bar", "baz", "qux"); // assert actual.then(() => { expect(builder.updateSourceDirectories) - .to.have.been.calledWith(Sinon.match.any, "bar", Sinon.match.any, Sinon.match.any, Sinon.match.any); + .to.have.been.calledWith(Sinon.match.any, "bar", Sinon.match.any, Sinon.match.any, Sinon.match.any, Sinon.match.any); }); }); @@ -492,12 +510,12 @@ describe("lib builder", () => { (builder.updateDependencies).resolves({}); // act - let actual = builder.syncTestElmPackage(config, "bar", "baz"); + let actual = builder.syncTestElmPackage(config, "bar", "baz", "qux"); // assert actual.then(() => { expect(builder.updateSourceDirectories) - .to.have.been.calledWith(Sinon.match.any, Sinon.match.any, "abc", Sinon.match.any, Sinon.match.any); + .to.have.been.calledWith(Sinon.match.any, Sinon.match.any, "abc", Sinon.match.any, Sinon.match.any, Sinon.match.any); }); }); @@ -512,12 +530,32 @@ describe("lib builder", () => { (builder.updateDependencies).resolves({}); // act - let actual = builder.syncTestElmPackage(config, "bar", "baz"); + let actual = builder.syncTestElmPackage(config, "bar", "baz", "qux"); // assert actual.then(() => { expect(builder.updateSourceDirectories) - .to.have.been.calledWith(Sinon.match.any, Sinon.match.any, Sinon.match.any, "baz", Sinon.match.any); + .to.have.been.calledWith(Sinon.match.any, Sinon.match.any, Sinon.match.any, "baz", Sinon.match.any, Sinon.match.any); + }); + }); + + it("should call updateSourceDirectories with the supplied test dir", () => { + // arrange + let config = {testFile: "foo", prompt: true}; + builder.readElmPackage = Sinon.stub(); + (builder.readElmPackage).resolves({base: "a", test: "b"}); + builder.updateSourceDirectories = Sinon.stub(); + (builder.updateSourceDirectories).resolves({base: "a", test: "b"}); + builder.updateDependencies = Sinon.stub(); + (builder.updateDependencies).resolves({}); + + // act + let actual = builder.syncTestElmPackage(config, "bar", "baz", "qux"); + + // assert + actual.then(() => { + expect(builder.updateSourceDirectories) + .to.have.been.calledWith(Sinon.match.any, Sinon.match.any, Sinon.match.any, Sinon.match.any, "qux", Sinon.match.any); }); }); @@ -532,12 +570,12 @@ describe("lib builder", () => { (builder.updateDependencies).resolves({}); // act - let actual = builder.syncTestElmPackage(config, "bar", "baz"); + let actual = builder.syncTestElmPackage(config, "bar", "baz", "qux"); // assert actual.then(() => { expect(builder.updateSourceDirectories) - .to.have.been.calledWith(Sinon.match.any, Sinon.match.any, Sinon.match.any, Sinon.match.any, "abc"); + .to.have.been.calledWith(Sinon.match.any, Sinon.match.any, Sinon.match.any, Sinon.match.any, Sinon.match.any, "abc"); }); }); @@ -552,7 +590,7 @@ describe("lib builder", () => { (builder.updateDependencies).resolves({}); // act - let actual = builder.syncTestElmPackage(config, "bar", "baz"); + let actual = builder.syncTestElmPackage(config, "bar", "baz", "qux"); // assert actual.then(() => { @@ -571,7 +609,7 @@ describe("lib builder", () => { (builder.updateDependencies).resolves({}); // act - let actual = builder.syncTestElmPackage(config, "bar", "baz"); + let actual = builder.syncTestElmPackage(config, "bar", "baz", "qux"); // assert actual.then(() => { @@ -590,7 +628,7 @@ describe("lib builder", () => { (builder.updateDependencies).resolves({}); // act - let actual = builder.syncTestElmPackage(config, "bar", "baz"); + let actual = builder.syncTestElmPackage(config, "bar", "baz", "qux"); // assert actual.then(() => { @@ -609,7 +647,7 @@ describe("lib builder", () => { (builder.updateDependencies).resolves({}); // act - let actual = builder.syncTestElmPackage(config, "bar", "baz"); + let actual = builder.syncTestElmPackage(config, "bar", "baz", "qux"); // assert actual.then(() => { @@ -707,11 +745,11 @@ describe("lib builder", () => { builder.mergeSourceDirectories = Sinon.stub(); // act - builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", testPackageJson); + builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", "qux", testPackageJson); // assert expect(builder.mergeSourceDirectories) - .to.have.been.calledWith(sourcePackageJson, Sinon.match.any, Sinon.match.any, Sinon.match.any, Sinon.match.any); + .to.have.been.calledWith(sourcePackageJson, Sinon.match.any, Sinon.match.any, Sinon.match.any, Sinon.match.any, Sinon.match.any); }); it("should call mergeSourceDirectories with the specified base directory", () => { @@ -722,11 +760,11 @@ describe("lib builder", () => { builder.mergeSourceDirectories = Sinon.stub(); // act - builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", testPackageJson); + builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", "qux", testPackageJson); // assert expect(builder.mergeSourceDirectories) - .to.have.been.calledWith(Sinon.match.any, "bar", Sinon.match.any, Sinon.match.any, Sinon.match.any); + .to.have.been.calledWith(Sinon.match.any, "bar", Sinon.match.any, Sinon.match.any, Sinon.match.any, Sinon.match.any); }); it("should call mergeSourceDirectories with the specified test package json", () => { @@ -737,14 +775,14 @@ describe("lib builder", () => { builder.mergeSourceDirectories = Sinon.stub(); // act - builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", testPackageJson); + builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", "qux", testPackageJson); // assert expect(builder.mergeSourceDirectories) - .to.have.been.calledWith(Sinon.match.any, Sinon.match.any, testPackageJson, Sinon.match.any, Sinon.match.any); + .to.have.been.calledWith(Sinon.match.any, Sinon.match.any, testPackageJson, Sinon.match.any, Sinon.match.any, Sinon.match.any); }); - it("should call mergeSourceDirectories with the specified test directory", () => { + it("should call mergeSourceDirectories with the specified main test directory", () => { // arrange let config = {testFile: "foo", prompt: true}; let sourcePackageJson = {sourceDirectories: ["source"]}; @@ -752,11 +790,26 @@ describe("lib builder", () => { builder.mergeSourceDirectories = Sinon.stub(); // act - builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", testPackageJson); + builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", "qux", testPackageJson); // assert expect(builder.mergeSourceDirectories) - .to.have.been.calledWith(Sinon.match.any, Sinon.match.any, Sinon.match.any, "baz", Sinon.match.any); + .to.have.been.calledWith(Sinon.match.any, Sinon.match.any, Sinon.match.any, "baz", Sinon.match.any, Sinon.match.any); + }); + + it("should call mergeSourceDirectories with the specified test file directory", () => { + // arrange + let config = {testFile: "foo", prompt: true}; + let sourcePackageJson = {sourceDirectories: ["source"]}; + let testPackageJson = {sourceDirectories: ["test"]}; + builder.mergeSourceDirectories = Sinon.stub(); + + // act + builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", "qux", testPackageJson); + + // assert + expect(builder.mergeSourceDirectories) + .to.have.been.calledWith(Sinon.match.any, Sinon.match.any, Sinon.match.any, Sinon.match.any, "qux", Sinon.match.any); }); it("should call mergeSourceDirectories with the specified testFramework", () => { @@ -767,11 +820,11 @@ describe("lib builder", () => { builder.mergeSourceDirectories = Sinon.stub(); // act - builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", testPackageJson); + builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", "qux", testPackageJson); // assert expect(builder.mergeSourceDirectories) - .to.have.been.calledWith(Sinon.match.any, Sinon.match.any, Sinon.match.any, Sinon.match.any, config.testFramework); + .to.have.been.calledWith(Sinon.match.any, Sinon.match.any, Sinon.match.any, Sinon.match.any, Sinon.match.any, config.testFramework); }); it("should return the unaltered base package json when there is no difference", () => { @@ -783,7 +836,7 @@ describe("lib builder", () => { (builder.mergeSourceDirectories).returns(testPackageJson.sourceDirectories); // act - let actual = builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", testPackageJson); + let actual = builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", "qux", testPackageJson); // assert actual.then((result: { base: {} }) => { @@ -800,7 +853,7 @@ describe("lib builder", () => { (builder.mergeSourceDirectories).returns(testPackageJson.sourceDirectories); // act - let actual = builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", testPackageJson); + let actual = builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", "qux", testPackageJson); // assert actual.then((result: { test: {} }) => { @@ -816,7 +869,7 @@ describe("lib builder", () => { builder.updateSourceDirectoriesAction = Sinon.stub(); // act - builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", testPackageJson); + builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", "qux", testPackageJson); // assert expect(mockConfirm).not.to.have.been.called; @@ -831,7 +884,7 @@ describe("lib builder", () => { builder.updateSourceDirectoriesAction = Sinon.stub(); // act - builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", testPackageJson); + builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", "qux", testPackageJson); // assert expect(mockConfirm).to.have.been.called; @@ -847,7 +900,7 @@ describe("lib builder", () => { mockConfirm.callsFake((message, defaults, action) => action({}, "foo")); // act - let actual = builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", testPackageJson); + let actual = builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", "qux", testPackageJson); actual.catchReturn({}); // assert @@ -863,7 +916,7 @@ describe("lib builder", () => { mockConfirm.callsFake((message, defaults, action) => action(undefined, false)); // act - let actual = builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", testPackageJson); + let actual = builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", "qux", testPackageJson); actual.catchReturn({}); // assert @@ -881,7 +934,7 @@ describe("lib builder", () => { (builder.mergeSourceDirectories).returns(expected); // act - builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", testPackageJson); + builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", "qux", testPackageJson); // assert expect(builder.updateSourceDirectoriesAction).to.have.been.calledWith(expected, Sinon.match.any, Sinon.match.any); @@ -895,7 +948,7 @@ describe("lib builder", () => { builder.updateSourceDirectoriesAction = Sinon.stub(); // act - let actual = builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", testPackageJson); + let actual = builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", "qux", testPackageJson); // assert actual.then((result: { base: {} }) => { @@ -913,7 +966,7 @@ describe("lib builder", () => { (builder.updateSourceDirectoriesAction).returns(expected); // act - let actual = builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", testPackageJson); + let actual = builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", "qux", testPackageJson); // assert actual.then((result: { test: {} }) => { @@ -933,7 +986,7 @@ describe("lib builder", () => { (builder.mergeSourceDirectories).returns(expected); // act - builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", testPackageJson); + builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", "qux", testPackageJson); // assert expect(builder.updateSourceDirectoriesAction).to.have.been.calledWith(expected, Sinon.match.any, Sinon.match.any); @@ -948,7 +1001,7 @@ describe("lib builder", () => { mockConfirm.callsFake((message, defaults, action) => action(undefined, true)); // act - let actual = builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", testPackageJson); + let actual = builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", "qux", testPackageJson); // assert actual.then((result: { base: {} }) => { @@ -967,7 +1020,7 @@ describe("lib builder", () => { mockConfirm.callsFake((message, defaults, action) => action(undefined, true)); // act - let actual = builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", testPackageJson); + let actual = builder.updateSourceDirectories(config, "bar", sourcePackageJson, "baz", "qux", testPackageJson); // assert actual.then((result: { test: {} }) => { @@ -1294,19 +1347,32 @@ describe("lib builder", () => { let testFramework = {config: {sourceDirectories: []}}; // act - let actual = builder.mergeSourceDirectories({}, "sourceDir", {}, "testDir", testFramework); + let actual = builder.mergeSourceDirectories({}, "sourceDir", {}, "testDir", ".", testFramework); // assert expect(actual.length).to.equal(1); expect(actual).to.include("."); }); + it("should return array with current dir and test file dir when no other dirs are specified", () => { + // arrange + let testFramework = {config: {sourceDirectories: []}}; + + // act + let actual = builder.mergeSourceDirectories({}, "sourceDir", {}, "testDir", "foo", testFramework); + + // assert + expect(actual.length).to.equal(2); + expect(actual).to.include("."); + expect(actual).to.include("foo"); + }); + it("should return array with current dir only when no other dirs are specified other than the test source directories", () => { // arrange let testFramework = {config: {sourceDirectories: []}}; // act - let actual = builder.mergeSourceDirectories({}, "sourceDir", {sourceDirectories: ["."]}, "testDir", testFramework); + let actual = builder.mergeSourceDirectories({}, "sourceDir", {sourceDirectories: ["."]}, "testDir", ".", testFramework); // assert expect(actual.length).to.equal(1); @@ -1320,7 +1386,7 @@ describe("lib builder", () => { let testPackageJson = {sourceDirectories: ["test"]}; // act - let actual = builder.mergeSourceDirectories(sourcePackageJson, "sourceDir", testPackageJson, "testDir", testFramework); + let actual = builder.mergeSourceDirectories(sourcePackageJson, "sourceDir", testPackageJson, "testDir", "qux", testFramework); // assert expect(actual).to.include("."); @@ -1333,7 +1399,7 @@ describe("lib builder", () => { let testPackageJson = {sourceDirectories: ["test"]}; // act - let actual = builder.mergeSourceDirectories(sourcePackageJson, "sourceDir", testPackageJson, "testDir", testFramework); + let actual = builder.mergeSourceDirectories(sourcePackageJson, "sourceDir", testPackageJson, "testDir", "qux", testFramework); // assert expect(actual).to.include("test"); @@ -1347,7 +1413,7 @@ describe("lib builder", () => { let testPackageJson = {sourceDirectories: ["test"]}; // act - let actual = builder.mergeSourceDirectories(sourcePackageJson, "sourceDir", testPackageJson, "testDir", testFramework); + let actual = builder.mergeSourceDirectories(sourcePackageJson, "sourceDir", testPackageJson, "testDir", "qux", testFramework); // assert expect(actual).to.include("../sourceDir/source"); @@ -1361,7 +1427,7 @@ describe("lib builder", () => { let testPackageJson = {sourceDirectories: ["test"]}; // act - let actual = builder.mergeSourceDirectories(sourcePackageJson, "sourceDir", testPackageJson, "testDir", testFramework); + let actual = builder.mergeSourceDirectories(sourcePackageJson, "sourceDir", testPackageJson, "testDir", "qux", testFramework); // assert expect(actual).to.include.something.that.match(/..\/foo/); @@ -1579,7 +1645,7 @@ describe("lib builder", () => { builder.runElmPackageInstall(config, "bar", true, mockResolve, mockReject); // assert - expect(mockExec).to.have.been.calledWith(Sinon.match(/^foo(\/|\\)elm-package install/), Sinon.match.any); + expect(mockExec).to.have.been.calledWith(Sinon.match(/^foo([\/\\])elm-package install/), Sinon.match.any); }); it("should call elm-package to install the packages without --yes when prompt is true", () => { @@ -1641,41 +1707,72 @@ describe("lib builder", () => { }); describe("make", () => { - let revertChildProcess: () => void; - let revertConsole: () => void; + let revertMocks: () => void; let mockExec: SinonStub; + let mockPathResolve: SinonStub; + let mockJoin: SinonStub; beforeEach(() => { mockExec = Sinon.stub(); - revertChildProcess = RewiredBuilder.__set__({childProcess: {execSync: mockExec}}); - revertConsole = RewiredBuilder.__set__({console: {log: Sinon.stub()}}); + mockPathResolve = Sinon.stub(); + mockJoin = Sinon.stub(); + revertMocks = RewiredBuilder.__set__({childProcess: {execSync: mockExec}, console: {log: Sinon.stub()}, path: { resolve: mockPathResolve, join: mockJoin}}); }); afterEach(() => { - revertChildProcess(); - revertConsole(); + revertMocks(); }); it("should call elm-make to build the tests", () => { // arrange let config = {compiler: "abc", testFramework: {config: {name: "foo"}}, testMainElm: "bar"}; + mockPathResolve.callsFake(() => "def"); + mockJoin.callsFake((...args) => args.join("/")); // act - builder.make(config, "bar"); + builder.make(config, "bar", "baz"); // assert - expect(mockExec).to.have.been.calledWith(Sinon.match(/^abc(\/|\\)elm-make /), Sinon.match.any); + expect(mockExec).to.have.been.calledWith(Sinon.match(/^abc([\/\\])elm-make /), Sinon.match.any); }); - it("should call elm-package to install the packages from the specified elm-install path", () => { + it("should call elm-make with the qualified path to testMainElm file from the config", () => { // arrange - let config = {compiler: "foo"}; + let config = {compiler: "abc", testFramework: {config: {name: "foo"}}, testMainElm: "bar"}; + mockPathResolve.callsFake(() => "def"); + mockJoin.callsFake((...args) => args.join("-")); // act - builder.runElmPackageInstall(config, "bar", true, mockResolve, mockReject); + builder.make(config, "baz", "qux"); + + // assert + expect(mockExec).to.have.been.calledWith(Sinon.match(/elm-make.* def-foo-bar/), Sinon.match.any); + }); + + it("should call elm-make with the relative path to testFile", () => { + // arrange + let config = {compiler: "abc", testFramework: {config: {name: "foo"}}, testMainElm: "bar"}; + mockPathResolve.callsFake(() => "def"); + mockJoin.callsFake((...args) => args.join("-")); + + // act + builder.make(config, "baz", "qux"); + + // assert + expect(mockExec).to.have.been.calledWith(Sinon.match(/elm-make qux/), Sinon.match.any); + }); + + it("should not call elm-make with the relative path to testFile when it is 'Tests.elm'", () => { + // arrange + let config = {compiler: "abc", testFramework: {config: {name: "foo"}}, testMainElm: "bar"}; + mockPathResolve.callsFake(() => "def"); + mockJoin.callsFake((...args) => args.join("-")); + + // act + builder.make(config, "baz", "Tests.elm"); // assert - expect(mockExec).to.have.been.calledWith(Sinon.match(/^foo(\/|\\)elm-package install/), Sinon.match.any); + expect(mockExec).not.to.have.been.calledWith(Sinon.match(/Tests.elm/), Sinon.match.any); }); it("should call elm-make to build the tests to the specified output testFile", () => { @@ -1683,7 +1780,7 @@ describe("lib builder", () => { let config = {testFramework: {config: {name: "foo"}}, testMainElm: "bar", testFile: "baz"}; // act - builder.make(config, "bar"); + builder.make(config, "baz", "qux"); // assert expect(mockExec).to.have.been.calledWith(Sinon.match(/--output=baz/), Sinon.match.any); @@ -1694,7 +1791,7 @@ describe("lib builder", () => { let config = {testFramework: {config: {name: "foo"}}, testMainElm: "bar", prompt: true}; // act - builder.make(config, "bar"); + builder.make(config, "baz", "qux"); // assert expect(mockExec).to.have.been.calledWith(Sinon.match((x) => x.indexOf("--yes") === -1), Sinon.match.any); @@ -1705,7 +1802,7 @@ describe("lib builder", () => { let config = {testFramework: {config: {name: "foo"}}, testMainElm: "bar", prompt: false}; // act - builder.make(config, "bar"); + builder.make(config, "baz", "qux"); // assert expect(mockExec).to.have.been.calledWith(Sinon.match(/ --yes/), Sinon.match.any); @@ -1716,7 +1813,7 @@ describe("lib builder", () => { let config = {testFramework: {config: {name: "foo"}}, testMainElm: "bar", noWarn: true}; // act - builder.make(config, "bar"); + builder.make(config, "baz", "qux"); // assert expect(mockExec).to.have.been.calledWith(Sinon.match((x) => x.indexOf("--warn") === -1), Sinon.match.any); @@ -1727,7 +1824,7 @@ describe("lib builder", () => { let config = {testFramework: {config: {name: "foo"}}, testMainElm: "bar", noWarn: false}; // act - builder.make(config, "bar"); + builder.make(config, "baz", "qux"); // assert expect(mockExec).to.have.been.calledWith(Sinon.match(/ --warn/), Sinon.match.any); @@ -1738,10 +1835,10 @@ describe("lib builder", () => { let config = {testFramework: {config: {name: "foo"}}, testMainElm: "bar", noWarn: false}; // act - builder.make(config, "bar"); + builder.make(config, "baz", "qux"); // assert - expect(mockExec).to.have.been.calledWith(Sinon.match.any, Sinon.match(x => x.cwd === "bar")); + expect(mockExec).to.have.been.calledWith(Sinon.match.any, Sinon.match(x => x.cwd === "baz")); }); it("should call resolve when there are no elm-make build errors", () => { @@ -1749,7 +1846,7 @@ describe("lib builder", () => { let config = {testFramework: {config: {name: "foo"}}, testMainElm: "bar"}; // act - let actual = builder.make(config, "bar"); + let actual = builder.make(config, "baz", "qux"); // assert actual.then(() => { @@ -1764,7 +1861,7 @@ describe("lib builder", () => { mockExec.throws(expected); // act - let actual = builder.make(config, "bar"); + let actual = builder.make(config, "baz", "qux"); // assert actual.catch((err) => { diff --git a/test/unit/lib/main.test.ts b/test/unit/lib/main.test.ts index 3fd1b80..9ca3022 100644 --- a/test/unit/lib/main.test.ts +++ b/test/unit/lib/main.test.ts @@ -1112,7 +1112,7 @@ describe("lib main", () => { it("should log an error when the elm compiler cannot be found", () => { // arrange - let revert = rewiredMain.__with__({program: {compiler: "foo", testDirectory: "bar"}, shelljs: {test: () => false}}); + let revert = rewiredMain.__with__({program: {compiler: "foo", testDirectory: "bar", testFile: "baz"}, shelljs: {test: () => false}}); // act revert(() => lobo.validateConfiguration()); @@ -1121,9 +1121,20 @@ describe("lib main", () => { expect(mockLogger.error).to.have.been.calledWith("Unable to find the elm compiler"); }); + it("should not log an error when the elm compiler is found", () => { + // arrange + let revert = rewiredMain.__with__({program: {compiler: "foo", testDirectory: "bar", testFile: "baz"}, shelljs: {test: () => true}}); + + // act + revert(() => lobo.validateConfiguration()); + + // assert + expect(mockLogger.error).not.to.have.been.calledWith("Unable to find the elm compiler"); + }); + it("should call process.exit with an exitCode of 1 when the elm compiler cannot be found", () => { // arrange - let revert = rewiredMain.__with__({program: {compiler: "foo", testDirectory: "bar"}, shelljs: {test: () => false}}); + let revert = rewiredMain.__with__({program: {compiler: "foo", testDirectory: "bar", testFile: "baz"}, shelljs: {test: () => false}}); // act revert(() => lobo.validateConfiguration()); @@ -1132,22 +1143,43 @@ describe("lib main", () => { expect(mockExit).to.have.been.calledWith(1); }); - it("should log an error when the Tests.elm file cannot be found in the test directory", () => { + it("should log an error with the specified test file when the specified test file cannot be found in the test directory", () => { + // arrange + let revert = rewiredMain.__with__({ + program: {compiler: "foo", testDirectory: "bar", testFile: "baz/Tests.elm"}, + shelljs: {test: () => false}, + path: {basename: x => "base", dirname: x => "dir", join: (...args) => args.join("-"), resolve: x => "abc-" + x} + }); + + // act + revert(() => lobo.validateConfiguration()); + + // assert + expect(mockLogger.error).to.have.been.calledWith("Unable to find \"base\""); + }); + + it("should log an error with the specified test directory when the specified test file cannot be found in the test directory", () => { // arrange - let fakeTest = (flags, fileName) => fileName !== "bar/Tests.elm"; - let revert = rewiredMain.__with__({program: {compiler: "foo", testDirectory: "bar"}, shelljs: {test: fakeTest}}); + let revert = rewiredMain.__with__({ + program: {compiler: "foo", testDirectory: "bar", testFile: "baz/Tests.elm"}, + shelljs: {test: () => false}, + path: {basename: x => "base", dirname: x => "dir", join: (...args) => args.join("-"), resolve: x => "abc-" + x} + }); // act revert(() => lobo.validateConfiguration()); // assert - expect(mockLogger.error).to.have.been.calledWith("Unable to find \"Tests.elm\""); + expect(mockLogger.error).to.have.been.calledWith("abc-dir"); }); it("should call process.exit with an exitCode of 1 when the Tests.elm file cannot be found in the test directory", () => { // arrange - let fakeTest = (flags, fileName) => fileName !== "bar/Tests.elm"; - let revert = rewiredMain.__with__({program: {compiler: "foo", testDirectory: "bar"}, shelljs: {test: fakeTest}}); + let revert = rewiredMain.__with__({ + program: {compiler: "foo", testDirectory: "bar", testFile: "baz-Tests.elm"}, + shelljs: {test: () => false}, + path: {basename: x => "base", dirname: x => "dir", join: (...args) => args.join("-"), resolve: x => "abc-" + x} + }); // act revert(() => lobo.validateConfiguration()); @@ -1158,7 +1190,11 @@ describe("lib main", () => { it("should log an error when the test framework is elm-test and showSkip is true", () => { // arrange - let revert = rewiredMain.__with__({program: {framework: "elm-test", showSkip: true}, shelljs: {test: () => true}}); + let revert = rewiredMain.__with__({ + program: {framework: "elm-test", showSkip: true}, + shelljs: {test: () => true}, + path: {join: () => undefined} + }); // act revert(() => lobo.validateConfiguration()); @@ -1169,7 +1205,11 @@ describe("lib main", () => { it("should not log an error when the test framework is elm-test and showSkip is false", () => { // arrange - let revert = rewiredMain.__with__({program: {framework: "elm-test", showSkip: false}, shelljs: {test: () => true}}); + let revert = rewiredMain.__with__({ + program: {framework: "elm-test", showSkip: false}, + shelljs: {test: () => true}, + path: {join: () => undefined} + }); // act revert(() => lobo.validateConfiguration()); @@ -1180,7 +1220,11 @@ describe("lib main", () => { it("should call process.exit with an exitCode of 1 when the test framework is elm-test and showSkip is true", () => { // arrange - let revert = rewiredMain.__with__({program: {framework: "elm-test", showSkip: true}, shelljs: {test: () => true}}); + let revert = rewiredMain.__with__({ + program: {framework: "elm-test", showSkip: true}, + shelljs: {test: () => true}, + path: {join: () => undefined} + }); // act revert(() => lobo.validateConfiguration()); @@ -1191,7 +1235,11 @@ describe("lib main", () => { it("should log an error when the reporter is junit and reportFile is unset", () => { // arrange - let revert = rewiredMain.__with__({program: {reporter: "junit-reporter", reportFile: undefined}, shelljs: {test: () => true}}); + let revert = rewiredMain.__with__({ + program: {reporter: "junit-reporter", reportFile: undefined}, + shelljs: {test: () => true}, + path: {join: () => undefined} + }); // act revert(() => lobo.validateConfiguration()); @@ -1202,7 +1250,11 @@ describe("lib main", () => { it("should not log an error when the reporter is junit and reportFile has a value", () => { // arrange - let revert = rewiredMain.__with__({program: {reporter: "junit-reporter", reportFile: "foo"}, shelljs: {test: () => true}}); + let revert = rewiredMain.__with__({ + program: {reporter: "junit-reporter", reportFile: "foo"}, + shelljs: {test: () => true}, + path: {join: () => undefined} + }); // act revert(() => lobo.validateConfiguration()); @@ -1213,7 +1265,11 @@ describe("lib main", () => { it("should call process.exit with an exitCode of 1 when the reporter is junit and reportFile is unset", () => { // arrange - let revert = rewiredMain.__with__({program: {reporter: "junit-reporter", reportFile: undefined}, shelljs: {test: () => true}}); + let revert = rewiredMain.__with__({ + program: {reporter: "junit-reporter", reportFile: undefined}, + shelljs: {test: () => true}, + path: {join: () => undefined} + }); // act revert(() => lobo.validateConfiguration()); @@ -1225,7 +1281,11 @@ describe("lib main", () => { it("should log an error when the reporter is junit and diffMaxLength is not an integer", () => { // arrange (mockUtil.isInteger).returns(false); - let revert = rewiredMain.__with__({program: {reporter: "junit-reporter", reportFile: "foo", diffMaxLength: "bar"}, shelljs: {test: () => true}}); + let revert = rewiredMain.__with__({ + program: {reporter: "junit-reporter", reportFile: "foo", diffMaxLength: "bar"}, + shelljs: {test: () => true}, + path: {join: () => undefined} + }); // act revert(() => lobo.validateConfiguration()); @@ -1237,7 +1297,11 @@ describe("lib main", () => { it("should not log an error when the reporter is junit and diffMaxLength is an integer", () => { // arrange (mockUtil.isInteger).returns(true); - let revert = rewiredMain.__with__({program: {reporter: "junit-reporter", reportFile: "foo", diffMaxLength: "122"}, shelljs: {test: () => true}}); + let revert = rewiredMain.__with__({ + program: {reporter: "junit-reporter", reportFile: "foo", diffMaxLength: "122"}, + shelljs: {test: () => true}, + path: {join: () => undefined} + }); // act revert(() => lobo.validateConfiguration()); @@ -1249,7 +1313,11 @@ describe("lib main", () => { it("should call process.exit with an exitCode of 1 when the reporter is junit and diffMaxLength is not an integer", () => { // arrange (mockUtil.isInteger).returns(false); - let revert = rewiredMain.__with__({program: {reporter: "junit-reporter", reportFile: "foo", diffMaxLength: "122"}, shelljs: {test: () => true}}); + let revert = rewiredMain.__with__({ + program: {reporter: "junit-reporter", reportFile: "foo", diffMaxLength: "122"}, + shelljs: {test: () => true}, + path: {join: () => undefined} + }); // act revert(() => lobo.validateConfiguration()); diff --git a/test/unit/lib/test-result-formatter.test.ts b/test/unit/lib/test-result-formatter.test.ts index c58a1ff..660695c 100644 --- a/test/unit/lib/test-result-formatter.test.ts +++ b/test/unit/lib/test-result-formatter.test.ts @@ -244,13 +244,25 @@ describe("lib test-result-formatter", () => { expect(actual).to.equal("\nfoo\n╷\n│bar\n╵\nbaz\n"); }); - it("should replace failure markers '╷', │' and '╵' with '┌','│' and'└' ", () => { + it("should replace failure marker '╷' with '│'", () => { // arrange (mockDecorator.expect).callsFake(x => x); (mockDecorator.line).callsFake(x => x); // act - let actual = formatter.formatFailureMessage("foo\n╷\n│ bar\n╵\nbaz", 123); + let actual = formatter.formatFailureMessage("foo\n╷\n│ bar\n╷\nbaz", 123); + + // assert + expect(actual).to.equal("\n┌ foo\n│\n│ bar\n│\n└ baz\n"); + }); + + it("should replace failure marker '╵' with '│'", () => { + // arrange + (mockDecorator.expect).callsFake(x => x); + (mockDecorator.line).callsFake(x => x); + + // act + let actual = formatter.formatFailureMessage("foo\n╵\n│ bar\n╵\nbaz", 123); // assert expect(actual).to.equal("\n┌ foo\n│\n│ bar\n│\n└ baz\n"); diff --git a/test/unit/plugin/elm-test-extra/plugin-config.test.ts b/test/unit/plugin/elm-test-extra/plugin-config.test.ts index 5ff6acc..61a771b 100644 --- a/test/unit/plugin/elm-test-extra/plugin-config.test.ts +++ b/test/unit/plugin/elm-test-extra/plugin-config.test.ts @@ -47,7 +47,7 @@ describe("plugin elm-test-extra plugin-config", () => { let dependencies = config.dependencies; // assert - expect(dependencies).to.have.property("elm-community/elm-test", "4.0.0 <= v < 5.0.0"); + expect(dependencies).to.have.property("elm-community/elm-test", "4.2.0 <= v < 5.0.0"); }); it("should have 'mgold/elm-random-pcg' dependency", () => { diff --git a/test/unit/plugin/elm-test/plugin-config.test.ts b/test/unit/plugin/elm-test/plugin-config.test.ts index b0f0dbc..3d3da7c 100644 --- a/test/unit/plugin/elm-test/plugin-config.test.ts +++ b/test/unit/plugin/elm-test/plugin-config.test.ts @@ -39,7 +39,7 @@ describe("plugin elm-test plugin-config", () => { let dependencies = config.dependencies; // assert - expect(dependencies).to.have.property("elm-community/elm-test", "4.0.0 <= v < 5.0.0"); + expect(dependencies).to.have.property("elm-community/elm-test", "4.2.0 <= v < 5.0.0"); }); it("should have 'mgold/elm-random-pcg' dependency", () => {