I want this test to throw because it doesn't have a username. Instead, it doesn't throw and shows username as undefined.
Post.js
class Post {
constructor({username, description, photo}) {
this.username = username;
this.description = description;
this.photo = photo;
}
}
Post.Test.js
test('post must have a username', () => {
expect(() => new Post({description: 'a', photo: 'photo.jpg'})).toThrow();
});
How do I make it throw?
Aucun commentaire:
Enregistrer un commentaire