Basic Jasmine
Estimated reading time: 2 minutesJasmine main terms
- Global method (Setup and Teardown (method))
- describe (method)
- it (method)
- expect (expectation)
Describe
‘describe’ is a function or method
. It has two parameters: a string
and a function
. The string is a name or title for a spec suite - usually what is being tested. The function is a block of code that implements the suite.
describe('Describe about your test', () => {
...
});
it
it
is also a function or method
. It has two parameters: a string
and a function
describe('Describe about your test', () => {
it('Your specefic test', () => {
...
});
it('Your specefic test two', () => {
...
});
})
expect
expect
or Expectations
that mean your testing process what you expect.
matcher
describe('Describe about your test', () => {
it('Your specefic test', () => {
expect(true).toBe(true);
});
})
Setup and Teardown
Global method
- beforeEach
- afterEach
- beforeAll
- afterAll
describe('Describe about your test', () => {
afterAll(() => {
...
});
beforeAll(() => {
...
});
afterEach(() => {
...
});
beforeEach(() => {
...
});
it('Your specefic test', () => {
expect(true).toBe(true);
});
})