Your First Test
Learn to write your first test in this lesson.
We'll cover the following...
Writing a test
Time for your first test. Create a file called greeting.test.js
:
// greeting.test.js
const greeting = guest => `Hello, ${guest}!`;
describe('greeting()', () => { // 1
it('says hello', () => { // 2
expect(greeting('Jest')).toBe('Hello, Jest!'); // 3
});
});
...
describe()
declares a test suite, which is a grouping of tests. Its first argument is a name, and the second is a function