TypeScript
- Strongly typed language
- A superset of JavaScript i.e. any valid JavaScript is valid TypeScript
- Adds time to development but makes debugging and refactoring much easier in the long run
- Extension for typescript file is
.ts
- It can be added to a project using
npm install --save-dev typescript
let name: string = "Kush" // valid
let age: int = "20" // error
type objType = {
name: string,
age: int,
location: string,
}
let myObject: objType = {
name: "Kush Gabani",
age: 20,
location: "Surat"
}
Jest
- Unit Testing for javascript
- Run test suites, individual test cases
- Provides a variety of methods for unit testing
- An extension of a test file is
.test.js
- To add jest to a project, we run the following command
npm install --save-dev jest
- To run test cases, we need to add a test script in
package.json
"scripts": [
"test": "jest",
];
- The syntax to write a Test case
test("test case description", () => {
// ...test case
});
Functions for asserting