fix: organize integration tests according to method targets. fix: set timeouts and retries for integration tests

This commit is contained in:
StevanFreeborn
2023-02-14 23:49:18 -06:00
parent 97ae716e93
commit d314b1745b
8 changed files with 33 additions and 18 deletions
@@ -1,8 +1,11 @@
import { OnspringClient } from '../src/index'; import { OnspringClient } from '../../src/index';
import { expect } from 'chai'; import { expect } from 'chai';
import { baseURL, apiKey } from './mochaRootHooks'; import { baseURL, apiKey } from '../mochaRootHooks';
describe('getAppById', function () { describe('getAppById', function () {
this.timeout(30000);
this.retries(3);
it('should return an app', async function () { it('should return an app', async function () {
const client = new OnspringClient(baseURL, apiKey); const client = new OnspringClient(baseURL, apiKey);
@@ -1,8 +1,11 @@
import { OnspringClient, PagingRequest } from '../src/index'; import { OnspringClient, PagingRequest } from '../../src/index';
import { expect } from 'chai'; import { expect } from 'chai';
import { baseURL, apiKey } from './mochaRootHooks'; import { baseURL, apiKey } from '../mochaRootHooks';
describe('getApps', function () { describe('getApps', function () {
this.timeout(30000);
this.retries(3);
it('should return a paged list of apps', async function () { it('should return a paged list of apps', async function () {
const client = new OnspringClient(baseURL, apiKey); const client = new OnspringClient(baseURL, apiKey);
const response = await client.getApps(); const response = await client.getApps();
@@ -1,8 +1,11 @@
import { OnspringClient } from '../src/index'; import { OnspringClient } from '../../src/index';
import { expect } from 'chai'; import { expect } from 'chai';
import { baseURL, apiKey } from './mochaRootHooks'; import { baseURL, apiKey } from '../mochaRootHooks';
describe('getAppsByIds', function () { describe('getAppsByIds', function () {
this.timeout(30000);
this.retries(3);
it('should return a collection of apps', async function () { it('should return a collection of apps', async function () {
const client = new OnspringClient(baseURL, apiKey); const client = new OnspringClient(baseURL, apiKey);
const appIds = process.env.TEST_APP_IDS; const appIds = process.env.TEST_APP_IDS;
@@ -1,8 +1,11 @@
import { OnspringClient } from '../src/index'; import { OnspringClient } from '../../src/index';
import { expect } from 'chai'; import { expect } from 'chai';
import { baseURL, apiKey } from './mochaRootHooks'; import { baseURL, apiKey } from '../mochaRootHooks';
describe('getAppById', function () { describe('getAppById', function () {
this.timeout(30000);
this.retries(3);
it('should return a field', async function () { it('should return a field', async function () {
const client = new OnspringClient(baseURL, apiKey); const client = new OnspringClient(baseURL, apiKey);
@@ -1,8 +1,11 @@
import { OnspringClient, PagingRequest } from '../src/index'; import { OnspringClient, PagingRequest } from '../../src/index';
import { expect } from 'chai'; import { expect } from 'chai';
import { baseURL, apiKey } from './mochaRootHooks'; import { baseURL, apiKey } from '../mochaRootHooks';
describe('getFieldsByAppId', function () { describe('getFieldsByAppId', function () {
this.timeout(30000);
this.retries(3);
it('should return a paged list of fields', async function () { it('should return a paged list of fields', async function () {
const client = new OnspringClient(baseURL, apiKey); const client = new OnspringClient(baseURL, apiKey);
@@ -1,8 +1,11 @@
import { OnspringClient } from '../src/index'; import { OnspringClient } from '../../src/index';
import { expect } from 'chai'; import { expect } from 'chai';
import { baseURL, apiKey } from './mochaRootHooks'; import { baseURL, apiKey } from '../mochaRootHooks';
describe('getFieldsByIds', function () { describe('getFieldsByIds', function () {
this.timeout(30000);
this.retries(3);
it('should return a collection of fields', async function () { it('should return a collection of fields', async function () {
const client = new OnspringClient(baseURL, apiKey); const client = new OnspringClient(baseURL, apiKey);
+2 -4
View File
@@ -1,4 +1,4 @@
import { type Context } from 'mocha'; import { type RootHookObject, type Context } from 'mocha';
import { expect } from 'chai'; import { expect } from 'chai';
import * as dotenv from 'dotenv'; import * as dotenv from 'dotenv';
import path from 'path'; import path from 'path';
@@ -8,11 +8,9 @@ dotenv.config({ path: envPath });
let baseURL: string | undefined; let baseURL: string | undefined;
let apiKey: string | undefined; let apiKey: string | undefined;
export const mochaHooks = (): Mocha.RootHookObject => { export const mochaHooks = (): RootHookObject => {
return { return {
beforeAll(this: Context) { beforeAll(this: Context) {
this.timeout('30s');
baseURL = process.env.API_BASE_URL; baseURL = process.env.API_BASE_URL;
apiKey = process.env.SANDBOX_API_KEY; apiKey = process.env.SANDBOX_API_KEY;
+1 -2
View File
@@ -45,8 +45,7 @@
"tests:unit": "mocha -R progress -r ts-node/register ./tests/**/*.spec.ts", "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: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", "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": "nyc npm run tests",
"test-coverage:ci": "nyc npm run tests",
"prepare": "husky install" "prepare": "husky install"
}, },
"devDependencies": { "devDependencies": {