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?
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'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With