From 99f2b48b43725fb7d544400bc0e2071ca336abd7 Mon Sep 17 00:00:00 2001 From: Alex Oskotsky Date: Thu, 14 May 2020 01:22:23 -0400 Subject: [PATCH] switch integration tests to typescript --- README.md | 2 +- package.json | 6 +- test/integration-tests/integration.test.js | 223 ----------------- test/integration-tests/integration.test.ts | 229 ++++++++++++++++++ .../{test-utilities.js => test-utilities.ts} | 25 +- test/unit-tests/index.test.ts | 3 +- tsconfig.json | 5 +- tsconfig.tests.json | 17 ++ tslint.json | 5 +- 9 files changed, 270 insertions(+), 245 deletions(-) delete mode 100644 test/integration-tests/integration.test.js create mode 100644 test/integration-tests/integration.test.ts rename test/integration-tests/{test-utilities.js => test-utilities.ts} (91%) create mode 100644 tsconfig.tests.json diff --git a/README.md b/README.md index 702d32e9..b70408ad 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ npm install ``` ## Writing Integration Tests -Unit tests are found in `test/unit-tests`. Integration tests are found in `test/integration-tests`. Each folder in `tests/integration-tests` contains the serverless-domain-manager configuration being tested. To create a new integration test, create a new folder for the `handler.js` and `serverless.yml` with the same naming convention and update `integration.test.js`. +Unit tests are found in `test/unit-tests`. Integration tests are found in `test/integration-tests`. Each folder in `tests/integration-tests` contains the serverless-domain-manager configuration being tested. To create a new integration test, create a new folder for the `handler.js` and `serverless.yml` with the same naming convention and update `integration.test.ts`. ## Changing API Types AWS API Gateway has three different API types: REST, HTTP, and WebSocket. Special steps need to be taken when migrating from one api type to another. A common migration will be from a REST API to an HTTP API given the potential cost savings. Below are the steps required to change from REST to HTTP. A similar process can be applied for other API type migrations. diff --git a/package.json b/package.json index fc639989..56a16402 100644 --- a/package.json +++ b/package.json @@ -27,9 +27,9 @@ "main": "dist/index.js", "bin": {}, "scripts": { - "test": "tsc --project . && nyc mocha -r ts-node/register test/unit-tests/index.test.ts && nyc report --reporter=text-summary", - "integration-test": "node ./node_modules/istanbul/lib/cli.js test _mocha test/integration-tests -- -R spec", - "lint": "tslint --project .", + "test": "nyc mocha -r ts-node/register --project tsconfig.tests.json test/unit-tests/index.test.ts && nyc report --reporter=text-summary", + "integration-test": "nyc mocha -r ts-node/register --project tsconfig.tests.json test/integration-tests/integration.test.ts && nyc report --reporter=text-summary", + "lint": "tslint --project . && tslint --project tsconfig.tests.json", "build": "tsc --project ." }, "files": [ diff --git a/test/integration-tests/integration.test.js b/test/integration-tests/integration.test.js deleted file mode 100644 index 63349f79..00000000 --- a/test/integration-tests/integration.test.js +++ /dev/null @@ -1,223 +0,0 @@ -"use strict"; - -const chai = require("chai"); -const itParam = require("mocha-param"); -const utilities = require("./test-utilities"); -const randomstring = require("randomstring"); - -const expect = chai.expect; - -const TEST_DOMAIN = process.env.TEST_DOMAIN; -if(!TEST_DOMAIN) { - throw new Error("TEST_DOMAIN environment variable not set") -} - -const FIFTEEN_MINUTES = 15 * 60 * 1000; // 15 minutes in milliseconds -const RANDOM_STRING = randomstring.generate({ - length: 5, - charset: "alphanumeric", - capitalization: "lowercase", -}); -const TEMP_DIR = `~/tmp/domain-manager-test-${RANDOM_STRING}`; - -const testCases = [ - { - testDescription: "Enabled with default values", - testFolder: "enabled-default", - testDomain: `enabled-default-${RANDOM_STRING}.${TEST_DOMAIN}`, - testStage: "dev", - testBasePath: "(none)", - testEndpoint: "EDGE", - testURL: `https://enabled-default-${RANDOM_STRING}.${TEST_DOMAIN}/hello-world`, - }, - { - testDescription: "Enabled with custom api gateway", - testFolder: "enabled-custom-apigateway", - testDomain: `enabled-custom-apigateway-${RANDOM_STRING}.${TEST_DOMAIN}`, - testStage: "dev", - testBasePath: "(none)", - testEndpoint: "EDGE", - testURL: `https://enabled-custom-apigateway-${RANDOM_STRING}.${TEST_DOMAIN}`, - createApiGateway: true, - }, - { - testDescription: "Enabled with custom basepath", - testFolder: "enabled-basepath", - testDomain: `enabled-basepath-${RANDOM_STRING}.${TEST_DOMAIN}`, - testStage: "dev", - testBasePath: "api", - testEndpoint: "EDGE", - testURL: `https://enabled-basepath-${RANDOM_STRING}.${TEST_DOMAIN}/api/hello-world`, - }, - { - testDescription: "Enabled with custom stage and empty basepath", - testFolder: "enabled-stage-basepath", - testDomain: `enabled-stage-basepath-${RANDOM_STRING}.${TEST_DOMAIN}`, - testStage: "test", - testBasePath: "(none)", - testEndpoint: "EDGE", - testURL: `https://enabled-stage-basepath-${RANDOM_STRING}.${TEST_DOMAIN}/hello-world`, - }, - { - testDescription: "Enabled with regional endpoint, custom basePath", - testFolder: "enabled-regional-basepath", - testDomain: `enabled-regional-basepath-${RANDOM_STRING}.${TEST_DOMAIN}`, - testStage: "dev", - testBasePath: "api", - testEndpoint: "REGIONAL", - testURL: `https://enabled-regional-basepath-${RANDOM_STRING}.${TEST_DOMAIN}/api/hello-world`, - }, - { - testDescription: "Enabled with regional endpoint, custom stage, empty basepath", - testFolder: "enabled-regional-stage-basepath", - testDomain: `enabled-regional-stage-basepath-${RANDOM_STRING}.${TEST_DOMAIN}`, - testStage: "test", - testBasePath: "(none)", - testEndpoint: "REGIONAL", - testURL: `https://enabled-regional-stage-basepath-${RANDOM_STRING}.${TEST_DOMAIN}/hello-world`, - }, - { - testDescription: "Enabled with regional endpoint and empty basepath", - testFolder: "enabled-regional-empty-basepath", - testDomain: `enabled-regional-empty-basepath-${RANDOM_STRING}.${TEST_DOMAIN}`, - testStage: "dev", - testBasePath: "(none)", - testEndpoint: "REGIONAL", - testURL: `https://enabled-regional-empty-basepath-${RANDOM_STRING}.${TEST_DOMAIN}/hello-world`, - }, -]; - -describe("Integration Tests", function () { // eslint-disable-line func-names - this.timeout(FIFTEEN_MINUTES); - - itParam("${value.testDescription}", testCases, async (value) => { // eslint-disable-line no-template-curly-in-string - let restApiInfo; - if (value.createApiGateway) { - restApiInfo = await utilities.setupApiGatewayResources(RANDOM_STRING); - } - try { - await utilities.createResources(value.testFolder, value.testDomain, RANDOM_STRING, true); - const stage = await utilities.getStage(value.testDomain); - expect(stage).to.equal(value.testStage); - - const basePath = await utilities.getBasePath(value.testDomain); - expect(basePath).to.equal(value.testBasePath); - - const endpoint = await utilities.getEndpointType(value.testDomain); - expect(endpoint).to.equal(value.testEndpoint); - } finally { - await utilities.destroyResources(value.testDomain, RANDOM_STRING); - if (value.createApiGateway) { - await utilities.deleteApiGatewayResources(restApiInfo.restApiId); - } - } - }); - - it("Creates a empty basepath mapping", async () => { - const testName = "null-basepath-mapping"; - const testURL = `${testName}-${RANDOM_STRING}.${TEST_DOMAIN}`; - // Perform sequence of commands to replicate basepath mapping issue - // Sleep for half a min between commands in order to avoid rate limiting. - try { - await utilities.createTempDir(TEMP_DIR, testName); - await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsDeleteDomain(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); - - const basePath = await utilities.getBasePath(testURL); - expect(basePath).to.equal("(none)"); - } finally { - await utilities.destroyResources(testURL, RANDOM_STRING); - } - }); - - it("Creates a basepath mapping", async () => { - const testName = "basepath-mapping"; - const testURL = `${testName}-${RANDOM_STRING}.${TEST_DOMAIN}`; - // Perform sequence of commands to replicate basepath mapping issue - // Sleep for half a min between commands in order to avoid rate limiting. - try { - await utilities.createTempDir(TEMP_DIR, testName); - await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsDeleteDomain(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); - - const basePath = await utilities.getBasePath(testURL); - expect(basePath).to.equal("api"); - } finally { - await utilities.destroyResources(testURL, RANDOM_STRING); - } - }); - - it("Creates a basepath mapping", async () => { - const testName = "null-basepath-mapping"; - const testURL = `${testName}-${RANDOM_STRING}.${TEST_DOMAIN}`; - // Perform sequence of commands to replicate basepath mapping issue - // Sleep for half a min between commands in order to avoid rate limiting. - try { - await utilities.createTempDir(TEMP_DIR, testName); - await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsDeleteDomain(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsRemove(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); - - const basePath = await utilities.getBasePath(testURL); - expect(basePath).to.equal("(none)"); - } finally { - await utilities.destroyResources(testURL, RANDOM_STRING); - } - }); - - it("Creates a domain multiple times without failure", async () => { - const testName = "create-domain-idempotent"; - const testURL = `${testName}-${RANDOM_STRING}.${TEST_DOMAIN}`; - try { - await utilities.createTempDir(TEMP_DIR, testName); - await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); - } finally { - await utilities.destroyResources(testURL, RANDOM_STRING); - } - }); - - it("Deploys multiple times without failure", async () => { - const testName = "deploy-idempotent"; - const testURL = `${testName}-${RANDOM_STRING}.${TEST_DOMAIN}`; - try { - await utilities.createTempDir(TEMP_DIR, testName); - await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); - await utilities.sleep(30); - await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); - } finally { - await utilities.destroyResources(testURL, RANDOM_STRING); - } - }); -}); diff --git a/test/integration-tests/integration.test.ts b/test/integration-tests/integration.test.ts new file mode 100644 index 00000000..8d0fe803 --- /dev/null +++ b/test/integration-tests/integration.test.ts @@ -0,0 +1,229 @@ +import chai = require("chai"); +import "mocha"; +import itParam = require("mocha-param"); +import randomstring = require("randomstring"); +import utilities = require("./test-utilities"); + +const expect = chai.expect; + +const TEST_DOMAIN = process.env.TEST_DOMAIN; + +if (!TEST_DOMAIN) { + throw new Error("TEST_DOMAIN environment variable not set"); +} + +const FIFTEEN_MINUTES = 15 * 60 * 1000; // 15 minutes in milliseconds +const RANDOM_STRING = randomstring.generate({ + capitalization: "lowercase", + charset: "alphanumeric", + length: 5, +}); +const TEMP_DIR = `~/tmp/domain-manager-test-${RANDOM_STRING}`; + +const testCases = [ + { + testBasePath: "(none)", + testDescription: "Enabled with default values", + testDomain: `enabled-default-${RANDOM_STRING}.${TEST_DOMAIN}`, + testEndpoint: "EDGE", + testFolder: "enabled-default", + testStage: "dev", + testURL: `https://enabled-default-${RANDOM_STRING}.${TEST_DOMAIN}/hello-world`, + }, + { + createApiGateway: true, + testBasePath: "(none)", + testDescription: "Enabled with custom api gateway", + testDomain: `enabled-custom-apigateway-${RANDOM_STRING}.${TEST_DOMAIN}`, + testEndpoint: "EDGE", + testFolder: "enabled-custom-apigateway", + testStage: "dev", + testURL: `https://enabled-custom-apigateway-${RANDOM_STRING}.${TEST_DOMAIN}`, + }, + { + testBasePath: "api", + testDescription: "Enabled with custom basepath", + testDomain: `enabled-basepath-${RANDOM_STRING}.${TEST_DOMAIN}`, + testEndpoint: "EDGE", + testFolder: "enabled-basepath", + testStage: "dev", + testURL: `https://enabled-basepath-${RANDOM_STRING}.${TEST_DOMAIN}/api/hello-world`, + }, + { + testBasePath: "(none)", + testDescription: "Enabled with custom stage and empty basepath", + testDomain: `enabled-stage-basepath-${RANDOM_STRING}.${TEST_DOMAIN}`, + testEndpoint: "EDGE", + testFolder: "enabled-stage-basepath", + testStage: "test", + testURL: `https://enabled-stage-basepath-${RANDOM_STRING}.${TEST_DOMAIN}/hello-world`, + }, + { + testBasePath: "api", + testDescription: "Enabled with regional endpoint, custom basePath", + testDomain: `enabled-regional-basepath-${RANDOM_STRING}.${TEST_DOMAIN}`, + testEndpoint: "REGIONAL", + testFolder: "enabled-regional-basepath", + testStage: "dev", + testURL: `https://enabled-regional-basepath-${RANDOM_STRING}.${TEST_DOMAIN}/api/hello-world`, + }, + { + testBasePath: "(none)", + testDescription: "Enabled with regional endpoint, custom stage, empty basepath", + testDomain: `enabled-regional-stage-basepath-${RANDOM_STRING}.${TEST_DOMAIN}`, + testEndpoint: "REGIONAL", + testFolder: "enabled-regional-stage-basepath", + testStage: "test", + testURL: `https://enabled-regional-stage-basepath-${RANDOM_STRING}.${TEST_DOMAIN}/hello-world`, + }, + { + testBasePath: "(none)", + testDescription: "Enabled with regional endpoint and empty basepath", + testDomain: `enabled-regional-empty-basepath-${RANDOM_STRING}.${TEST_DOMAIN}`, + testEndpoint: "REGIONAL", + testFolder: "enabled-regional-empty-basepath", + testStage: "dev", + testURL: `https://enabled-regional-empty-basepath-${RANDOM_STRING}.${TEST_DOMAIN}/hello-world`, + }, +]; + +describe("Integration Tests", function() { + this.timeout(FIFTEEN_MINUTES); + + describe("Configuration Tests", () => { + itParam("${value.testDescription}", testCases, async (value) => { + let restApiInfo; + if (value.createApiGateway) { + restApiInfo = await utilities.setupApiGatewayResources(RANDOM_STRING); + } + try { + await utilities.createResources(value.testFolder, value.testDomain, RANDOM_STRING, true); + const stage = await utilities.getStage(value.testDomain); + expect(stage).to.equal(value.testStage); + + const basePath = await utilities.getBasePath(value.testDomain); + expect(basePath).to.equal(value.testBasePath); + + const endpoint = await utilities.getEndpointType(value.testDomain); + expect(endpoint).to.equal(value.testEndpoint); + } finally { + await utilities.destroyResources(value.testDomain, RANDOM_STRING); + if (value.createApiGateway) { + await utilities.deleteApiGatewayResources(restApiInfo.restApiId); + } + } + }); + }); + + describe("Basepath mapping issue tests", () => { + it("Creates a empty basepath mapping", async () => { + const testName = "null-basepath-mapping"; + const testURL = `${testName}-${RANDOM_STRING}.${TEST_DOMAIN}`; + // Perform sequence of commands to replicate basepath mapping issue + // Sleep for half a min between commands in order to avoid rate limiting. + try { + await utilities.createTempDir(TEMP_DIR, testName); + await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsDeleteDomain(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); + + const basePath = await utilities.getBasePath(testURL); + expect(basePath).to.equal("(none)"); + } finally { + await utilities.destroyResources(testURL, RANDOM_STRING); + } + }); + + it("Delete domain then recreate", async () => { + const testName = "basepath-mapping"; + const testURL = `${testName}-${RANDOM_STRING}.${TEST_DOMAIN}`; + // Perform sequence of commands to replicate basepath mapping issue + // Sleep for half a min between commands in order to avoid rate limiting. + try { + await utilities.createTempDir(TEMP_DIR, testName); + await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsDeleteDomain(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); + + const basePath = await utilities.getBasePath(testURL); + expect(basePath).to.equal("api"); + } finally { + await utilities.destroyResources(testURL, RANDOM_STRING); + } + }); + + it("Delete domain then remove", async () => { + const testName = "null-basepath-mapping"; + const testURL = `${testName}-${RANDOM_STRING}.${TEST_DOMAIN}`; + // Perform sequence of commands to replicate basepath mapping issue + // Sleep for half a min between commands in order to avoid rate limiting. + try { + await utilities.createTempDir(TEMP_DIR, testName); + await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsDeleteDomain(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsRemove(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); + + const basePath = await utilities.getBasePath(testURL); + expect(basePath).to.equal("(none)"); + } finally { + await utilities.destroyResources(testURL, RANDOM_STRING); + } + }); + }); + + describe("Idempotency tests", () => { + it("Creates a domain multiple times without failure", async () => { + const testName = "create-domain-idempotent"; + const testURL = `${testName}-${RANDOM_STRING}.${TEST_DOMAIN}`; + try { + await utilities.createTempDir(TEMP_DIR, testName); + await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); + } finally { + await utilities.destroyResources(testURL, RANDOM_STRING); + } + }); + + it("Deploys multiple times without failure", async () => { + const testName = "deploy-idempotent"; + const testURL = `${testName}-${RANDOM_STRING}.${TEST_DOMAIN}`; + try { + await utilities.createTempDir(TEMP_DIR, testName); + await utilities.slsCreateDomain(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); + await utilities.sleep(30); + await utilities.slsDeploy(TEMP_DIR, RANDOM_STRING); + } finally { + await utilities.destroyResources(testURL, RANDOM_STRING); + } + }); + }); +}); diff --git a/test/integration-tests/test-utilities.js b/test/integration-tests/test-utilities.ts similarity index 91% rename from test/integration-tests/test-utilities.js rename to test/integration-tests/test-utilities.ts index 865861c9..ed7155a6 100644 --- a/test/integration-tests/test-utilities.js +++ b/test/integration-tests/test-utilities.ts @@ -1,19 +1,18 @@ "use strict"; -const aws = require("aws-sdk"); -const shell = require("shelljs"); +import aws = require("aws-sdk"); +import shell = require("shelljs"); const AWS_PROFILE = process.env.AWS_PROFILE; const apiGateway = new aws.APIGateway({ - region: "us-west-2", credentials: new aws.SharedIniFileCredentials( { profile: AWS_PROFILE }, ), + region: "us-west-2", }); class CreationError extends Error {} - /** * Stops event thread execution for given number of seconds. * @param seconds @@ -202,15 +201,15 @@ async function removeLambdas(tempDir, domainIdentifier) { * @returns {Promise} Resolves if successfully executed, else rejects */ async function createResources(folderName, url, domainIdentifier, enabled) { - console.debug(`\tCreating Resources for ${url}`); // eslint-disable-line no-console + console.debug(`\tCreating Resources for ${url}`); const tempDir = `~/tmp/domain-manager-test-${domainIdentifier}`; console.debug(`\tUsing tmp directory ${tempDir}`); try { - await createTempDir(tempDir, folderName); // eslint-disable-line no-console + await createTempDir(tempDir, folderName); await deployLambdas(tempDir, domainIdentifier); - console.debug("\tResources Created"); // eslint-disable-line no-console - } catch(e) { - console.debug("\tResources Failed to Create"); // eslint-disable-line no-console + console.debug("\tResources Created"); + } catch (e) { + console.debug("\tResources Failed to Create"); } } @@ -222,18 +221,18 @@ async function createResources(folderName, url, domainIdentifier, enabled) { */ async function destroyResources(url, domainIdentifier) { try { - console.debug(`\tCleaning Up Resources for ${url}`); // eslint-disable-line no-console + console.debug(`\tCleaning Up Resources for ${url}`); const tempDir = `~/tmp/domain-manager-test-${domainIdentifier}`; await removeLambdas(tempDir, domainIdentifier); await exec(`rm -rf ${tempDir}`); - console.debug("\tResources Cleaned Up"); // eslint-disable-line no-console + console.debug("\tResources Cleaned Up"); } catch (e) { - console.debug("\tFailed to Clean Up Resources"); // eslint-disable-line no-console + console.debug("\tFailed to Clean Up Resources"); } } -module.exports = { +export { createResources, createTempDir, destroyResources, diff --git a/test/unit-tests/index.test.ts b/test/unit-tests/index.test.ts index 803a2e61..72c372d7 100644 --- a/test/unit-tests/index.test.ts +++ b/test/unit-tests/index.test.ts @@ -3,11 +3,10 @@ import * as AWS from "aws-sdk-mock"; import chai = require("chai"); import spies = require("chai-spies"); import "mocha"; -import DomainInfo = require("../../DomainInfo"); import DomainConfig = require("../../DomainConfig"); +import DomainInfo = require("../../DomainInfo"); import Globals from "../../Globals"; import ServerlessCustomDomain = require("../../index"); -import { ServerlessInstance, ServerlessOptions } from "../../types"; const expect = chai.expect; chai.use(spies); diff --git a/tsconfig.json b/tsconfig.json index babfb254..c07f20b8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,9 +9,10 @@ "types": ["node"] }, "include": [ - "*.ts" + "**/*.ts" ], "exclude": [ - "node_modules" + "node_modules", + "test" ] } diff --git a/tsconfig.tests.json b/tsconfig.tests.json new file mode 100644 index 00000000..962b5022 --- /dev/null +++ b/tsconfig.tests.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "moduleResolution": "node", + "rootDir": ".", + "target": "es6", + "sourceMap": false, + "outDir": "dist", + "types": ["mocha", "node"] + }, + "include": [ + "test/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} diff --git a/tslint.json b/tslint.json index 78af2344..534cb941 100644 --- a/tslint.json +++ b/tslint.json @@ -1,3 +1,6 @@ { - "extends": "tslint:recommended" + "extends": "tslint:recommended", + "rules": { + "no-console": false + } }