Skip to content

Instantly share code, notes, and snippets.

@aalencar
Created March 17, 2020 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aalencar/1963c469670cf29f59aea86e8a801b94 to your computer and use it in GitHub Desktop.
Save aalencar/1963c469670cf29f59aea86e8a801b94 to your computer and use it in GitHub Desktop.
Example on how to better organize your test using Jest
describe('Person', () => {
describe('#setName', () => {
it('should set name when name is passed', () => {
const person = new Person();
const name = 'Alex';
person.setName(name);
expect(person.name).toBe(name);
});
});
});
export class Person {
age: number;
name: string;
setName(name: string) {
this.name = name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment