test('socket connect test', (done) => {
socket.on('connect', () => {
done();
});
});
describe('socket.io test', () => {
beforeAll(() => {
...
});
afterAll(() => {
...
});
test('socket connect test', (done) => {
...
});
test('[EMIT] \'enter_room\' event test', (done) => {
...
});
});
afterAll(fn, timeout): 모든 테스트가 끝나고 한번 실행된다.
afterEach(fn, timeout): 하나의 테스트가 끝날 때 마다 매번 실행된다.
beforeAll(fn, timeout): 모든 테스트가 시작하기 전에 한번 실행된다.
beforeEach(fn, timeout): 하나의 테스트가 시작하기 전에 매번 실행된다.
<span data-testid="html-element"><span>Html Element</span></span>
<svg data-testid="svg-element"></svg>
expect(
getByTestId(document.documentElement, 'html-element'),
).toBeInTheDocument()
expect(getByTestId(document.documentElement, 'svg-element')).toBeInTheDocument()
expect(
queryByTestId(document.documentElement, 'does-not-exist'),
).not.toBeInTheDocument()
<button data-testid="ok-button" type="submit" disabled>ok</button>
const button = getByTestId('ok-button')
expect(button).toHaveAttribute('disabled')
expect(button).toHaveAttribute('type', 'submit')
expect(button).not.toHaveAttribute('type', 'button')
expect(button).toHaveAttribute('type', expect.stringContaining('sub'))
expect(button).toHaveAttribute('type', expect.not.stringContaining('but'))