NEW
Font size
WorksheetsNodejs - Testing
Total questions: 15
Worksheet time: 8mins
What is testing?
an activity to check whether the actual results match the expected results
an activity to check whether the expected results match the initial results
an activity to check whether the initial results match the actual results
none of the options
What is the purpose of a test runner?
to write test cases
to execute test cases
to set up mock data
to debug the code
which library/framework can we use to test out nodejs app
node-tester
testy-node
jest
node-jester
when using jest, what module can we use with it to test HTTP request and responses
supertest
requester
jest-request
test-request
which of the following command is used to run tests(test runner)
npm jest
npm test
npm runner
npm pretest
in Jest, what keyword is used to define a test case?
should
it
expect
describe
in Jest, what keyword is used to define a test suite?
should
it
expect
describe
Which of the following is not a hook in jest?
beforeEach
beforeAll
after
afterAll
What is the purpose of hooks in testing?
abstract complex behaviour from test cases
configure test cases to meet certain requirements
setup mocks and global variables for other test cases
All of the options
which of the following is not a type of testing?
unit testing
integration testing
end-to-end testing
complex testing
unit testing tests individual units of code, while integration testing _______
tests code coverage
tests for syntax error
tests for interactions between parts of the application
tests for integral changes
why do we always do a cleanup of the database for every test case?
to remove all the data in the database
to avoid confilcts on the data when running tests cases
all of the options
which of the following is not something we can write test for?
response status code
structure of the body/data of response
values from the request body matches what the database needs
none of the options
```const response = await supertest(app)
.post('/users/signup')```
From the code above, which of the following is not correct
we are testing the endpoint of /users/signup
the endpoint is using a POST method
app is an instance of Express
none of the options
which of the following is an assertion keywords in Jest?
it
describe
expect
assertThat
