Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit fdb7539

Browse files
author
Walker
committed
Add snapshot testing for error messages
1 parent cfe93f1 commit fdb7539

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`new Writer([filePath]) ensures filePath is not an object 1`] = `"Expected 'files' to be of type 'Array' or a 'string', instead got 'undefined'"`;
4+
5+
exports[`new Writer([filePath]) ensures filePath[] is an array of strings 1`] = `"Expected 'file' (null) to be of type 'string', instead got 'object'"`;
6+
7+
exports[`new Writer([filePath]) ensures filePath[] is not a number 1`] = `"Expected 'files' to be of type 'Array' or a 'string', instead got 'undefined'"`;
8+
9+
exports[`new Writer([filePath]) ensures filePath[] is not null 1`] = `"Expected 'files' to be of type 'Array' or a 'string', instead got 'undefined'"`;
10+
11+
exports[`new Writer([filePath]) ensures valid filePath provided 1`] = `"Expected 'file' (fake.css) to be an absolute path to a file but it was not"`;
12+
13+
exports[`new Writer([filePath]) ensures valid filePaths provided in array 1`] = `"Expected 'file' (fake.css) to be an absolute path to a file but it was not"`;
14+
15+
exports[`new Writer(filePath) relative paths throw error 1`] = `"Expected 'file' (./test-assets/my-module-1/main.css) to be an absolute path to a file but it was not"`;

test/writer.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ test('new Writer(filePath) relative paths throw error', () => {
8282

8383
const result = () => new Writer(filePath);
8484

85-
expect(result).toThrow();
85+
expect(result).toThrowErrorMatchingSnapshot();
8686
});
8787

8888
test('new Writer([filePath])', done => {
@@ -163,7 +163,7 @@ test('new Writer([filePath]) ensures filePath[] is not null', () => {
163163

164164
const result = () => new Writer(filePath);
165165

166-
expect(result).toThrow();
166+
expect(result).toThrowErrorMatchingSnapshot();
167167
});
168168

169169
test('new Writer([filePath]) ensures filePath[] is not a number', () => {
@@ -172,7 +172,7 @@ test('new Writer([filePath]) ensures filePath[] is not a number', () => {
172172

173173
const result = () => new Writer(filePath);
174174

175-
expect(result).toThrow();
175+
expect(result).toThrowErrorMatchingSnapshot();
176176
});
177177

178178
test('new Writer([filePath]) ensures filePath is not an object', () => {
@@ -181,7 +181,7 @@ test('new Writer([filePath]) ensures filePath is not an object', () => {
181181

182182
const result = () => new Writer(filePath);
183183

184-
expect(result).toThrow();
184+
expect(result).toThrowErrorMatchingSnapshot();
185185
});
186186

187187
test('new Writer([filePath]) ensures filePath[] is an array of strings', () => {
@@ -190,7 +190,7 @@ test('new Writer([filePath]) ensures filePath[] is an array of strings', () => {
190190

191191
const result = () => new Writer([filePath]);
192192

193-
expect(result).toThrow();
193+
expect(result).toThrowErrorMatchingSnapshot();
194194
});
195195

196196
test('new Writer([filePath]) ensures valid filePath provided', () => {
@@ -199,7 +199,7 @@ test('new Writer([filePath]) ensures valid filePath provided', () => {
199199

200200
const result = () => new Writer(filePath);
201201

202-
expect(result).toThrow();
202+
expect(result).toThrowErrorMatchingSnapshot();
203203
});
204204

205205
test('new Writer([filePath]) ensures valid filePaths provided in array', () => {
@@ -208,7 +208,7 @@ test('new Writer([filePath]) ensures valid filePaths provided in array', () => {
208208

209209
const result = () => new Writer([filePath]);
210210

211-
expect(result).toThrow();
211+
expect(result).toThrowErrorMatchingSnapshot();
212212
});
213213

214214
test('writer emits error', done => {

0 commit comments

Comments
 (0)