Reputation: 287
I am writing tests for my js compiler and when I input a String, multiple lines are retrieved. What is retrieved is what I want to retrieve, but my test fails because I don't know how to write what is expected for jest.
This is how I call the test:
testRequireImport(
'import { b, a } from \'@sugar/merge/*\';',
'!EXPECTED',
babelOptions
);
This is the reaction in the console:
expect(received).toBe(expected)
Expected value to be (using ===):
"import '../../top/merge/FileInTop.js';,import '../../mid/merge/FileInMid.js';,import '../../mid/merge/Second.js';,import './FileInBot.js';"
Received:
"import '../../top/merge/FileInTop.js';
import '../../mid/merge/FileInMid.js';
import '../../mid/merge/Second.js';
import './FileInBot.js';"
Difference:
- Expected
+ Received
-import '../../top/merge/FileInTop.js';,import '../../mid/merge/FileInMid.js';,import '../../mid/merge/Second.js';,import './FileInBot.js';
+import '../../top/merge/FileInTop.js';
+import '../../mid/merge/FileInMid.js';
+import '../../mid/merge/Second.js';
+import './FileInBot.js';
Can anyone help me with writing what is expected?
Upvotes: 4
Views: 9256
Reputation: 441
Your expected has commas where new lines should be, and your received has new lines instead of commas.
So make your expected match with line breaks
expect(received).toBe(expected.replace(',', '\n'));
Upvotes: 3