Skip to content

Commit

Permalink
chore: test for typescript project references
Browse files Browse the repository at this point in the history
  • Loading branch information
mfogel committed Oct 23, 2020
1 parent 7fe1449 commit 6f855e6
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ jspm_packages/
# TypeScript v1 declaration files
typings/

# TypeScript incremental build products
dist/
tsconfig.tsbuildinfo

# Optional npm cache directory
.npm

Expand Down
5 changes: 5 additions & 0 deletions tests/typescript-project-references/lib-bar/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions tests/typescript-project-references/lib-bar/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "lib-bar",
"version": "1.0.0",
"main": "dist/index.js",
"license": "MIT"
}
1 change: 1 addition & 0 deletions tests/typescript-project-references/lib-bar/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const getMeaningOfLife = () => "42, so they tell me";
8 changes: 8 additions & 0 deletions tests/typescript-project-references/lib-bar/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig-base.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
},
"include": ["src/"]
}
11 changes: 11 additions & 0 deletions tests/typescript-project-references/service-foo/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions tests/typescript-project-references/service-foo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "service-foo",
"version": "1.0.0",
"main": "dist/index.js",
"license": "MIT",
"dependencies": {
"lib-bar": "file:../lib-bar"
}
}
12 changes: 12 additions & 0 deletions tests/typescript-project-references/service-foo/serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
service: service-foo

plugins:
- '../../../index'

provider:
name: aws
runtime: nodejs10.x

functions:
hello:
handler: src/handler.hello
11 changes: 11 additions & 0 deletions tests/typescript-project-references/service-foo/src/handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { getMeaningOfLife } from "lib-bar";

export const hello = async (event: any) => {
return {
statusCode: 200,
body: JSON.stringify({
message: getMeaningOfLife(),
input: event
})
};
};
9 changes: 9 additions & 0 deletions tests/typescript-project-references/service-foo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig-base.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
},
"include": ["src/"],
"references": [{ "path": "../lib-bar" }]
}
9 changes: 9 additions & 0 deletions tests/typescript-project-references/tsconfig-base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"baseUrl": ".",
"target": "es6",
"moduleResolution": "node",
"composite": true,
"incremental": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { runSlsCommand, clearNpmCache } = require("../helpers");
const { join } = require("path");

beforeEach(async () => {
await clearNpmCache(__dirname);
});

afterAll(async () => {
await clearNpmCache(__dirname);
});

test("typescript-project-references", async () => {
const result = await runSlsCommand(join(__dirname, "service-foo"));

expect(result).toContain("42, so they tell me");
});

0 comments on commit 6f855e6

Please sign in to comment.