From d314b1745b0f5bc5fbf4dd5ee06cd3ea43ca250b Mon Sep 17 00:00:00 2001 From: StevanFreeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Tue, 14 Feb 2023 23:49:18 -0600 Subject: [PATCH] fix: organize integration tests according to method targets. fix: set timeouts and retries for integration tests --- integrationTests/{ => Apps}/getAppById.spec.ts | 7 +++++-- integrationTests/{ => Apps}/getApps.spec.ts | 7 +++++-- integrationTests/{ => Apps}/getAppsByIds.spec.ts | 7 +++++-- integrationTests/{ => Fields}/getFieldById.spec.ts | 7 +++++-- integrationTests/{ => Fields}/getFieldsByAppId.spec.ts | 7 +++++-- integrationTests/{ => Fields}/getFieldsByIds.spec.ts | 7 +++++-- integrationTests/mochaRootHooks.ts | 6 ++---- package.json | 3 +-- 8 files changed, 33 insertions(+), 18 deletions(-) rename integrationTests/{ => Apps}/getAppById.spec.ts (93%) rename integrationTests/{ => Apps}/getApps.spec.ts (94%) rename integrationTests/{ => Apps}/getAppsByIds.spec.ts (93%) rename integrationTests/{ => Fields}/getFieldById.spec.ts (94%) rename integrationTests/{ => Fields}/getFieldsByAppId.spec.ts (96%) rename integrationTests/{ => Fields}/getFieldsByIds.spec.ts (94%) diff --git a/integrationTests/getAppById.spec.ts b/integrationTests/Apps/getAppById.spec.ts similarity index 93% rename from integrationTests/getAppById.spec.ts rename to integrationTests/Apps/getAppById.spec.ts index 4c8eb3a..501593e 100644 --- a/integrationTests/getAppById.spec.ts +++ b/integrationTests/Apps/getAppById.spec.ts @@ -1,8 +1,11 @@ -import { OnspringClient } from '../src/index'; +import { OnspringClient } from '../../src/index'; import { expect } from 'chai'; -import { baseURL, apiKey } from './mochaRootHooks'; +import { baseURL, apiKey } from '../mochaRootHooks'; describe('getAppById', function () { + this.timeout(30000); + this.retries(3); + it('should return an app', async function () { const client = new OnspringClient(baseURL, apiKey); diff --git a/integrationTests/getApps.spec.ts b/integrationTests/Apps/getApps.spec.ts similarity index 94% rename from integrationTests/getApps.spec.ts rename to integrationTests/Apps/getApps.spec.ts index 98a26d6..7be5aa0 100644 --- a/integrationTests/getApps.spec.ts +++ b/integrationTests/Apps/getApps.spec.ts @@ -1,8 +1,11 @@ -import { OnspringClient, PagingRequest } from '../src/index'; +import { OnspringClient, PagingRequest } from '../../src/index'; import { expect } from 'chai'; -import { baseURL, apiKey } from './mochaRootHooks'; +import { baseURL, apiKey } from '../mochaRootHooks'; describe('getApps', function () { + this.timeout(30000); + this.retries(3); + it('should return a paged list of apps', async function () { const client = new OnspringClient(baseURL, apiKey); const response = await client.getApps(); diff --git a/integrationTests/getAppsByIds.spec.ts b/integrationTests/Apps/getAppsByIds.spec.ts similarity index 93% rename from integrationTests/getAppsByIds.spec.ts rename to integrationTests/Apps/getAppsByIds.spec.ts index 0cac689..ebd79b1 100644 --- a/integrationTests/getAppsByIds.spec.ts +++ b/integrationTests/Apps/getAppsByIds.spec.ts @@ -1,8 +1,11 @@ -import { OnspringClient } from '../src/index'; +import { OnspringClient } from '../../src/index'; import { expect } from 'chai'; -import { baseURL, apiKey } from './mochaRootHooks'; +import { baseURL, apiKey } from '../mochaRootHooks'; describe('getAppsByIds', function () { + this.timeout(30000); + this.retries(3); + it('should return a collection of apps', async function () { const client = new OnspringClient(baseURL, apiKey); const appIds = process.env.TEST_APP_IDS; diff --git a/integrationTests/getFieldById.spec.ts b/integrationTests/Fields/getFieldById.spec.ts similarity index 94% rename from integrationTests/getFieldById.spec.ts rename to integrationTests/Fields/getFieldById.spec.ts index 78780a1..005b853 100644 --- a/integrationTests/getFieldById.spec.ts +++ b/integrationTests/Fields/getFieldById.spec.ts @@ -1,8 +1,11 @@ -import { OnspringClient } from '../src/index'; +import { OnspringClient } from '../../src/index'; import { expect } from 'chai'; -import { baseURL, apiKey } from './mochaRootHooks'; +import { baseURL, apiKey } from '../mochaRootHooks'; describe('getAppById', function () { + this.timeout(30000); + this.retries(3); + it('should return a field', async function () { const client = new OnspringClient(baseURL, apiKey); diff --git a/integrationTests/getFieldsByAppId.spec.ts b/integrationTests/Fields/getFieldsByAppId.spec.ts similarity index 96% rename from integrationTests/getFieldsByAppId.spec.ts rename to integrationTests/Fields/getFieldsByAppId.spec.ts index ea03632..e7c394e 100644 --- a/integrationTests/getFieldsByAppId.spec.ts +++ b/integrationTests/Fields/getFieldsByAppId.spec.ts @@ -1,8 +1,11 @@ -import { OnspringClient, PagingRequest } from '../src/index'; +import { OnspringClient, PagingRequest } from '../../src/index'; import { expect } from 'chai'; -import { baseURL, apiKey } from './mochaRootHooks'; +import { baseURL, apiKey } from '../mochaRootHooks'; describe('getFieldsByAppId', function () { + this.timeout(30000); + this.retries(3); + it('should return a paged list of fields', async function () { const client = new OnspringClient(baseURL, apiKey); diff --git a/integrationTests/getFieldsByIds.spec.ts b/integrationTests/Fields/getFieldsByIds.spec.ts similarity index 94% rename from integrationTests/getFieldsByIds.spec.ts rename to integrationTests/Fields/getFieldsByIds.spec.ts index 1a9ce2a..d6b6370 100644 --- a/integrationTests/getFieldsByIds.spec.ts +++ b/integrationTests/Fields/getFieldsByIds.spec.ts @@ -1,8 +1,11 @@ -import { OnspringClient } from '../src/index'; +import { OnspringClient } from '../../src/index'; import { expect } from 'chai'; -import { baseURL, apiKey } from './mochaRootHooks'; +import { baseURL, apiKey } from '../mochaRootHooks'; describe('getFieldsByIds', function () { + this.timeout(30000); + this.retries(3); + it('should return a collection of fields', async function () { const client = new OnspringClient(baseURL, apiKey); diff --git a/integrationTests/mochaRootHooks.ts b/integrationTests/mochaRootHooks.ts index 21709c9..ff3939c 100644 --- a/integrationTests/mochaRootHooks.ts +++ b/integrationTests/mochaRootHooks.ts @@ -1,4 +1,4 @@ -import { type Context } from 'mocha'; +import { type RootHookObject, type Context } from 'mocha'; import { expect } from 'chai'; import * as dotenv from 'dotenv'; import path from 'path'; @@ -8,11 +8,9 @@ dotenv.config({ path: envPath }); let baseURL: string | undefined; let apiKey: string | undefined; -export const mochaHooks = (): Mocha.RootHookObject => { +export const mochaHooks = (): RootHookObject => { return { beforeAll(this: Context) { - this.timeout('30s'); - baseURL = process.env.API_BASE_URL; apiKey = process.env.SANDBOX_API_KEY; diff --git a/package.json b/package.json index f0c5ed7..129990a 100644 --- a/package.json +++ b/package.json @@ -45,8 +45,7 @@ "tests:unit": "mocha -R progress -r ts-node/register ./tests/**/*.spec.ts", "tests:integration": "mocha -R progress -r ts-node/register -r integrationTests/mochaRootHooks.ts ./integrationTests/**/*.spec.ts", "tests": "mocha -R progress -r ts-node/register ./tests/**/*.spec.ts -r ts-node/register -r integrationTests/mochaRootHooks.ts ./integrationTests/**/*.spec.ts", - "test-coverage": "nyc npm run tests:unit", - "test-coverage:ci": "nyc npm run tests", + "test-coverage": "nyc npm run tests", "prepare": "husky install" }, "devDependencies": {