soda-test
v2.2.6
Published
Package for Unit and API tests
Downloads
67
Maintainers
Readme
via npm
$ npm install soda-test --save-dev
@describe('demo')
class TestDemoTest {
@stub(User, "findById").returns("dummy-user")
findStub: SinonStub
@it('should get user by id')
GetById(): TR {
const user = getUser({id:123})
expect(user).to.equal("dummy-user")
expect(this.findStub).to.have.been.calledOnce.calledWith(123)
}
}
For full documentation and many sample test, see soda-test wiki Define API test-cases by using the testCase decorator on a method, and define its steps in it
@testCase("sample case", SampleTestStepsTest)
checkGetApi(step: stepMethod<SampleTestStepsTest>): void {
step("define dummy REST server").StartRestServer({expect: "GET /", return: "dummy"})
step("send get request").SendRequest({method:"GET", url: "/", expectresponse: "dummy"})
step("validate get request").ValidateRequest({method: "GET", url: "/"})
step("stop dummy Rest server").StopRestServer()
}
For more details about API test case see Soda-test test-cases documenation