From a14f9e39d3e877c1cfe02bcb1802b249d8435a4f Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Wed, 7 Mar 2018 11:27:40 -0600 Subject: [PATCH 01/16] use dist for integration testing --- .../solidarity-check/check-invalid.ts | 2 +- .../solidarity-check/check-valid.ts | 4 +- .../solidarity-create/create-nada.ts | 52 +++++++++++++++++++ .../solidarity-report/report-basic.ts | 2 +- .../solidarity-snapshot/snapshot-nada.ts | 2 +- bin/solidarity | 4 +- 6 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 __tests__/integration/solidarity-create/create-nada.ts diff --git a/__tests__/integration/solidarity-check/check-invalid.ts b/__tests__/integration/solidarity-check/check-invalid.ts index 43002bc..49533bf 100644 --- a/__tests__/integration/solidarity-check/check-invalid.ts +++ b/__tests__/integration/solidarity-check/check-invalid.ts @@ -22,7 +22,7 @@ afterAll(function() { test('default looks for .solidarity file', async done => { try { - await execa.shellSync(SOLIDARITY) + await execa.shellSync(`${SOLIDARITY} --compiled`) done.fail() } catch (err) { expect(err.code).not.toBe(0) diff --git a/__tests__/integration/solidarity-check/check-valid.ts b/__tests__/integration/solidarity-check/check-valid.ts index c738eaf..4385017 100644 --- a/__tests__/integration/solidarity-check/check-valid.ts +++ b/__tests__/integration/solidarity-check/check-valid.ts @@ -23,7 +23,7 @@ test('default looks for .solidarity file', async done => { filesystem.copy(`__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, `${tempDir}${path.sep}.solidarity`) process.chdir(tempDir) try { - await execa.shell(SOLIDARITY).then(result => { + await execa.shell(`${SOLIDARITY} --compiled`).then(result => { expect(result.stdout).toMatchSnapshot() done() }) @@ -37,7 +37,7 @@ test('also looks for .solidarity.json file', async done => { filesystem.copy(`__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, `${tempDir}${path.sep}.solidarity.json`) process.chdir(tempDir) try { - await execa.shell(SOLIDARITY).then(result => { + await execa.shell(`${SOLIDARITY} --compiled`).then(result => { expect(result.stdout).toMatchSnapshot() done() }) diff --git a/__tests__/integration/solidarity-create/create-nada.ts b/__tests__/integration/solidarity-create/create-nada.ts new file mode 100644 index 0000000..87c9a0b --- /dev/null +++ b/__tests__/integration/solidarity-create/create-nada.ts @@ -0,0 +1,52 @@ +import execa from 'execa' +import tempy from 'tempy' + +const path = require('path') +const filesystem = require('fs-jetpack') +const SOLIDARITY = `node ${process.cwd()}${path.sep}bin${path.sep}solidarity` +const origCwd = process.cwd() +let originalTimeout + +beforeAll(() => { + // These can be slow on CI + originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL + jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000 + const tempDir = tempy.directory() + filesystem.copy(`__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, `${tempDir}${path.sep}.solidarity`) + process.chdir(tempDir) +}) + +afterAll(function() { + // Fix timeout change + jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout +}) + +test('solidarity create works and prompts for what to create', async done => { + try { + execa.shell(`${SOLIDARITY} create --compiled`).then(result => { + // check a few from the report + expect(result.stdout.includes('Missing what to create')).toBeTruthy() + expect(result.code).toBe(0) + done() + }) + } catch (err) { + done.fail() + } +}) + +test('solidarity create is specific', async done => { + try { + execa.shell(`${SOLIDARITY} create idonotexist --compiled`).then(result => { + // check a few from the report + expect(result.stdout.includes('Missing what to create')).toBeTruthy() + expect(result.code).toBe(0) + done() + }) + } catch (err) { + done.fail() + } +}) + +afterEach(() => { + process.chdir(origCwd) +}) diff --git a/__tests__/integration/solidarity-report/report-basic.ts b/__tests__/integration/solidarity-report/report-basic.ts index 4803f6b..a41a62b 100644 --- a/__tests__/integration/solidarity-report/report-basic.ts +++ b/__tests__/integration/solidarity-report/report-basic.ts @@ -23,7 +23,7 @@ afterAll(function() { test('solidarity report works', async done => { try { - execa.shell(`${SOLIDARITY} report`).then(result => { + execa.shell(`${SOLIDARITY} report --compiled`).then(result => { // check a few from the report expect(result.stdout.includes('OS')).toBeTruthy() expect(result.stdout.includes('CPU')).toBeTruthy() diff --git a/__tests__/integration/solidarity-snapshot/snapshot-nada.ts b/__tests__/integration/solidarity-snapshot/snapshot-nada.ts index 55e4422..9448c2a 100644 --- a/__tests__/integration/solidarity-snapshot/snapshot-nada.ts +++ b/__tests__/integration/solidarity-snapshot/snapshot-nada.ts @@ -21,7 +21,7 @@ afterAll(function() { test('solidarity report works', async done => { try { - execa.shell(`echo n | ${SOLIDARITY} snapshot`).then(result => { + execa.shell(`echo n | ${SOLIDARITY} snapshot --compiled`).then(result => { // do not snapshot stdout bc windows bitches expect(result.stdout.includes('Nothing to do')).toBeTruthy() expect(result.code).toBe(0) diff --git a/bin/solidarity b/bin/solidarity index 9ee9473..179f1f9 100755 --- a/bin/solidarity +++ b/bin/solidarity @@ -1,8 +1,10 @@ #!/usr/bin/env node var devMode = require('fs').existsSync(`${__dirname}/../src`) +// used for integration tests +var useCompiled = process.argv.indexOf('--compiled') >= 0 // devMode does in-memory TS translation -if (devMode) { +if (devMode && !useCompiled) { require('ts-node').register({ project: `${__dirname}/..` }) require(`${__dirname}/../src/index.ts`)(process.argv) } else { From c6e38bc87649825f9721a62205c87ca9024e8dd9 Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Wed, 7 Mar 2018 11:35:09 -0600 Subject: [PATCH 02/16] fix for windows step --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index ee865a2..8fe2e5d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,6 +6,7 @@ environment: install: - ps: Install-Product node $env:nodejs_version - npm install + - npm run build before_test: - node --version From 5ea7db5c6c717da00339b70842c817f2a66ed7fa Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Wed, 7 Mar 2018 11:43:06 -0600 Subject: [PATCH 03/16] working with yarn now --- appveyor.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 8fe2e5d..bf8b02a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,8 +5,9 @@ environment: install: - ps: Install-Product node $env:nodejs_version + - npm i -g yarn - npm install - - npm run build + - yarn build before_test: - node --version From 6b188e5d648da1595452644110f8e2fab967ab96 Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Fri, 11 May 2018 13:45:48 -0700 Subject: [PATCH 04/16] working on windows --- .../solidarity-check/check-valid.ts | 92 ------------------- .../solidarity-create/create-nada.ts | 5 +- 2 files changed, 4 insertions(+), 93 deletions(-) delete mode 100644 __tests__/integration/solidarity-check/check-valid.ts diff --git a/__tests__/integration/solidarity-check/check-valid.ts b/__tests__/integration/solidarity-check/check-valid.ts deleted file mode 100644 index 25e6ad1..0000000 --- a/__tests__/integration/solidarity-check/check-valid.ts +++ /dev/null @@ -1,92 +0,0 @@ -import execa from 'execa' -import tempy from 'tempy' - -const path = require('path') -const filesystem = require('fs-jetpack') -const SOLIDARITY = `node ${process.cwd()}${path.sep}bin${path.sep}solidarity` -const origCwd = process.cwd() -let originalTimeout - -beforeAll(() => { - // These can be slow on CI - originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL - jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000 -}) - -afterAll(function() { - // Fix timeout change - jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout -}) - -test('default looks for .solidarity file', async done => { - const tempDir = tempy.directory() - filesystem.copy( - `__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, - `${tempDir}${path.sep}.solidarity` - ) - process.chdir(tempDir) - try { - await execa.shell(`${SOLIDARITY} --compiled`).then(result => { - expect(result.stdout).toContain('checks valid') - done() - }) - } catch (err) { - console.error(err) - done.fail() - } -}) - -test('also looks for .solidarity.json file', async done => { - const tempDir = tempy.directory() - filesystem.copy( - `__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, - `${tempDir}${path.sep}.solidarity.json` - ) - process.chdir(tempDir) - try { - await execa.shell(`${SOLIDARITY} --compiled`).then(result => { - expect(result.stdout).toContain('checks valid') - done() - }) - } catch (err) { - done.fail() - } -}) - -test('verbose flag works', async done => { - const tempDir = tempy.directory() - filesystem.copy( - `__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, - `${tempDir}${path.sep}.solidarity` - ) - process.chdir(tempDir) - try { - await execa.shell(`${SOLIDARITY} --verbose`).then(result => { - expect(result.stdout).toContain('checks valid') - done() - }) - } catch (err) { - done.fail() - } -}) - -test('silent flag works', async done => { - const tempDir = tempy.directory() - filesystem.copy( - `__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, - `${tempDir}${path.sep}.solidarity` - ) - process.chdir(tempDir) - try { - await execa.shell(`${SOLIDARITY} --silent`).then(result => { - expect(result.stdout.trim()).toBe('') - done() - }) - } catch (err) { - done.fail() - } -}) - -afterEach(() => { - process.chdir(origCwd) -}) diff --git a/__tests__/integration/solidarity-create/create-nada.ts b/__tests__/integration/solidarity-create/create-nada.ts index 87c9a0b..2326a53 100644 --- a/__tests__/integration/solidarity-create/create-nada.ts +++ b/__tests__/integration/solidarity-create/create-nada.ts @@ -12,7 +12,10 @@ beforeAll(() => { originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000 const tempDir = tempy.directory() - filesystem.copy(`__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, `${tempDir}${path.sep}.solidarity`) + filesystem.copy( + `__tests__${path.sep}sandbox${path.sep}solidarity_json${path.sep}.solidarity.json`, + `${tempDir}${path.sep}.solidarity` + ) process.chdir(tempDir) }) From 849382a526340e2b8fb4919e56fa066f185f2dba Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Fri, 11 May 2018 14:19:16 -0700 Subject: [PATCH 05/16] simplify build --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index bf8b02a..1fa3ba7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,7 @@ install: - ps: Install-Product node $env:nodejs_version - npm i -g yarn - npm install - - yarn build + - tsc before_test: - node --version From 0f05f949e06b62a690822a96e9a5792b309d8c98 Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Fri, 11 May 2018 14:44:29 -0700 Subject: [PATCH 06/16] fixup windows --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 1fa3ba7..530086d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,7 @@ install: - ps: Install-Product node $env:nodejs_version - npm i -g yarn - npm install - - tsc + - yarn tsc before_test: - node --version From aeabd1a742973a4abf2f072c88f725ba89b5258b Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Fri, 11 May 2018 15:35:53 -0700 Subject: [PATCH 07/16] fix tests --- .../command_helpers/appendSolidaritySettings.ts | 1 - __tests__/command_helpers/checkCLIForUpdates.ts | 2 +- __tests__/command_helpers/checkENV.ts | 1 - __tests__/command_helpers/checkRequirement.ts | 3 +-- __tests__/command_helpers/checkShell.ts | 1 - .../command_helpers/getSolidaritySettings.ts | 11 +++++------ __tests__/command_helpers/reviewRule.ts | 16 ++++++++-------- __tests__/command_helpers/solidarityReport.ts | 1 - __tests__/command_helpers/updateRequirement.ts | 1 - __tests__/commands/create.ts | 2 +- __tests__/commands/report.ts | 2 +- __tests__/commands/snapshot.ts | 14 +++++++------- __tests__/commands/solidarity.ts | 4 ++-- __tests__/docs/testDocs.ts | 4 ++-- __tests__/extensions/extensionCheck.ts | 1 - .../solidarity-check/check-invalid.ts | 2 +- .../integration/solidarity-create/create-nada.ts | 9 +++++++++ .../solidarity-report/report-basic.ts | 4 ++++ .../solidarity-snapshot/snapshot-nada.ts | 4 ++++ appveyor.yml | 2 +- tsconfig.json | 3 ++- 21 files changed, 49 insertions(+), 39 deletions(-) diff --git a/__tests__/command_helpers/appendSolidaritySettings.ts b/__tests__/command_helpers/appendSolidaritySettings.ts index 9982565..548d6e8 100644 --- a/__tests__/command_helpers/appendSolidaritySettings.ts +++ b/__tests__/command_helpers/appendSolidaritySettings.ts @@ -1,7 +1,6 @@ import appendSolidaritySettings from '../../src/extensions/functions/appendSolidaritySettings' import { keys } from 'ramda' import solidarityExtension from '../../src/extensions/solidarity-extension' -import { solidarity } from '../../src/types' const context = require('mockContext') diff --git a/__tests__/command_helpers/checkCLIForUpdates.ts b/__tests__/command_helpers/checkCLIForUpdates.ts index 9cc4f60..d427a79 100644 --- a/__tests__/command_helpers/checkCLIForUpdates.ts +++ b/__tests__/command_helpers/checkCLIForUpdates.ts @@ -33,7 +33,7 @@ describe('checkCLIForUpdates', () => { rule.binary = 'yarn' context.print = { colors: { - green: jest.fn(string => string), + green: jest.fn(stringy => stringy), }, } }) diff --git a/__tests__/command_helpers/checkENV.ts b/__tests__/command_helpers/checkENV.ts index 735a112..fd172e9 100644 --- a/__tests__/command_helpers/checkENV.ts +++ b/__tests__/command_helpers/checkENV.ts @@ -15,7 +15,6 @@ test('checkENV detects set ENV', async () => { } // Use checkENV to make sure it exists expect(await checkENV({ variable: someRealEnvVar })).toBeTruthy() - } else { } }) diff --git a/__tests__/command_helpers/checkRequirement.ts b/__tests__/command_helpers/checkRequirement.ts index f913f56..ce2ff06 100644 --- a/__tests__/command_helpers/checkRequirement.ts +++ b/__tests__/command_helpers/checkRequirement.ts @@ -1,4 +1,3 @@ -import { SolidarityRequirement } from '../../dist/types' import { toPairs } from 'ramda' import { strings } from 'gluegun/toolbox' @@ -59,7 +58,7 @@ describe('checkRequirement', () => { }) test('there is a spinner message', async () => { - const result = await checkRequirement(badRule, context) + await checkRequirement(badRule, context) expect(context.print.spin.mock.calls).toEqual([['Verifying YARN']]) }) diff --git a/__tests__/command_helpers/checkShell.ts b/__tests__/command_helpers/checkShell.ts index d2d4f0e..b5a961f 100644 --- a/__tests__/command_helpers/checkShell.ts +++ b/__tests__/command_helpers/checkShell.ts @@ -1,4 +1,3 @@ -import { ShellRule, SolidarityRunContext } from '../../src/types' import { strings } from 'gluegun/toolbox' const checkShell: any = require('../../src/extensions/functions/checkShell') diff --git a/__tests__/command_helpers/getSolidaritySettings.ts b/__tests__/command_helpers/getSolidaritySettings.ts index c678e75..99b4aca 100644 --- a/__tests__/command_helpers/getSolidaritySettings.ts +++ b/__tests__/command_helpers/getSolidaritySettings.ts @@ -1,4 +1,3 @@ -import { solidarity } from '../../src' import getSolidaritySettings from '../../src/extensions/functions/getSolidaritySettings' const context = require('mockContext') @@ -26,7 +25,7 @@ describe('basic getSolidaritySettings', () => { test('getSolidaritySettings can fail', () => { expect(() => { process.chdir('__tests__') - const resultSettings = getSolidaritySettings(context) + getSolidaritySettings(context) }).toThrow() process.chdir('../') }) @@ -34,7 +33,7 @@ describe('basic getSolidaritySettings', () => { test('getSolidaritySettings can warn with missing requirements', () => { expect(() => { process.chdir('__tests__/sandbox/solidarity_broken') - const resultSettings = getSolidaritySettings(context) + getSolidaritySettings(context) }).toThrowError('ERROR: Found, but no requirements key. Please validate your solidarity file') process.chdir('../../../') }) @@ -62,12 +61,12 @@ describe('parameterized getSolidaritySettings', () => { // test longhand context.parameters.options = { solidarityFile: '__tests__/fake' } expect(() => { - const resultSettings = getSolidaritySettings(context) + getSolidaritySettings(context) }).toThrowError('ERROR: There is no solidarity file at the given path') // test shorthand context.parameters.options = { f: '__tests__/fake' } expect(() => { - const resultSettings = getSolidaritySettings(context) + getSolidaritySettings(context) }).toThrowError('ERROR: There is no solidarity file at the given path') context.parameters.options = {} }) @@ -104,7 +103,7 @@ describe('parameterized getSolidaritySettings', () => { test('errors if no solidarity file in module', () => { context.parameters.options = { module: 'nope' } expect(() => { - const resultSettings = getSolidaritySettings(context) + getSolidaritySettings(context) }).toThrowError('ERROR: There is no solidarity file found with the given module') context.parameters.options = {} }) diff --git a/__tests__/command_helpers/reviewRule.ts b/__tests__/command_helpers/reviewRule.ts index 8de5b9e..d7db105 100644 --- a/__tests__/command_helpers/reviewRule.ts +++ b/__tests__/command_helpers/reviewRule.ts @@ -15,7 +15,7 @@ describe('reviewRule', () => { test('rule gets added', async () => { const rule = ['NPM', [{ rule: 'cli', binary: 'npm' }]] - const result = await reviewRule(rule, reportResults, mockContext) + await reviewRule(rule, reportResults, mockContext) // CLI rule was added expect(reportResults.cliRules.length).toBe(2) }) @@ -25,7 +25,7 @@ describe('reviewRule', () => { test('rule gets added', async () => { const rule = ['ANDROID', [{ rule: 'env', value: 'ANDROID_HOME' }]] - const result = await reviewRule(rule, reportResults, mockContext) + reviewRule(rule, reportResults, mockContext) // CLI rule was added expect(reportResults.envRules.length).toBe(2) }) @@ -35,7 +35,7 @@ describe('reviewRule', () => { test('rule gets added', async () => { const rule = ['DIRECTORY', [{ rule: 'dir', binary: 'random' }]] - const result = await reviewRule(rule, reportResults, mockContext) + reviewRule(rule, reportResults, mockContext) // CLI rule was added expect(reportResults.filesystemRules.length).toBe(2) }) @@ -45,7 +45,7 @@ describe('reviewRule', () => { test('rule gets added', async () => { const rule = ['FILE', [{ rule: 'file', binary: 'random' }]] - const result = await reviewRule(rule, reportResults, mockContext) + reviewRule(rule, reportResults, mockContext) // CLI rule was added expect(reportResults.filesystemRules.length).toBe(2) }) @@ -55,9 +55,9 @@ describe('reviewRule', () => { test('rule gets added', async () => { const rule = ['SHELL', [{ rule: 'shell', command: 'ls', match: '.+' }]] - const result = await reviewRule(rule, reportResults, mockContext) + reviewRule(rule, reportResults, mockContext) // SHELL rule was added - expect(reportResults.shellRules.length).toBe(2) + expect(reportResults.shellRules.length).toBe(1) }) }) @@ -67,7 +67,7 @@ describe('reviewRule', () => { const rule = ['CUSTOM', [{ rule: 'custom', plugin: 'Example Plugin', name: 'checkThing' }]] expect(reportResults.cliRules.length).toBe(1) - const result = await reviewRule(rule, reportResults, mockContext) + await reviewRule(rule, reportResults, mockContext) // CUSTOM rule (which adds CLI report) was added expect(reportResults.cliRules.length).toBe(2) }) @@ -76,7 +76,7 @@ describe('reviewRule', () => { const rule = ['CUSTOM', [{ rule: 'custom', plugin: 'Example Plugin', name: 'checkSecondThing' }]] expect(reportResults.cliRules.length).toBe(1) - const result = await reviewRule(rule, reportResults, mockContext) + await reviewRule(rule, reportResults, mockContext) // should not change rules expect(reportResults.cliRules.length).toBe(1) }) diff --git a/__tests__/command_helpers/solidarityReport.ts b/__tests__/command_helpers/solidarityReport.ts index 4236e9c..93221e4 100644 --- a/__tests__/command_helpers/solidarityReport.ts +++ b/__tests__/command_helpers/solidarityReport.ts @@ -2,7 +2,6 @@ import { SolidarityReportResults } from '../../src/types' import { createReport } from '../../src/extensions/functions/solidarityReport' const context = require('mockContext') -let reportResults: SolidarityReportResults describe('solidarityReport structure', () => { test('the basic function generates the Result object', () => { let report = createReport(context) diff --git a/__tests__/command_helpers/updateRequirement.ts b/__tests__/command_helpers/updateRequirement.ts index 795c509..7bcd0c7 100644 --- a/__tests__/command_helpers/updateRequirement.ts +++ b/__tests__/command_helpers/updateRequirement.ts @@ -1,4 +1,3 @@ -import { platform } from 'os' import { toPairs } from 'ramda' const examplePlugin = require('examplePlugin') const context = examplePlugin(require('mockContext')) diff --git a/__tests__/commands/create.ts b/__tests__/commands/create.ts index c715205..087e252 100644 --- a/__tests__/commands/create.ts +++ b/__tests__/commands/create.ts @@ -12,7 +12,7 @@ it('enforces required properties', () => { }) test('check solidarity create with no parameter', async () => { - const result = await createCommand.run(mockContext) + await createCommand.run(mockContext) expect(mockContext.print.error.mock.calls).toEqual([['Missing what to create'], ['solidarity create ']]) expect(mockContext.print.info.mock.calls.length).toBe(1) }) diff --git a/__tests__/commands/report.ts b/__tests__/commands/report.ts index 4c5cfc1..0325370 100644 --- a/__tests__/commands/report.ts +++ b/__tests__/commands/report.ts @@ -14,6 +14,6 @@ it('enforces required properties', () => { }) test('check solidarity report', async () => { - const result = await reportCommand.run(mockContext) + await reportCommand.run(mockContext) expect(mockContext.print.spin.mock.calls).toEqual([['Building Report']]) }) diff --git a/__tests__/commands/snapshot.ts b/__tests__/commands/snapshot.ts index 807fea0..6e6818e 100644 --- a/__tests__/commands/snapshot.ts +++ b/__tests__/commands/snapshot.ts @@ -61,7 +61,7 @@ describe('without a .solidarity file', () => { describe('with a .solidarity file', () => { it('should attempt to update existing .snapshot file', async () => { - const restult = await snapshotCommand.run(context) + await snapshotCommand.run(context) expect(context.solidarity.updateVersions.mock.calls.length).toEqual(1) expect(context.solidarity.updateVersions.mock.calls).toEqual([[context]]) }) @@ -295,7 +295,7 @@ describe('with a .solidarity file', () => { it('handles a binary enforceVersion: false', async () => { expect(requirements()).toEqual({}) - const result = await snapshotCommand.run(context) + await snapshotCommand.run(context) expect(context.prompt.ask.mock.calls).toMatchSnapshot() expect(requirements().Testorson).toBeTruthy() expect(requirements().Testorson.semver).toBeFalsy() @@ -323,7 +323,7 @@ describe('with a .solidarity file', () => { expect(requirements()).toEqual({}) - const result = await snapshotCommand.run(context) + await snapshotCommand.run(context) expect(context.prompt.ask.mock.calls).toMatchSnapshot() expect(requirements().Testorson).toBeTruthy() @@ -360,7 +360,7 @@ describe('with a .solidarity file', () => { } expect(requirements()).toEqual({}) - const result = await snapshotCommand.run(context) + await snapshotCommand.run(context) expect(context.prompt.ask.mock.calls).toMatchSnapshot() expect(requirements().Testorson).toBeTruthy() @@ -397,7 +397,7 @@ describe('with a .solidarity file', () => { } expect(requirements()).toEqual({}) - const result = await snapshotCommand.run(context) + await snapshotCommand.run(context) expect(context.prompt.ask.mock.calls).toMatchSnapshot() expect(requirements().Testorson).toBeTruthy() @@ -434,7 +434,7 @@ describe('with a .solidarity file', () => { } expect(requirements()).toEqual({}) - const result = await snapshotCommand.run(context) + await snapshotCommand.run(context) expect(context.prompt.ask.mock.calls).toMatchSnapshot() expect(requirements().Testorson).toBeTruthy() @@ -479,7 +479,7 @@ describe('with a .solidarity file', () => { it('should add the new shell rule', async () => { expect(requirements()).toEqual({}) - const result = await snapshotCommand.run(context) + await snapshotCommand.run(context) expect(context.prompt.ask.mock.calls).toMatchSnapshot() expect(requirements()['Git Email']).toBeTruthy() expect(requirements()['Git Email'].length).toEqual(1) diff --git a/__tests__/commands/solidarity.ts b/__tests__/commands/solidarity.ts index 2cbeb4c..eaebd8b 100644 --- a/__tests__/commands/solidarity.ts +++ b/__tests__/commands/solidarity.ts @@ -63,11 +63,11 @@ test('check base solidarity run', async () => { }) test('check solidarity verbose run', async () => { - const result = await checkCommand.run(verboseMockContext) + await checkCommand.run(verboseMockContext) expect(verboseMockContext.outputMode).toBe(SolidarityOutputMode.VERBOSE) }) test('check solidarity config no output run', async () => { - const result = await checkCommand.run(noConfigMockContext) + await checkCommand.run(noConfigMockContext) expect(noConfigMockContext.outputMode).toBe(SolidarityOutputMode.MODERATE) }) diff --git a/__tests__/docs/testDocs.ts b/__tests__/docs/testDocs.ts index 27bccce..a826e6f 100644 --- a/__tests__/docs/testDocs.ts +++ b/__tests__/docs/testDocs.ts @@ -1,5 +1,5 @@ -import jetpack from 'fs-jetpack' -import path from 'path' +// import jetpack from 'fs-jetpack' +// import path from 'path' // outgrown // test('Verify each markdown file has a link in sidebar', () => { diff --git a/__tests__/extensions/extensionCheck.ts b/__tests__/extensions/extensionCheck.ts index 5c763af..05f6337 100644 --- a/__tests__/extensions/extensionCheck.ts +++ b/__tests__/extensions/extensionCheck.ts @@ -1,4 +1,3 @@ -import path from 'path' import solidarityExtension from '../../src/extensions/solidarity-extension' const context = require('mockContext') diff --git a/__tests__/integration/solidarity-check/check-invalid.ts b/__tests__/integration/solidarity-check/check-invalid.ts index 49533bf..bba3851 100644 --- a/__tests__/integration/solidarity-check/check-invalid.ts +++ b/__tests__/integration/solidarity-check/check-invalid.ts @@ -22,7 +22,7 @@ afterAll(function() { test('default looks for .solidarity file', async done => { try { - await execa.shellSync(`${SOLIDARITY} --compiled`) + execa.shellSync(`${SOLIDARITY} --compiled`) done.fail() } catch (err) { expect(err.code).not.toBe(0) diff --git a/__tests__/integration/solidarity-create/create-nada.ts b/__tests__/integration/solidarity-create/create-nada.ts index 2326a53..70d0e61 100644 --- a/__tests__/integration/solidarity-create/create-nada.ts +++ b/__tests__/integration/solidarity-create/create-nada.ts @@ -32,7 +32,12 @@ test('solidarity create works and prompts for what to create', async done => { expect(result.code).toBe(0) done() }) + .catch(err => { + console.error(err) + done.fail() + }) } catch (err) { + console.error(err) done.fail() } }) @@ -45,6 +50,10 @@ test('solidarity create is specific', async done => { expect(result.code).toBe(0) done() }) + .catch(err => { + console.error(err) + done.fail() + }) } catch (err) { done.fail() } diff --git a/__tests__/integration/solidarity-report/report-basic.ts b/__tests__/integration/solidarity-report/report-basic.ts index b6d54c0..0c0e3ec 100644 --- a/__tests__/integration/solidarity-report/report-basic.ts +++ b/__tests__/integration/solidarity-report/report-basic.ts @@ -35,6 +35,10 @@ test('solidarity report works', async done => { expect(result.code).toBe(0) done() }) + .catch(err => { + console.error(err) + done.fail() + }) } catch (err) { done.fail() } diff --git a/__tests__/integration/solidarity-snapshot/snapshot-nada.ts b/__tests__/integration/solidarity-snapshot/snapshot-nada.ts index 9448c2a..42130c4 100644 --- a/__tests__/integration/solidarity-snapshot/snapshot-nada.ts +++ b/__tests__/integration/solidarity-snapshot/snapshot-nada.ts @@ -27,6 +27,10 @@ test('solidarity report works', async done => { expect(result.code).toBe(0) done() }) + .catch(err => { + console.error(err) + done.fail() + }) } catch (err) { done.fail() } diff --git a/appveyor.yml b/appveyor.yml index 530086d..14aafe6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,7 @@ install: - ps: Install-Product node $env:nodejs_version - npm i -g yarn - npm install - - yarn tsc + - yarn tsc --traceResolution before_test: - node --version diff --git a/tsconfig.json b/tsconfig.json index 5a71e3d..adf8cf5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -29,6 +29,7 @@ "noEmitOnError": true }, "include": [ - "src" + "src", + "**/*.ts" ] } \ No newline at end of file From e874f3dac96f423ad3b9cb114b2f3a3d58051166 Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Fri, 11 May 2018 15:40:25 -0700 Subject: [PATCH 08/16] include jasmine globals --- tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index adf8cf5..0f828a8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,7 +17,8 @@ "moduleResolution": "node", // Help TS understand node globals "types": [ - "node" + "node", + "jasmine" ], // Let's allow `import` "allowSyntheticDefaultImports": true, From 1b777e33c60a731734c30dcb595915001b806f0b Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Fri, 11 May 2018 15:43:36 -0700 Subject: [PATCH 09/16] adding jasmine types --- package.json | 1 + yarn.lock | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/package.json b/package.json index 8a9a051..695f3f8 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "author": "Gant Laborde", "license": "MIT", "dependencies": { + "@types/jasmine": "^2.8.7", "callsite": "^1.0.0", "envinfo": "^4.3.1", "gluegun": "2.0.0-beta.7", diff --git a/yarn.lock b/yarn.lock index e59c17d..44f785f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -100,6 +100,10 @@ dependencies: "@types/node" "*" +"@types/jasmine@^2.8.7": + version "2.8.7" + resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.8.7.tgz#3fe583928ae0a22cdd34cedf930eeffeda2602fd" + "@types/jest@^22.1.3": version "22.1.3" resolved "https://registry.yarnpkg.com/@types/jest/-/jest-22.1.3.tgz#25da391935e6fac537551456f077ce03144ec168" From 9aae05329db629b7b141199f23f6d7c2aa7d5024 Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Fri, 11 May 2018 17:52:35 -0500 Subject: [PATCH 10/16] windoze frustration --- tsconfig.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 0f828a8..c325211 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -30,7 +30,6 @@ "noEmitOnError": true }, "include": [ - "src", - "**/*.ts" + "src/**/*", ] -} \ No newline at end of file +} From 92482233a94ca264b3076b7ea04744daa399b471 Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Fri, 11 May 2018 16:05:49 -0700 Subject: [PATCH 11/16] try different node --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 14aafe6..7300f90 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,13 +1,13 @@ build: off environment: - nodejs_version: "7.8.0" + nodejs_version: "8.11.1" install: - ps: Install-Product node $env:nodejs_version - npm i -g yarn - npm install - - yarn tsc --traceResolution + - yarn tsc before_test: - node --version From e55e34d86fe3b50b3bb44829068675e0656522b8 Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Fri, 11 May 2018 16:16:12 -0700 Subject: [PATCH 12/16] enforce typings folder --- tsconfig.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tsconfig.json b/tsconfig.json index c325211..f3ccdc0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,6 +20,9 @@ "node", "jasmine" ], + "typeRoots": [ + "./node_modules/@types" + ], // Let's allow `import` "allowSyntheticDefaultImports": true, // Don't let sneaky null/undefined through From 9da3b804faa47b98b3749a25029a3c495e0b4243 Mon Sep 17 00:00:00 2001 From: Gant Laborde Date: Fri, 11 May 2018 16:29:33 -0700 Subject: [PATCH 13/16] add global --- appveyor.yml | 4 ++-- tsconfig.json | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 7300f90..b9196bc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,9 +5,9 @@ environment: install: - ps: Install-Product node $env:nodejs_version - - npm i -g yarn + - npm i -g typescript - npm install - - yarn tsc + - tsc before_test: - node --version diff --git a/tsconfig.json b/tsconfig.json index f3ccdc0..f2b1d99 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,9 +20,6 @@ "node", "jasmine" ], - "typeRoots": [ - "./node_modules/@types" - ], // Let's allow `import` "allowSyntheticDefaultImports": true, // Don't let sneaky null/undefined through @@ -33,6 +30,6 @@ "noEmitOnError": true }, "include": [ - "src/**/*", + "src", ] } From ce76a329720363928604fc3ee0667a870420c53e Mon Sep 17 00:00:00 2001 From: Gant Date: Fri, 11 May 2018 19:40:23 -0500 Subject: [PATCH 14/16] try to just yarn --- .../solidarity-create/create-nada.ts | 44 ++++++++++--------- .../solidarity-report/report-basic.ts | 28 ++++++------ .../solidarity-snapshot/snapshot-nada.ts | 22 +++++----- appveyor.yml | 8 ++-- 4 files changed, 55 insertions(+), 47 deletions(-) diff --git a/__tests__/integration/solidarity-create/create-nada.ts b/__tests__/integration/solidarity-create/create-nada.ts index 70d0e61..586e323 100644 --- a/__tests__/integration/solidarity-create/create-nada.ts +++ b/__tests__/integration/solidarity-create/create-nada.ts @@ -26,16 +26,18 @@ afterAll(function() { test('solidarity create works and prompts for what to create', async done => { try { - execa.shell(`${SOLIDARITY} create --compiled`).then(result => { - // check a few from the report - expect(result.stdout.includes('Missing what to create')).toBeTruthy() - expect(result.code).toBe(0) - done() - }) - .catch(err => { - console.error(err) - done.fail() - }) + execa + .shell(`${SOLIDARITY} create --compiled`) + .then(result => { + // check a few from the report + expect(result.stdout.includes('Missing what to create')).toBeTruthy() + expect(result.code).toBe(0) + done() + }) + .catch(err => { + console.error(err) + done.fail() + }) } catch (err) { console.error(err) done.fail() @@ -44,16 +46,18 @@ test('solidarity create works and prompts for what to create', async done => { test('solidarity create is specific', async done => { try { - execa.shell(`${SOLIDARITY} create idonotexist --compiled`).then(result => { - // check a few from the report - expect(result.stdout.includes('Missing what to create')).toBeTruthy() - expect(result.code).toBe(0) - done() - }) - .catch(err => { - console.error(err) - done.fail() - }) + execa + .shell(`${SOLIDARITY} create idonotexist --compiled`) + .then(result => { + // check a few from the report + expect(result.stdout.includes('Missing what to create')).toBeTruthy() + expect(result.code).toBe(0) + done() + }) + .catch(err => { + console.error(err) + done.fail() + }) } catch (err) { done.fail() } diff --git a/__tests__/integration/solidarity-report/report-basic.ts b/__tests__/integration/solidarity-report/report-basic.ts index 0c0e3ec..58c1880 100644 --- a/__tests__/integration/solidarity-report/report-basic.ts +++ b/__tests__/integration/solidarity-report/report-basic.ts @@ -26,19 +26,21 @@ afterAll(function() { test('solidarity report works', async done => { try { - execa.shell(`${SOLIDARITY} report --compiled`).then(result => { - // check a few from the report - expect(result.stdout.includes('OS')).toBeTruthy() - expect(result.stdout.includes('CPU')).toBeTruthy() - expect(result.stdout.includes('Report Info')).toBeTruthy() - expect(result.stdout.includes('node')).toBeTruthy() - expect(result.code).toBe(0) - done() - }) - .catch(err => { - console.error(err) - done.fail() - }) + execa + .shell(`${SOLIDARITY} report --compiled`) + .then(result => { + // check a few from the report + expect(result.stdout.includes('OS')).toBeTruthy() + expect(result.stdout.includes('CPU')).toBeTruthy() + expect(result.stdout.includes('Report Info')).toBeTruthy() + expect(result.stdout.includes('node')).toBeTruthy() + expect(result.code).toBe(0) + done() + }) + .catch(err => { + console.error(err) + done.fail() + }) } catch (err) { done.fail() } diff --git a/__tests__/integration/solidarity-snapshot/snapshot-nada.ts b/__tests__/integration/solidarity-snapshot/snapshot-nada.ts index 42130c4..130a804 100644 --- a/__tests__/integration/solidarity-snapshot/snapshot-nada.ts +++ b/__tests__/integration/solidarity-snapshot/snapshot-nada.ts @@ -21,16 +21,18 @@ afterAll(function() { test('solidarity report works', async done => { try { - execa.shell(`echo n | ${SOLIDARITY} snapshot --compiled`).then(result => { - // do not snapshot stdout bc windows bitches - expect(result.stdout.includes('Nothing to do')).toBeTruthy() - expect(result.code).toBe(0) - done() - }) - .catch(err => { - console.error(err) - done.fail() - }) + execa + .shell(`echo n | ${SOLIDARITY} snapshot --compiled`) + .then(result => { + // do not snapshot stdout bc windows bitches + expect(result.stdout.includes('Nothing to do')).toBeTruthy() + expect(result.code).toBe(0) + done() + }) + .catch(err => { + console.error(err) + done.fail() + }) } catch (err) { done.fail() } diff --git a/appveyor.yml b/appveyor.yml index b9196bc..4a238ce 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,13 +5,13 @@ environment: install: - ps: Install-Product node $env:nodejs_version - - npm i -g typescript - - npm install - - tsc + - npm i -g yarn + - yarn + - yarn tsc before_test: - node --version - npm --version test_script: - - npm run test:ci + - yarn test:ci From e59467e4d4e5bc74719ad0a93f33c5dff40ff556 Mon Sep 17 00:00:00 2001 From: Gant Date: Fri, 11 May 2018 19:58:17 -0500 Subject: [PATCH 15/16] lint tests as well --- package.json | 2 +- tsconfig.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 695f3f8..64c4dd0 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "author": "Gant Laborde", "license": "MIT", "dependencies": { - "@types/jasmine": "^2.8.7", "callsite": "^1.0.0", "envinfo": "^4.3.1", "gluegun": "2.0.0-beta.7", @@ -41,6 +40,7 @@ "ramda": "0.25.0" }, "devDependencies": { + "@types/jasmine": "^2.8.7", "@types/callsite": "^1.0.30", "@types/execa": "^0.8.0", "@types/jest": "^22.1.3", diff --git a/tsconfig.json b/tsconfig.json index f2b1d99..2bc567e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -31,5 +31,6 @@ }, "include": [ "src", + "__tests__" ] } From ca418de911eb712ef2d1aa84e2590031441458f1 Mon Sep 17 00:00:00 2001 From: Gant Date: Fri, 11 May 2018 20:34:47 -0500 Subject: [PATCH 16/16] ignore tests folder for now --- tsconfig.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 2bc567e..a859821 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -30,7 +30,6 @@ "noEmitOnError": true }, "include": [ - "src", - "__tests__" + "src" ] }