File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 11"use strict" ;
22
33const path = require ( "path" ) ;
4+ const os = require ( "os" ) ;
45const { test, expect, mergeExpects } = require ( "@playwright/test" ) ;
56
7+ /**
8+ * Returns a new string with all the EOL markers from the string passed in
9+ * replaced with the Operating System specific EOL marker.
10+ * Useful for guaranteeing two transform outputs have the same EOL marker format.
11+ * @param {string } input the string which will have its EOL markers replaced
12+ * @returns {string } a new string with all EOL markers replaced
13+ * @private
14+ */
15+ const normalizeLineEndings = ( input ) => {
16+ return input . replace ( / ( \r \n | \n | \r ) / gmu, os . EOL ) ;
17+ } ;
18+
619/**
720 * Custom Playwright matcher to match a snapshot with an array.
821 *
@@ -37,7 +50,7 @@ const toMatchSnapshotWithArray = expect.extend({
3750 ) ;
3851
3952 try {
40- const serialized = JSON . stringify ( received ) ;
53+ const serialized = normalizeLineEndings ( JSON . stringify ( received ) ) ;
4154 await expect ( serialized ) . toMatchSnapshot ( {
4255 name : snapshotFilePath ,
4356 } ) ;
You can’t perform that action at this time.
0 commit comments