https://github.com/vic-lsh/jest-test-cases
Utility library that facilitates test-case-driven development.
https://github.com/vic-lsh/jest-test-cases
jest test-case
Last synced: 2 months ago
JSON representation
Utility library that facilitates test-case-driven development.
- Host: GitHub
- URL: https://github.com/vic-lsh/jest-test-cases
- Owner: vic-lsh
- License: mit
- Created: 2020-11-16T18:07:41.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-11-18T18:43:51.000Z (over 4 years ago)
- Last Synced: 2025-01-13T11:59:48.793Z (4 months ago)
- Topics: jest, test-case
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/jest-test-cases
- Size: 49.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jest-test-cases
Utility library that facilitates test-case-driven development.
## Description
`describeTestcase` helps you highlight the essence of a test: inputs and outputs. Focus on coming up with more test cases, and let the library do the assertions for you.
```ts
function toCamelCase(s: string) {
// ...
}describeTestcase("utils/toCamelCase", toCamelCase, {
testCases: [
{
should: "return an empty string",
given: "an empty string",
cases: { input: "", expected: "" }
},
{
should: "transform input to camel case strings",
given: "a non-empty string",
cases: [
{ input: "Hello world", expected: "helloWorld" },
{ input: "word", expected: "word" },
{ input: "camelCased", expected: "camelCased" }
]
}
]
})
```Instead of:
```ts
describe("utils/toCamelCase", () => {
it("should return an empty string given an empty string", () => {
expect(toCamelCase("")).toEqual("");
})it("should transform input to camel case strings given a non-empty string", () => {
expect(toCamelCase("Hello World")).toEqual("helloWorld");
expect(toCamelCase("word")).toEqual("word");
expect(toCamelCase("camelCased")).toEqual("camelCased");})
})
```