I am writing tests for my js piler 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?
I am writing tests for my js piler 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?
Share Improve this question edited Mar 19, 2017 at 14:38 Andreas Köberle 111k58 gold badges280 silver badges307 bronze badges asked Mar 17, 2017 at 15:18 Inbar AzulayInbar Azulay 2871 gold badge6 silver badges28 bronze badges 2- You haven't said what you actually want to happen – Aron Commented Mar 17, 2017 at 15:30
-
@Aron I want my test to succeed. What I receive is correct, but I want to know how to write the
expected
to be equal to the received. – Inbar Azulay Commented Mar 17, 2017 at 16:04
1 Answer
Reset to default 3Your expected has mas where new lines should be, and your received has new lines instead of mas.
So make your expected match with line breaks
expect(received).toBe(expected.replace(',', '\n'));