Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce tests boilerplate code #307

Open
AzisK opened this issue Dec 7, 2021 · 0 comments
Open

Reduce tests boilerplate code #307

AzisK opened this issue Dec 7, 2021 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@AzisK
Copy link
Collaborator

AzisK commented Dec 7, 2021

Goal
Reduce tests boilerplate code

Description
Reduce tests boilerplate code by using the post method in https://github.com/pets-oss/pets-back/blob/main/test/utils/requests.ts

Example of such usage

it('Returns animal id=1 with all fields', (done) => {
const req = requests(`{ animal(id: 1)
${animalFields}
}`);
req.expect(200)
.end((err, res) => {
if (err) {
// eslint-disable-next-line no-console
console.log(res.body);
return done(err);
}
validate(res.body.data.animal);
return done();
});
});

Bonus
It would be great to abstract and hide the error logging code from the main test logic

if (err) { 
    // eslint-disable-next-line no-console 
    console.log(res.body); 
    return done(err); 
}
@AzisK AzisK added the enhancement New feature or request label Dec 7, 2021
@AzisK AzisK added the good first issue Good for newcomers label Dec 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant