-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(NOC-1903): Unit testing and API testing with jest + supertest #7
Conversation
Tests are added for following endpoints: 1. `/completions` 2. `/state` 3. `/pricing/model` 4. `/pricing/model/cost`
…e unnecearry types + make data as const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @dynamite-bud! I've made some minor changes and we're now ready to merge 💪
Note, all tests can now be run with The required node version has also been bumped to v20 because node version 19.8.1 is not compatible with |
feat(NOC-1903): Unit testing and API testing with jest + supertest
Description
This PR introduces unit tests and API tests for this project.
Technologies used
I've used:
jest
for unit testssupertest
for API testingTest Structure
The tests live under the
server/__tests__/*
.Unit tests
Unit tests are located under
server/__tests__/unit/*
. They currently test splitters.intercom.tests.ts
json.tests.ts
markdown.tests.ts
pdf.tests.ts
unstructured.tests.ts
These tests test the splitters' functionality to split different types of documents supplied.
API tests
These tests are located under
server/__tests__/api/*
. They test different endpoints such as:1.
/completions
2.
/pricing/model
3.
/pricing/model/cost
4.
/state
Tests development
Important
Please update values in your
.env
file following.env/example
file.Unit tests
server/__tests__/unit/
yarn run test:unit:watch
, to watch development in realtimeAPI tests
server/__tests__/api/api.tests.ts
yarn run test:api
Note
All API tests are written in one file and there's no watch mode as supertests instantiate an express app and as a new server is spun so if you make multiple files, multiple apps are instantiated creating the error.
ERROR: Address already in use
Running tests
Unit tests
yarn run test:unit
API tests
yarn run test:api