I'm building some API tests for the product I'm building. One of the test looks like this:
GET FILTERS
✓ should be restricted (45ms)
it should get the filters
✓ should return 200
✓ should return an object
✓ should close db connections
GET USERS COUNT
✓ should be restricted
✓ should throw error when payload is not correct
it should get the user count
✓ should return 200
✓ should return an object
✓ should close db connections
GET USERS FILE
✓ should be restricted
✓ should throw error when no queryId is specified
it should retrieve the file
✓ should return 200
✓ should download an excel file
✓ should close db connections
UPLOAD PROMOTION IMAGE
✓ should throw error when no file is specified
it should save the file
✓ should return 200
✓ should have named the file with the title of the promotion
✓ should have uploaded the file to S3 (355ms)
✓ should close db connections
CREATE PROMOTION
it should save the promotion
✓ should return 200
✓ should return a correct response
✓ should close db connections
GET PROMOTIONS
✓ should be restricted
it should get the promotions
✓ should return 200
✓ should be an array of promotions
✓ should contain the previously created promotion
UPDATE PROMOTION
it should update the promotion
✓ should return 200
✓ should return a correct response
✓ should close db connections
PUT PROMOTION IN BIN
it should put the promotion in the bin
✓ should return 200
✓ should return a correct response
✓ should close db connections
GET ARCHIVED PROMOTIONS
✓ should be restricted
it should get the promotions
✓ should return 200
✓ should be an array of promotions
✓ should be an array of archived promotions
✓ should contain the previously archived promotion
DELETE PROMOTION
it should delete the promotion
✓ should return 200
✓ should return a correct response
✓ should have deleted the file from S3 (563ms)
✓ should close db connections
As you can see I've tried to put everything regarding promotions in a single test suite so that I can have a sort of workflow to test what the user will do exactly on the platform.
In this example I create a random generate promotion and then use the id of that promotion to read it, update it, archive it and then finally delete it. Every step is connected and I need to have return values for each suit (i.e: The ID of the inserted promotion, or the filters...)
At this moment my promotions.test.js file is 625 and, since I have not finished yet, I expect it to grow a lot in the next days.
Is there a way to split multiple test suits in different files but in a way that each test/file is able to return, as soon as it finishes, a value that I can pass to the next step ?
via Matteo Cardellini
No comments:
Post a Comment