From 0c084de06cd358a9ca3c056992d5ca854b1ae8fe Mon Sep 17 00:00:00 2001 From: Nicolas Beaussart Date: Thu, 13 Feb 2020 16:48:08 +0100 Subject: [PATCH] :white_check_mark: fix tests --- .circleci/config.yml | 2 +- src/tests/add/prettier.spec.ts | 4 ++- src/tests/add/tailwind.spec.ts | 4 ++- .../base-add-command.spec.ts.snap | 28 ++----------------- src/utls/base-add-command.spec.ts | 8 ++++-- 5 files changed, 16 insertions(+), 30 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b005fe7..9859c92 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,7 +22,7 @@ jobs: - run: ./bin/run --help - run: name: Testing - command: yarn test + command: yarn test --ci - run: name: Sending to codecov command: yarn codecov diff --git a/src/tests/add/prettier.spec.ts b/src/tests/add/prettier.spec.ts index fbf3303..4d2ca48 100644 --- a/src/tests/add/prettier.spec.ts +++ b/src/tests/add/prettier.spec.ts @@ -12,7 +12,7 @@ let execPath: string; const originalCwd = process.cwd(); const originalLog = console.log; -beforeEach(() => { +beforeEach(async () => { consoleLogOutput = []; console.log = (x: any) => consoleLogOutput.push(stripANSI(x)); @@ -20,6 +20,8 @@ beforeEach(() => { execPath = filesystem.path('/', 'tmp', tmpDirName); filesystem.dir(execPath); process.chdir(execPath); + await system.run('git config --global user.email "you@example.com"'); + await system.run('git config --global user.name "Your Name"'); }); afterEach(() => { console.log = originalLog; diff --git a/src/tests/add/tailwind.spec.ts b/src/tests/add/tailwind.spec.ts index 2b2ecfd..5e9a307 100644 --- a/src/tests/add/tailwind.spec.ts +++ b/src/tests/add/tailwind.spec.ts @@ -12,7 +12,7 @@ let execPath: string; const originalCwd = process.cwd(); const originalLog = console.log; -beforeEach(() => { +beforeEach(async () => { consoleLogOutput = []; console.log = (x: any) => consoleLogOutput.push(stripANSI(x)); @@ -20,6 +20,8 @@ beforeEach(() => { execPath = filesystem.path('/', 'tmp', tmpDirName); filesystem.dir(execPath); process.chdir(execPath); + await system.run('git config --global user.email "you@example.com"'); + await system.run('git config --global user.name "Your Name"'); }); afterEach(() => { console.log = originalLog; diff --git a/src/utls/__snapshots__/base-add-command.spec.ts.snap b/src/utls/__snapshots__/base-add-command.spec.ts.snap index 74ae5bb..6422e5b 100644 --- a/src/utls/__snapshots__/base-add-command.spec.ts.snap +++ b/src/utls/__snapshots__/base-add-command.spec.ts.snap @@ -56,30 +56,8 @@ exports[`BaseAddCommand addDevDependency should add the dependancy without git 2 exports[`BaseAddCommand gitAddUnstaged should add uncommited changes 1`] = ` "A .nbxrc -A test.11.md -A test.12.md -A test.13.md -A test.14.md -A test.15.md -A test.21.md -A test.22.md -A test.23.md -A test.24.md -A test.25.md -A test.31.md -A test.32.md -A test.33.md -A test.34.md -A test.35.md -A test.41.md -A test.42.md -A test.43.md -A test.44.md -A test.45.md -A test.51.md -A test.52.md -A test.53.md -A test.54.md -A test.55.md +A test.1.md +A test.2.md +A test.3.md " `; diff --git a/src/utls/base-add-command.spec.ts b/src/utls/base-add-command.spec.ts index dcdd812..999bc8d 100644 --- a/src/utls/base-add-command.spec.ts +++ b/src/utls/base-add-command.spec.ts @@ -10,7 +10,7 @@ let execPath: string; const originalCwd = process.cwd(); const originalLog = console.log; -beforeEach(() => { +beforeEach(async () => { consoleLogOutput = []; console.log = (x: any) => consoleLogOutput.push(stripANSI(x)); @@ -18,6 +18,8 @@ beforeEach(() => { execPath = filesystem.path('/', 'tmp', tmpDirName); filesystem.dir(execPath); process.chdir(execPath); + await system.run('git config --global user.email "you@example.com"'); + await system.run('git config --global user.name "Your Name"'); }); afterEach(() => { console.log = originalLog; @@ -259,7 +261,9 @@ describe('BaseAddCommand', () => { it('should add uncommited changes', async () => { await system.run('git init'); filesystem.write('.nbxrc', { git: { user: 'aaa', email: 'bbb' } }); - await system.run('touch test.{1,2,3,4,5}{1,2,3,4,5}.md'); + await system.run('touch test.1.md'); + await system.run('touch test.2.md'); + await system.run('touch test.3.md'); await RunCommand.run(['gitAddUnstaged']);