From f3fb904341ef25243da266e89974400e770afef1 Mon Sep 17 00:00:00 2001 From: stasson Date: Sat, 8 Sep 2018 12:04:35 +0200 Subject: [PATCH] test: add e2e tests --- package-lock.json | 20 ++++++++++++++++++++ package.json | 4 +++- test/e2e/.gitignore | 1 - test/e2e/commands.spect.ts | 17 +++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) delete mode 100644 test/e2e/.gitignore diff --git a/package-lock.json b/package-lock.json index bc7faeb..42589ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -332,6 +332,15 @@ "@types/node": "*" } }, + "@types/fs-extra": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-5.0.4.tgz", + "integrity": "sha512-DsknoBvD8s+RFfSGjmERJ7ZOP1HI0UZRA3FSI+Zakhrc/Gy26YQsLI+m5V5DHxroHRJqCDLKJp7Hixn8zyaF7g==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/inquirer": { "version": "0.0.43", "resolved": "https://registry.npmjs.org/@types/inquirer/-/inquirer-0.0.43.tgz", @@ -3012,6 +3021,17 @@ "null-check": "^1.0.0" } }, + "fs-extra": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.0.tgz", + "integrity": "sha512-EglNDLRpmaTWiD/qraZn6HREAEAHJcJOmxNEYwq6xeMKnVMAy3GUcFB+wXt2C6k4CNvB/mP1y/U3dzvKKj5OtQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", diff --git a/package.json b/package.json index fdfe47a..bdf6f12 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "transform": { "^.+\\.tsx?$": "ts-jest" }, - "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", + "testRegex": "(.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", "moduleFileExtensions": [ "ts", "tsx", @@ -71,11 +71,13 @@ "@commitlint/cli": "^7.0.0", "@commitlint/config-conventional": "^7.0.1", "@types/execa": "^0.9.0", + "@types/fs-extra": "^5.0.4", "@types/jest": "^23.3.1", "@types/listr": "^0.13.0", "@types/node": "^10.8.0", "bdd-stdin": "^0.2.0", "cross-env": "^5.2.0", + "fs-extra": "^7.0.0", "jest": "^23.5.0", "npm-run-all": "^4.1.3", "prettier": "^1.14.2", diff --git a/test/e2e/.gitignore b/test/e2e/.gitignore deleted file mode 100644 index ffdcec4..0000000 --- a/test/e2e/.gitignore +++ /dev/null @@ -1 +0,0 @@ -repo \ No newline at end of file diff --git a/test/e2e/commands.spect.ts b/test/e2e/commands.spect.ts index e69de29..cd8f343 100644 --- a/test/e2e/commands.spect.ts +++ b/test/e2e/commands.spect.ts @@ -0,0 +1,17 @@ +import * as os from 'os' +import * as path from 'path' +import * as fs from 'fs-extra' +import * as execa from 'execa' + +describe('commit', () => { + it('fails on not a repo', () => { + expect.hasAssertions() + + const tmpPath = path.join(os.tmpdir(), 'not-a-repo') + fs.mkdirpSync(tmpPath) + execa.shellSync(' ',{ + cwd: tmpPath + }) + expect(true).toBeFalsy() + }) +})