Skip to content

Commit a5aec42

Browse files
authored
Merge pull request #12 from aymenn/tests
Tests
2 parents c532ef9 + dc72b01 commit a5aec42

File tree

5 files changed

+62
-1
lines changed

5 files changed

+62
-1
lines changed

.eslintrc.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,15 @@ module.exports = {
1010
sourceType: "module",
1111
},
1212
rules: {},
13+
overrides: [
14+
{
15+
files: [
16+
"**/*.test.js",
17+
"**/*.test.ts"
18+
],
19+
env: {
20+
jest: true
21+
}
22+
}
23+
]
1324
};

.github/workflows/test.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches: [ $default-branch ]
9+
pull_request:
10+
branches: [ $default-branch ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
matrix:
19+
node-version: [16.x]
20+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21+
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v3
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
cache: 'npm'
29+
- run: npm install
30+
- run: npm test

jest.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
2+
module.exports = {
3+
preset: 'ts-jest',
4+
testEnvironment: 'node'
5+
};

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,21 @@
1414
"@types/cors": "^2.8.12",
1515
"@types/express": "^4.17.13",
1616
"@types/http-errors": "^1.8.2",
17+
"@types/jest": "^28.1.5",
1718
"@types/morgan": "^1.9.3",
1819
"@types/node": "^18.0.1",
20+
"jest": "^28.1.3",
1921
"node-fetch": "2",
2022
"nodemon": "^2.0.19",
23+
"ts-jest": "^28.0.6",
2124
"ts-node": "^10.8.2",
2225
"typescript": "^4.7.4"
2326
},
2427
"name": "masked-communications",
2528
"scripts": {
2629
"dev": "nodemon -r dotenv/config index.ts",
27-
"loadtest": "node ./tests/loadtest.js"
30+
"loadtest": "node ./tests/loadtest.js",
31+
"test": "jest"
2832
},
2933
"version": "1.0.0"
3034
}

tests/index.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
require('dotenv').config();
3+
4+
const {createConversation} = require('../src/utils/createConversation.util');
5+
6+
7+
test("Creates a conversation", ()=>{
8+
return createConversation().then(data=>{
9+
expect(data.sid).toBeDefined();
10+
});
11+
});

0 commit comments

Comments
 (0)