From 2676032aa3e266000ff358b9cdfb9d9e49fa080c Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Tue, 23 Jan 2024 22:48:57 +0100 Subject: [PATCH 1/5] Make applyFixes async, avoiding prettyMaybe.sync https://github.com/sunesimonsen/offline-github-changelog/pull/102#issuecomment-1906971694 --- lib/applyFixes.js | 4 ++-- lib/unexpected-snapshot-update.js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/applyFixes.js b/lib/applyFixes.js index a221ab3..abe6b94 100644 --- a/lib/applyFixes.js +++ b/lib/applyFixes.js @@ -185,7 +185,7 @@ function fixUnassessed( return fixes; } -function applyFixes(fixes) { +async function applyFixes(fixes) { const fixesByFileName = {}; let numFixedExpects = 0; for (const fix of fixes) { @@ -254,7 +254,7 @@ function applyFixes(fixes) { if ( !/^(?:0|false|off|no)$/.test(process.env.UNEXPECTED_SNAPSHOT_PRETTIER) ) { - fixedCode = prettyMaybe.sync(fileName, fixedCode, { + fixedCode = await prettyMaybe(fileName, fixedCode, { requireConfig: false, }); } diff --git a/lib/unexpected-snapshot-update.js b/lib/unexpected-snapshot-update.js index e4bed55..bd4fd5c 100644 --- a/lib/unexpected-snapshot-update.js +++ b/lib/unexpected-snapshot-update.js @@ -14,8 +14,9 @@ function ensureAfterHookIsRegistered() { } afterBlockRegistered = true; after(async function () { - const { numFixedExpects, fixedSourceTextByFileName } = - applyFixes(topLevelFixes); + const { numFixedExpects, fixedSourceTextByFileName } = await applyFixes( + topLevelFixes + ); const fileNames = Object.keys(fixedSourceTextByFileName); From ff2962493e1769d6452e2f1c117d667c65709023 Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Tue, 23 Jan 2024 22:50:35 +0100 Subject: [PATCH 2/5] Update prettier to ~3.2.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c8f27ae..cc57127 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "mocha": "^8.0.1", "nyc": "^15.0.0", "offline-github-changelog": "^2.0.0", - "prettier": "~2.5.0", + "prettier": "~3.2.4", "rollup": "^2.0.3", "rollup-plugin-commonjs": "^10.0.0", "rollup-plugin-json": "^4.0.0", From 7a2331943f34d19348bff8c13cfbb775af474bcd Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Tue, 23 Jan 2024 22:50:59 +0100 Subject: [PATCH 3/5] prettier --write '**/*.{js,md}' --- README.md | 2 +- lib/applyFixes.js | 46 ++++----- lib/createInspector.js | 4 +- lib/getSourceCode.js | 2 +- lib/isSimpleObjectTree.js | 2 +- lib/run.js | 2 +- lib/unexpected-snapshot-check.js | 4 +- lib/unexpected-snapshot-update.js | 19 ++-- test/browser/index.js | 8 +- test/indentString.js | 2 +- test/unexpected-snapshot.js | 154 +++++++++++++++--------------- 11 files changed, 122 insertions(+), 123 deletions(-) diff --git a/README.md b/README.md index b40cfef..1b048c3 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ function Person(name) { expect( new Person('Eigil'), 'to inspect as snapshot', - "Person({ name: 'Eigil' })" + "Person({ name: 'Eigil' })", ); ``` diff --git a/lib/applyFixes.js b/lib/applyFixes.js index abe6b94..ac1a9e2 100644 --- a/lib/applyFixes.js +++ b/lib/applyFixes.js @@ -11,7 +11,7 @@ function stringify(obj, indentationWidth, inspect, expectName = 'expect') { if (obj.includes('\n') && !/^\n*[ \t]/.test(obj)) { return `${expectName}.unindent\`${indentString( obj.replace(/[`$]/g, '\\$&'), - indentationWidth + indentationWidth, )}\``; } else { return inspect(obj, indentationWidth); @@ -20,7 +20,7 @@ function stringify(obj, indentationWidth, inspect, expectName = 'expect') { // Only parse each file once, even though multiple fixes have to be applied: const getSourceCodeMemoized = require('memoizesync')( - require('./getSourceCode') + require('./getSourceCode'), ); function getNodeIndent(node, sourceCode, byLastLine) { @@ -32,7 +32,7 @@ function getNodeIndent(node, sourceCode, byLastLine) { .split(''); const indentChars = srcCharsBeforeNode.slice( 0, - srcCharsBeforeNode.findIndex((char) => char !== ' ' && char !== '\t') + srcCharsBeforeNode.findIndex((char) => char !== ' ' && char !== '\t'), ); const spaces = indentChars.filter((char) => char === ' ').length; const tabs = indentChars.filter((char) => char === '\t').length; @@ -50,7 +50,7 @@ function fixUnexpected( node, sourceCode, indentationWidth, - { status, subject, inspect, assertionName } + { status, subject, inspect, assertionName }, ) { // Take compound assertions into account: const assertionArgument = @@ -60,7 +60,7 @@ function fixUnexpected( !assertionArgument.value.endsWith(assertionName) // Allow compound ) { throw new Error( - `unexpected-snapshot could not find '${assertionName}' assertion to patch up. Note that expect.it is not supported` + `unexpected-snapshot could not find '${assertionName}' assertion to patch up. Note that expect.it is not supported`, ); } // Find the indentation of the literal being replaced, @@ -77,7 +77,7 @@ function fixUnexpected( if (typeof subject === 'string' && assertionName === 'to equal snapshot') { stringifiedSubject = stringify(subject, indentationWidth, inspect).replace( /\n^(?=[^\n])/gm, - `\n${indent}` + `\n${indent}`, ); } else if ( isSimpleObjectTree(subject) && @@ -89,25 +89,25 @@ function fixUnexpected( stringifiedSubject = stringify( inspect(subject, indentationWidth), indentationWidth, - inspect + inspect, ).replace(/\n^(?=[^\n])/gm, `\n${indent}`); } const newAssertionNameWithPrefix = assertionArgument.value.replace( assertionName, - newAssertionName + newAssertionName, ); if (status === 'missing') { if (newAssertionName === assertionName) { fixes.unshift( - ruleFixer.insertTextAfter(assertionArgument, `, ${stringifiedSubject}`) + ruleFixer.insertTextAfter(assertionArgument, `, ${stringifiedSubject}`), ); } else { fixes.unshift( ruleFixer.replaceText( assertionArgument, - `'${newAssertionNameWithPrefix}', ${stringifiedSubject}` - ) + `'${newAssertionNameWithPrefix}', ${stringifiedSubject}`, + ), ); } } else if (status === 'mismatch') { @@ -115,15 +115,15 @@ function fixUnexpected( fixes.unshift( ruleFixer.replaceText( assertionArgument, - `'${newAssertionNameWithPrefix}'` - ) + `'${newAssertionNameWithPrefix}'`, + ), ); } fixes.unshift( ruleFixer.replaceText( node.arguments[node.arguments.length - 1], - stringifiedSubject - ) + stringifiedSubject, + ), ); } return fixes; @@ -133,7 +133,7 @@ function fixUnassessed( node, sourceCode, indentationWidth, - { status, subject, inspect, assertionName } + { status, subject, inspect, assertionName }, ) { // Find the indentation of the literal being replaced, // falling back to that of assess(...) @@ -152,7 +152,7 @@ function fixUnassessed( subject, indentationWidth, inspect, - node.callee.object.callee.name + node.callee.object.callee.name, ).replace(/\n^(?=[^\n])/gm, `\n${indent}`); } else if ( isSimpleObjectTree(subject) && @@ -165,19 +165,19 @@ function fixUnassessed( inspect(subject, indentationWidth), indentationWidth, inspect, - node.callee.object.callee.name + node.callee.object.callee.name, ).replace(/\n^(?=[^\n])/gm, `\n${indent}`); } if (newAssertionName !== assertionName) { fixes.unshift( - ruleFixer.replaceText(node.callee.property, camelCase(newAssertionName)) + ruleFixer.replaceText(node.callee.property, camelCase(newAssertionName)), ); } if (status === 'missing') { const endParenToken = sourceCode.getLastToken(node); fixes.unshift( - ruleFixer.insertTextBefore(endParenToken, stringifiedSubject) + ruleFixer.insertTextBefore(endParenToken, stringifiedSubject), ); } else if (status === 'mismatch') { fixes.unshift(ruleFixer.replaceText(node.arguments[0], stringifiedSubject)); @@ -223,7 +223,7 @@ async function applyFixes(fixes) { ['expect', 'assess'].includes(node.callee.object.callee.name) && node.callee.property.type === 'Identifier' && ['toEqualSnapshot', 'toInspectAsSnapshot'].includes( - node.callee.property.name + node.callee.property.name, ) && node.callee.property.loc.start.line === lineNumber && node.callee.property.loc.start.column + 1 === columnNumber @@ -235,7 +235,7 @@ async function applyFixes(fixes) { if (appliedFixes && appliedFixes.length > 0) { (fixesByFileName[fileName] = fixesByFileName[fileName] || []).push( - ...appliedFixes + ...appliedFixes, ); } }, @@ -246,7 +246,7 @@ async function applyFixes(fixes) { for (const fileName of Object.keys(fixesByFileName)) { const fixResult = SourceCodeFixer.applyFixes( getSourceCodeMemoized(fileName).text, - fixesByFileName[fileName].map((fix) => ({ fix })) + fixesByFileName[fileName].map((fix) => ({ fix })), ); if (fixResult.fixed) { diff --git a/lib/createInspector.js b/lib/createInspector.js index 6e5e6cb..38756a6 100644 --- a/lib/createInspector.js +++ b/lib/createInspector.js @@ -12,7 +12,7 @@ const createInspector = (expect) => { if (value.length > 32) { return output.code( `Buffer.from('${value.toString('base64')}', 'base64')`, - 'javascript' + 'javascript', ); } else { return this.baseType.inspect.call( @@ -20,7 +20,7 @@ const createInspector = (expect) => { value, depth, output, - inspect + inspect, ); } }, diff --git a/lib/getSourceCode.js b/lib/getSourceCode.js index e96ef76..1fe3fd7 100644 --- a/lib/getSourceCode.js +++ b/lib/getSourceCode.js @@ -99,7 +99,7 @@ function getSourceCode(fileName) { return `//${captured}`; }), { parser: 'espree' }, - fileName + fileName, ); let ast; diff --git a/lib/isSimpleObjectTree.js b/lib/isSimpleObjectTree.js index 9687b32..f29edb7 100644 --- a/lib/isSimpleObjectTree.js +++ b/lib/isSimpleObjectTree.js @@ -17,7 +17,7 @@ function isSimpleObjectTree(obj) { const result = obj.constructor === Object && Object.getOwnPropertyNames(obj).every((name) => - isSimple(obj[name]) + isSimple(obj[name]), ) && Object.getOwnPropertySymbols(obj).length === 0; seen.delete(obj); diff --git a/lib/run.js b/lib/run.js index 8543531..43af90f 100644 --- a/lib/run.js +++ b/lib/run.js @@ -37,7 +37,7 @@ module.exports = function run(command, args, options) { err, bufferedLinesByStreamName.stdout, bufferedLinesByStreamName.stderr, - ]) + ]), ) .on('exit', (exitCode) => { resolve([ diff --git a/lib/unexpected-snapshot-check.js b/lib/unexpected-snapshot-check.js index de7fd29..21754e1 100644 --- a/lib/unexpected-snapshot-check.js +++ b/lib/unexpected-snapshot-check.js @@ -37,7 +37,7 @@ module.exports = { withSnapshotMessageAppended(expect, () => { expect(subject, 'to equal', value); }); - } + }, ); expect.addAssertion(' to inspect as snapshot', (expect) => { @@ -52,7 +52,7 @@ module.exports = { withSnapshotMessageAppended(expect, () => { expect(inspect(subject), 'to equal', value); }); - } + }, ); }, }; diff --git a/lib/unexpected-snapshot-update.js b/lib/unexpected-snapshot-update.js index bd4fd5c..6f8d964 100644 --- a/lib/unexpected-snapshot-update.js +++ b/lib/unexpected-snapshot-update.js @@ -14,9 +14,8 @@ function ensureAfterHookIsRegistered() { } afterBlockRegistered = true; after(async function () { - const { numFixedExpects, fixedSourceTextByFileName } = await applyFixes( - topLevelFixes - ); + const { numFixedExpects, fixedSourceTextByFileName } = + await applyFixes(topLevelFixes); const fileNames = Object.keys(fixedSourceTextByFileName); @@ -30,7 +29,7 @@ function ensureAfterHookIsRegistered() { numFixedExpects === 1 ? '' : 's' } in ${fileNames.length} source file${ fileNames.length === 1 ? '' : 's' - }` + }`, ); const Promise = require('bluebird'); @@ -41,13 +40,13 @@ function ensureAfterHookIsRegistered() { fileNames, (fileName) => fs.writeFileAsync(fileName, fixedSourceTextByFileName[fileName]), - { concurrency: 5 } + { concurrency: 5 }, ); console.log( `unexpected-snapshot: Wrote ${results.length} file${ results.length === 1 ? '' : 's' - }` + }`, ); } // Replay the calls that were made while were writing files: @@ -98,10 +97,10 @@ module.exports = { ensureAfterHookIsRegistered(); } else { throw new Error( - 'unexpected-snapshot: Could not figure out the location of the expect() call to patch up' + 'unexpected-snapshot: Could not figure out the location of the expect() call to patch up', ); } - } + }, ); expect.addAssertion( @@ -131,9 +130,9 @@ module.exports = { } else { throw err; } - } + }, ); - } + }, ); expect.unindent = require('@gustavnikolaj/string-utils').deindent; diff --git a/test/browser/index.js b/test/browser/index.js index 927a919..db35d74 100644 --- a/test/browser/index.js +++ b/test/browser/index.js @@ -20,7 +20,7 @@ describe('unexpected-snapshot', function () { '-abc\n' + '+def\n' + '\n' + - 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots' + 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots', ); }); }); @@ -34,7 +34,7 @@ describe('unexpected-snapshot', function () { expect( new Person('Eigil'), 'to inspect as snapshot', - "Person({ name: 'Eigil' })" + "Person({ name: 'Eigil' })", ); }); @@ -44,13 +44,13 @@ describe('unexpected-snapshot', function () { expect( new Person('Eigil'), 'to equal snapshot', - "Person({ name: 'Preben' })" + "Person({ name: 'Preben' })", ); }, 'to throw', "expected Person({ name: 'Eigil' }) to equal snapshot 'Person({ name: \\'Preben\\' })'\n" + '\n' + - 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots' + 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots', ); }); }); diff --git a/test/indentString.js b/test/indentString.js index f646043..5ed3fdb 100644 --- a/test/indentString.js +++ b/test/indentString.js @@ -24,7 +24,7 @@ describe('stringSnapshot', () => { expect( indentString('foo\n \nbar', 2), 'to equal', - '\n foo\n \n bar\n' + '\n foo\n \n bar\n', ); }); diff --git a/test/unexpected-snapshot.js b/test/unexpected-snapshot.js index 0a262ab..e950bf7 100644 --- a/test/unexpected-snapshot.js +++ b/test/unexpected-snapshot.js @@ -9,25 +9,25 @@ describe('with snapshot updating on', function () { const espree = require('espree'); const preambleByType = { unexpected: `var expect = require('${require.resolve( - 'unexpected' + 'unexpected', )}').clone().use(require('${pathModule.resolve( __dirname, '..', 'lib', - 'unexpected-snapshot.js' + 'unexpected-snapshot.js', )}'));\n// END PREAMBLE\n`, unassessed: `var assess = require('${require.resolve( - 'unassessed' + 'unassessed', )}').withUnexpectedPlugins(require('${pathModule.resolve( __dirname, '..', 'lib', - 'unexpected-snapshot.js' + 'unexpected-snapshot.js', )}'));\n// END PREAMBLE\n`, }; const tmpDir = pathModule.resolve( require('os').tmpdir(), - `unexpected-snapshot-test-${Date.now()}-${process.pid}` + `unexpected-snapshot-test-${Date.now()}-${process.pid}`, ); before(async () => { @@ -61,7 +61,7 @@ describe('with snapshot updating on', function () { async function writeTestToTemporaryFile(code, type = 'unexpected') { const tmpFileName = pathModule.resolve( tmpDir, - `unexpected-snapshot-${Math.round(10000000 * Math.random())}.js` + `unexpected-snapshot-${Math.round(10000000 * Math.random())}.js`, ); await fs.writeFileAsync(tmpFileName, preambleByType[type] + code, 'utf-8'); return tmpFileName; @@ -76,14 +76,14 @@ describe('with snapshot updating on', function () { '..', 'node_modules', '.bin', - 'mocha' + 'mocha', )} ${fileNames.join(' ')}`; const [err, stdout, stderr] = await expect.promise.fromNode((cb) => childProcess.exec( testCommand, { env: { ...process.env, ...env } }, - cb.bind(null, null) - ) + cb.bind(null, null), + ), ); return [err, stdout, stderr]; } @@ -104,10 +104,10 @@ describe('with snapshot updating on', function () { expect.flags['with unassessed'] ? 'unassessed' : 'unexpected' ]; const output = (await fs.readFileAsync(tmpFileName, 'utf-8')).substr( - preamble.length + preamble.length, ); expect(beautifyJavaScript(output), 'to equal', subject); - } + }, ); expect.addAssertion( @@ -145,7 +145,7 @@ describe('with snapshot updating on', function () { let output = (await fs.readFileAsync(tmpFileName, 'utf-8')).replace( /^[\s\S]*?\/\/ END PREAMBLE\n/, - '' + '', ); if (!expect.flags.exactly) { output = beautifyJavaScript(output); @@ -166,7 +166,7 @@ describe('with snapshot updating on', function () { } await fs.unlinkAsync(tmpFileName); } - } + }, ); describe('inspect as snapshot', () => { @@ -183,10 +183,10 @@ describe('with snapshot updating on', function () { expect( ['a', 'b', 'c'], 'to inspect as snapshot', - "[ 'a', 'b', 'c' ]" + "[ 'a', 'b', 'c' ]", ); }); - } + }, ); }); @@ -197,7 +197,7 @@ describe('with snapshot updating on', function () { expect( ['a', 'b', 'c'], 'to inspect as snapshot', - "['a', 'b', 'c']" + "['a', 'b', 'c']", ); }); }, @@ -207,10 +207,10 @@ describe('with snapshot updating on', function () { expect( ['a', 'b', 'c'], 'to inspect as snapshot', - "[ 'a', 'b', 'c' ]" + "[ 'a', 'b', 'c' ]", ); }); - } + }, ); }); @@ -222,7 +222,7 @@ describe('with snapshot updating on', function () { ['c', 'a', 'b'], 'when sorted', 'to inspect as snapshot', - "['a', 'b', 'c']" + "['a', 'b', 'c']", ); }); }, @@ -233,10 +233,10 @@ describe('with snapshot updating on', function () { ['c', 'a', 'b'], 'when sorted', 'to inspect as snapshot', - "[ 'a', 'b', 'c' ]" + "[ 'a', 'b', 'c' ]", ); }); - } + }, ); }); @@ -249,7 +249,7 @@ describe('with snapshot updating on', function () { down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } }, }, 'to inspect as snapshot', - '{ down: { the: { rabbit: { hole: {} } } } }' + '{ down: { the: { rabbit: { hole: {} } } } }', ); }); }, @@ -261,10 +261,10 @@ describe('with snapshot updating on', function () { down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } }, }, 'to inspect as snapshot', - "{ down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } } }" + "{ down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } } }", ); }); - } + }, ); }); @@ -282,7 +282,7 @@ describe('with snapshot updating on', function () { it('should foo', function () { assess(['a', 'b', 'c']).toInspectAsSnapshot("[ 'a', 'b', 'c' ]"); }); - } + }, ); }); @@ -298,7 +298,7 @@ describe('with snapshot updating on', function () { it('should foo', function () { assess(['a', 'b', 'c']).toInspectAsSnapshot("[ 'a', 'b', 'c' ]"); }); - } + }, ); }); }); @@ -317,7 +317,7 @@ it('should foo', function() { it('should foo', function() { expect('foo', 'to equal snapshot', 'foo'); }); - ` + `, ); }); @@ -336,7 +336,7 @@ it('should foo', function() { \`); }); - ` + `, ); }); @@ -355,7 +355,7 @@ it('should foo', function() { \`); }); - ` + `, ); }); @@ -371,7 +371,7 @@ it('should foo', function() { it('should foo', function() { expect('\\n foo', 'to equal snapshot', '\\n foo'); }); - ` + `, ); }); @@ -387,7 +387,7 @@ it('should foo', function() { it('should foo', function() { expect(' foo\\n', 'to equal snapshot', ' foo\\n'); }); - ` + `, ); }); @@ -411,7 +411,7 @@ it('should foo', function() { 'foo' ); }); - ` + `, ); }); @@ -438,7 +438,7 @@ it('should foo', function() { \` ); }); - ` + `, ); }); @@ -458,7 +458,7 @@ it('should foo', function() { bar \`); }); - ` + `, ); }); @@ -481,7 +481,7 @@ if (true) { \`); }); } - ` + `, ); }); @@ -504,7 +504,7 @@ if (true) { \`); }); } - ` + `, ); }); }); @@ -523,7 +523,7 @@ it('should foo', function() { it('should foo', function() { expect('foo', 'to equal snapshot', 'foo'); }); - ` + `, ); }); @@ -539,7 +539,7 @@ it('should foo', function() { it('should foo', function() { expect('foo', 'to equal snapshot', 'foo'); }); - ` + `, ); }); @@ -559,7 +559,7 @@ it('should foo', function() { bar \`); }); - ` + `, ); }); @@ -581,7 +581,7 @@ it('should foo', function() { bar \`); }); - ` + `, ); }); @@ -597,7 +597,7 @@ it('should foo', function() { it('should foo', function () { expect({ foo: 'bar' }, 'to equal snapshot', { foo: 'bar' }); }); - } + }, ); }); @@ -613,7 +613,7 @@ it('should foo', function() { it('should foo', function () { expect([123, 'abc'], 'to equal snapshot', [123, 'abc']); }); - } + }, ); }); @@ -635,10 +635,10 @@ it('should foo', function() { expect( foo, 'to inspect as snapshot', - '{ bar: 123, quux: [Circular] }' + '{ bar: 123, quux: [Circular] }', ); }); - } + }, ); }); @@ -647,7 +647,7 @@ it('should foo', function() { return expect( () => { expect.addAssertion(' noop ', (expect) => - expect.shift() + expect.shift(), ); it('should foo', function () { @@ -659,7 +659,7 @@ it('should foo', function() { 'to come out as', function () { expect.addAssertion(' noop ', (expect) => - expect.shift() + expect.shift(), ); it('should foo', function () { @@ -668,10 +668,10 @@ it('should foo', function() { expect( foo, 'noop to inspect as snapshot', - '{ bar: 123, quux: [Circular] }' + '{ bar: 123, quux: [Circular] }', ); }); - } + }, ); }); @@ -680,7 +680,7 @@ it('should foo', function() { return expect( () => { expect.addAssertion(' noop ', (expect) => - expect.shift() + expect.shift(), ); it('should foo', function () { @@ -692,7 +692,7 @@ it('should foo', function() { 'to come out as', function () { expect.addAssertion(' noop ', (expect) => - expect.shift() + expect.shift(), ); it('should foo', function () { @@ -701,10 +701,10 @@ it('should foo', function() { expect( foo, 'noop to inspect as snapshot', - '{ bar: 123, quux: [Circular] }' + '{ bar: 123, quux: [Circular] }', ); }); - } + }, ); }); }); @@ -730,10 +730,10 @@ it('should foo', function() { expect( new Person('Eigil'), 'to inspect as snapshot', - "Person({ name: 'Eigil' })" + "Person({ name: 'Eigil' })", ); }); - } + }, ); }); @@ -752,7 +752,7 @@ it('should foo', function() { number: 123.456, regexp: /abc(?:)/gim, }, - 'to equal snapshot' + 'to equal snapshot', ); }); }, @@ -780,10 +780,10 @@ it('should foo', function() { Infinity: Infinity, number: 123.456, regexp: /abc(?:)/gim, - } + }, ); }); - } + }, ); }); @@ -806,7 +806,7 @@ it('should foo', function() { 'c', ]); }); - } + }, ); }); @@ -819,7 +819,7 @@ it('should foo', function() { down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } }, }, 'to equal snapshot', - { down: { the: { rabbit: { hole: {} } } } } + { down: { the: { rabbit: { hole: {} } } } }, ); }); }, @@ -833,10 +833,10 @@ it('should foo', function() { 'to equal snapshot', { down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } }, - } + }, ); }); - } + }, ); }); @@ -857,7 +857,7 @@ it('should foo', function() { bar: expect.it('to equal snapshot', 'foo'), }); }); - } + }, ); }); @@ -879,7 +879,7 @@ it('should foo', function() { }), }); }); - } + }, ); }); }); @@ -900,12 +900,12 @@ it('should foo', function() { UNEXPECTED_SNAPSHOT: 'on', }); const fixedSrcs = await Promise.all( - tmpFileNames.map((fileName) => fs.readFileAsync(fileName, 'utf-8')) + tmpFileNames.map((fileName) => fs.readFileAsync(fileName, 'utf-8')), ); expect( fixedSrcs, 'to have items satisfying to contain', - `expect("foo", "to equal snapshot", "foo");` + `expect("foo", "to equal snapshot", "foo");`, ); }); }); @@ -927,7 +927,7 @@ it('should foo', function() { 'to equal snapshot', 'foo' ); }); -` +`, ); }); @@ -946,7 +946,7 @@ it('should foo', function() { it('should foo', function () { expect('foo', 'to equal snapshot', 'foo'); }); -` +`, ); }); }); @@ -966,7 +966,7 @@ it('should foo', function () { it('should foo', function () { assess('foo').toEqualSnapshot('foo'); }); - } + }, ); }); @@ -986,7 +986,7 @@ it('should foo', function () { foo.quux = foo; assess(foo).toInspectAsSnapshot('{ bar: 123, quux: [Circular] }'); }); - } + }, ); }); @@ -1006,7 +1006,7 @@ it('should foo', function() { baz \`); }); -` +`, ); }); }); @@ -1024,7 +1024,7 @@ it('should foo', function() { it('should foo', function () { assess('foo').toEqualSnapshot('foo'); }); - } + }, ); }); }); @@ -1043,7 +1043,7 @@ describe('with snapshot updating off', function () { 'to throw', 'expected 42 to equal snapshot\n' + '\n' + - 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots' + 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots', ); }); @@ -1061,7 +1061,7 @@ describe('with snapshot updating off', function () { 'to throw', 'expected 42 to equal snapshot 666\n' + '\n' + - 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots' + 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots', ); }); @@ -1070,7 +1070,7 @@ describe('with snapshot updating off', function () { expect( { down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } } }, 'to equal snapshot', - { down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } } } + { down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } } }, ); }, 'not to throw'); }); @@ -1085,7 +1085,7 @@ describe('with snapshot updating off', function () { 'to throw', 'expected 42 to inspect as snapshot\n' + '\n' + - 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots' + 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots', ); }); @@ -1106,7 +1106,7 @@ describe('with snapshot updating off', function () { '-42\n' + '+666\n' + '\n' + - 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots' + 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots', ); }); @@ -1115,7 +1115,7 @@ describe('with snapshot updating off', function () { expect( { down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } } }, 'to inspect as snapshot', - "{ down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } } }" + "{ down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } } }", ); }, 'not to throw'); }); From f226df447420c264cdd92801679d2ffc9324fc8e Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Tue, 23 Jan 2024 22:57:19 +0100 Subject: [PATCH 4/5] Undo new tralingComma default in prettier 3 that breaks IE --- .prettierrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.prettierrc b/.prettierrc index 544138b..c1a6f66 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,3 +1,4 @@ { - "singleQuote": true + "singleQuote": true, + "trailingComma": "es5" } From 46c09120ebabad285fca407a87bc4a0bce46da17 Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Tue, 23 Jan 2024 22:57:39 +0100 Subject: [PATCH 5/5] prettier --write '**/*.{js,md}' --- README.md | 2 +- lib/applyFixes.js | 46 ++++----- lib/createInspector.js | 4 +- lib/getSourceCode.js | 2 +- lib/isSimpleObjectTree.js | 2 +- lib/run.js | 2 +- lib/unexpected-snapshot-check.js | 4 +- lib/unexpected-snapshot-update.js | 14 +-- test/browser/index.js | 8 +- test/indentString.js | 2 +- test/unexpected-snapshot.js | 154 +++++++++++++++--------------- 11 files changed, 120 insertions(+), 120 deletions(-) diff --git a/README.md b/README.md index 1b048c3..b40cfef 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ function Person(name) { expect( new Person('Eigil'), 'to inspect as snapshot', - "Person({ name: 'Eigil' })", + "Person({ name: 'Eigil' })" ); ``` diff --git a/lib/applyFixes.js b/lib/applyFixes.js index ac1a9e2..abe6b94 100644 --- a/lib/applyFixes.js +++ b/lib/applyFixes.js @@ -11,7 +11,7 @@ function stringify(obj, indentationWidth, inspect, expectName = 'expect') { if (obj.includes('\n') && !/^\n*[ \t]/.test(obj)) { return `${expectName}.unindent\`${indentString( obj.replace(/[`$]/g, '\\$&'), - indentationWidth, + indentationWidth )}\``; } else { return inspect(obj, indentationWidth); @@ -20,7 +20,7 @@ function stringify(obj, indentationWidth, inspect, expectName = 'expect') { // Only parse each file once, even though multiple fixes have to be applied: const getSourceCodeMemoized = require('memoizesync')( - require('./getSourceCode'), + require('./getSourceCode') ); function getNodeIndent(node, sourceCode, byLastLine) { @@ -32,7 +32,7 @@ function getNodeIndent(node, sourceCode, byLastLine) { .split(''); const indentChars = srcCharsBeforeNode.slice( 0, - srcCharsBeforeNode.findIndex((char) => char !== ' ' && char !== '\t'), + srcCharsBeforeNode.findIndex((char) => char !== ' ' && char !== '\t') ); const spaces = indentChars.filter((char) => char === ' ').length; const tabs = indentChars.filter((char) => char === '\t').length; @@ -50,7 +50,7 @@ function fixUnexpected( node, sourceCode, indentationWidth, - { status, subject, inspect, assertionName }, + { status, subject, inspect, assertionName } ) { // Take compound assertions into account: const assertionArgument = @@ -60,7 +60,7 @@ function fixUnexpected( !assertionArgument.value.endsWith(assertionName) // Allow compound ) { throw new Error( - `unexpected-snapshot could not find '${assertionName}' assertion to patch up. Note that expect.it is not supported`, + `unexpected-snapshot could not find '${assertionName}' assertion to patch up. Note that expect.it is not supported` ); } // Find the indentation of the literal being replaced, @@ -77,7 +77,7 @@ function fixUnexpected( if (typeof subject === 'string' && assertionName === 'to equal snapshot') { stringifiedSubject = stringify(subject, indentationWidth, inspect).replace( /\n^(?=[^\n])/gm, - `\n${indent}`, + `\n${indent}` ); } else if ( isSimpleObjectTree(subject) && @@ -89,25 +89,25 @@ function fixUnexpected( stringifiedSubject = stringify( inspect(subject, indentationWidth), indentationWidth, - inspect, + inspect ).replace(/\n^(?=[^\n])/gm, `\n${indent}`); } const newAssertionNameWithPrefix = assertionArgument.value.replace( assertionName, - newAssertionName, + newAssertionName ); if (status === 'missing') { if (newAssertionName === assertionName) { fixes.unshift( - ruleFixer.insertTextAfter(assertionArgument, `, ${stringifiedSubject}`), + ruleFixer.insertTextAfter(assertionArgument, `, ${stringifiedSubject}`) ); } else { fixes.unshift( ruleFixer.replaceText( assertionArgument, - `'${newAssertionNameWithPrefix}', ${stringifiedSubject}`, - ), + `'${newAssertionNameWithPrefix}', ${stringifiedSubject}` + ) ); } } else if (status === 'mismatch') { @@ -115,15 +115,15 @@ function fixUnexpected( fixes.unshift( ruleFixer.replaceText( assertionArgument, - `'${newAssertionNameWithPrefix}'`, - ), + `'${newAssertionNameWithPrefix}'` + ) ); } fixes.unshift( ruleFixer.replaceText( node.arguments[node.arguments.length - 1], - stringifiedSubject, - ), + stringifiedSubject + ) ); } return fixes; @@ -133,7 +133,7 @@ function fixUnassessed( node, sourceCode, indentationWidth, - { status, subject, inspect, assertionName }, + { status, subject, inspect, assertionName } ) { // Find the indentation of the literal being replaced, // falling back to that of assess(...) @@ -152,7 +152,7 @@ function fixUnassessed( subject, indentationWidth, inspect, - node.callee.object.callee.name, + node.callee.object.callee.name ).replace(/\n^(?=[^\n])/gm, `\n${indent}`); } else if ( isSimpleObjectTree(subject) && @@ -165,19 +165,19 @@ function fixUnassessed( inspect(subject, indentationWidth), indentationWidth, inspect, - node.callee.object.callee.name, + node.callee.object.callee.name ).replace(/\n^(?=[^\n])/gm, `\n${indent}`); } if (newAssertionName !== assertionName) { fixes.unshift( - ruleFixer.replaceText(node.callee.property, camelCase(newAssertionName)), + ruleFixer.replaceText(node.callee.property, camelCase(newAssertionName)) ); } if (status === 'missing') { const endParenToken = sourceCode.getLastToken(node); fixes.unshift( - ruleFixer.insertTextBefore(endParenToken, stringifiedSubject), + ruleFixer.insertTextBefore(endParenToken, stringifiedSubject) ); } else if (status === 'mismatch') { fixes.unshift(ruleFixer.replaceText(node.arguments[0], stringifiedSubject)); @@ -223,7 +223,7 @@ async function applyFixes(fixes) { ['expect', 'assess'].includes(node.callee.object.callee.name) && node.callee.property.type === 'Identifier' && ['toEqualSnapshot', 'toInspectAsSnapshot'].includes( - node.callee.property.name, + node.callee.property.name ) && node.callee.property.loc.start.line === lineNumber && node.callee.property.loc.start.column + 1 === columnNumber @@ -235,7 +235,7 @@ async function applyFixes(fixes) { if (appliedFixes && appliedFixes.length > 0) { (fixesByFileName[fileName] = fixesByFileName[fileName] || []).push( - ...appliedFixes, + ...appliedFixes ); } }, @@ -246,7 +246,7 @@ async function applyFixes(fixes) { for (const fileName of Object.keys(fixesByFileName)) { const fixResult = SourceCodeFixer.applyFixes( getSourceCodeMemoized(fileName).text, - fixesByFileName[fileName].map((fix) => ({ fix })), + fixesByFileName[fileName].map((fix) => ({ fix })) ); if (fixResult.fixed) { diff --git a/lib/createInspector.js b/lib/createInspector.js index 38756a6..6e5e6cb 100644 --- a/lib/createInspector.js +++ b/lib/createInspector.js @@ -12,7 +12,7 @@ const createInspector = (expect) => { if (value.length > 32) { return output.code( `Buffer.from('${value.toString('base64')}', 'base64')`, - 'javascript', + 'javascript' ); } else { return this.baseType.inspect.call( @@ -20,7 +20,7 @@ const createInspector = (expect) => { value, depth, output, - inspect, + inspect ); } }, diff --git a/lib/getSourceCode.js b/lib/getSourceCode.js index 1fe3fd7..e96ef76 100644 --- a/lib/getSourceCode.js +++ b/lib/getSourceCode.js @@ -99,7 +99,7 @@ function getSourceCode(fileName) { return `//${captured}`; }), { parser: 'espree' }, - fileName, + fileName ); let ast; diff --git a/lib/isSimpleObjectTree.js b/lib/isSimpleObjectTree.js index f29edb7..9687b32 100644 --- a/lib/isSimpleObjectTree.js +++ b/lib/isSimpleObjectTree.js @@ -17,7 +17,7 @@ function isSimpleObjectTree(obj) { const result = obj.constructor === Object && Object.getOwnPropertyNames(obj).every((name) => - isSimple(obj[name]), + isSimple(obj[name]) ) && Object.getOwnPropertySymbols(obj).length === 0; seen.delete(obj); diff --git a/lib/run.js b/lib/run.js index 43af90f..8543531 100644 --- a/lib/run.js +++ b/lib/run.js @@ -37,7 +37,7 @@ module.exports = function run(command, args, options) { err, bufferedLinesByStreamName.stdout, bufferedLinesByStreamName.stderr, - ]), + ]) ) .on('exit', (exitCode) => { resolve([ diff --git a/lib/unexpected-snapshot-check.js b/lib/unexpected-snapshot-check.js index 21754e1..de7fd29 100644 --- a/lib/unexpected-snapshot-check.js +++ b/lib/unexpected-snapshot-check.js @@ -37,7 +37,7 @@ module.exports = { withSnapshotMessageAppended(expect, () => { expect(subject, 'to equal', value); }); - }, + } ); expect.addAssertion(' to inspect as snapshot', (expect) => { @@ -52,7 +52,7 @@ module.exports = { withSnapshotMessageAppended(expect, () => { expect(inspect(subject), 'to equal', value); }); - }, + } ); }, }; diff --git a/lib/unexpected-snapshot-update.js b/lib/unexpected-snapshot-update.js index 6f8d964..6475f3a 100644 --- a/lib/unexpected-snapshot-update.js +++ b/lib/unexpected-snapshot-update.js @@ -29,7 +29,7 @@ function ensureAfterHookIsRegistered() { numFixedExpects === 1 ? '' : 's' } in ${fileNames.length} source file${ fileNames.length === 1 ? '' : 's' - }`, + }` ); const Promise = require('bluebird'); @@ -40,13 +40,13 @@ function ensureAfterHookIsRegistered() { fileNames, (fileName) => fs.writeFileAsync(fileName, fixedSourceTextByFileName[fileName]), - { concurrency: 5 }, + { concurrency: 5 } ); console.log( `unexpected-snapshot: Wrote ${results.length} file${ results.length === 1 ? '' : 's' - }`, + }` ); } // Replay the calls that were made while were writing files: @@ -97,10 +97,10 @@ module.exports = { ensureAfterHookIsRegistered(); } else { throw new Error( - 'unexpected-snapshot: Could not figure out the location of the expect() call to patch up', + 'unexpected-snapshot: Could not figure out the location of the expect() call to patch up' ); } - }, + } ); expect.addAssertion( @@ -130,9 +130,9 @@ module.exports = { } else { throw err; } - }, + } ); - }, + } ); expect.unindent = require('@gustavnikolaj/string-utils').deindent; diff --git a/test/browser/index.js b/test/browser/index.js index db35d74..927a919 100644 --- a/test/browser/index.js +++ b/test/browser/index.js @@ -20,7 +20,7 @@ describe('unexpected-snapshot', function () { '-abc\n' + '+def\n' + '\n' + - 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots', + 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots' ); }); }); @@ -34,7 +34,7 @@ describe('unexpected-snapshot', function () { expect( new Person('Eigil'), 'to inspect as snapshot', - "Person({ name: 'Eigil' })", + "Person({ name: 'Eigil' })" ); }); @@ -44,13 +44,13 @@ describe('unexpected-snapshot', function () { expect( new Person('Eigil'), 'to equal snapshot', - "Person({ name: 'Preben' })", + "Person({ name: 'Preben' })" ); }, 'to throw', "expected Person({ name: 'Eigil' }) to equal snapshot 'Person({ name: \\'Preben\\' })'\n" + '\n' + - 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots', + 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots' ); }); }); diff --git a/test/indentString.js b/test/indentString.js index 5ed3fdb..f646043 100644 --- a/test/indentString.js +++ b/test/indentString.js @@ -24,7 +24,7 @@ describe('stringSnapshot', () => { expect( indentString('foo\n \nbar', 2), 'to equal', - '\n foo\n \n bar\n', + '\n foo\n \n bar\n' ); }); diff --git a/test/unexpected-snapshot.js b/test/unexpected-snapshot.js index e950bf7..0a262ab 100644 --- a/test/unexpected-snapshot.js +++ b/test/unexpected-snapshot.js @@ -9,25 +9,25 @@ describe('with snapshot updating on', function () { const espree = require('espree'); const preambleByType = { unexpected: `var expect = require('${require.resolve( - 'unexpected', + 'unexpected' )}').clone().use(require('${pathModule.resolve( __dirname, '..', 'lib', - 'unexpected-snapshot.js', + 'unexpected-snapshot.js' )}'));\n// END PREAMBLE\n`, unassessed: `var assess = require('${require.resolve( - 'unassessed', + 'unassessed' )}').withUnexpectedPlugins(require('${pathModule.resolve( __dirname, '..', 'lib', - 'unexpected-snapshot.js', + 'unexpected-snapshot.js' )}'));\n// END PREAMBLE\n`, }; const tmpDir = pathModule.resolve( require('os').tmpdir(), - `unexpected-snapshot-test-${Date.now()}-${process.pid}`, + `unexpected-snapshot-test-${Date.now()}-${process.pid}` ); before(async () => { @@ -61,7 +61,7 @@ describe('with snapshot updating on', function () { async function writeTestToTemporaryFile(code, type = 'unexpected') { const tmpFileName = pathModule.resolve( tmpDir, - `unexpected-snapshot-${Math.round(10000000 * Math.random())}.js`, + `unexpected-snapshot-${Math.round(10000000 * Math.random())}.js` ); await fs.writeFileAsync(tmpFileName, preambleByType[type] + code, 'utf-8'); return tmpFileName; @@ -76,14 +76,14 @@ describe('with snapshot updating on', function () { '..', 'node_modules', '.bin', - 'mocha', + 'mocha' )} ${fileNames.join(' ')}`; const [err, stdout, stderr] = await expect.promise.fromNode((cb) => childProcess.exec( testCommand, { env: { ...process.env, ...env } }, - cb.bind(null, null), - ), + cb.bind(null, null) + ) ); return [err, stdout, stderr]; } @@ -104,10 +104,10 @@ describe('with snapshot updating on', function () { expect.flags['with unassessed'] ? 'unassessed' : 'unexpected' ]; const output = (await fs.readFileAsync(tmpFileName, 'utf-8')).substr( - preamble.length, + preamble.length ); expect(beautifyJavaScript(output), 'to equal', subject); - }, + } ); expect.addAssertion( @@ -145,7 +145,7 @@ describe('with snapshot updating on', function () { let output = (await fs.readFileAsync(tmpFileName, 'utf-8')).replace( /^[\s\S]*?\/\/ END PREAMBLE\n/, - '', + '' ); if (!expect.flags.exactly) { output = beautifyJavaScript(output); @@ -166,7 +166,7 @@ describe('with snapshot updating on', function () { } await fs.unlinkAsync(tmpFileName); } - }, + } ); describe('inspect as snapshot', () => { @@ -183,10 +183,10 @@ describe('with snapshot updating on', function () { expect( ['a', 'b', 'c'], 'to inspect as snapshot', - "[ 'a', 'b', 'c' ]", + "[ 'a', 'b', 'c' ]" ); }); - }, + } ); }); @@ -197,7 +197,7 @@ describe('with snapshot updating on', function () { expect( ['a', 'b', 'c'], 'to inspect as snapshot', - "['a', 'b', 'c']", + "['a', 'b', 'c']" ); }); }, @@ -207,10 +207,10 @@ describe('with snapshot updating on', function () { expect( ['a', 'b', 'c'], 'to inspect as snapshot', - "[ 'a', 'b', 'c' ]", + "[ 'a', 'b', 'c' ]" ); }); - }, + } ); }); @@ -222,7 +222,7 @@ describe('with snapshot updating on', function () { ['c', 'a', 'b'], 'when sorted', 'to inspect as snapshot', - "['a', 'b', 'c']", + "['a', 'b', 'c']" ); }); }, @@ -233,10 +233,10 @@ describe('with snapshot updating on', function () { ['c', 'a', 'b'], 'when sorted', 'to inspect as snapshot', - "[ 'a', 'b', 'c' ]", + "[ 'a', 'b', 'c' ]" ); }); - }, + } ); }); @@ -249,7 +249,7 @@ describe('with snapshot updating on', function () { down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } }, }, 'to inspect as snapshot', - '{ down: { the: { rabbit: { hole: {} } } } }', + '{ down: { the: { rabbit: { hole: {} } } } }' ); }); }, @@ -261,10 +261,10 @@ describe('with snapshot updating on', function () { down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } }, }, 'to inspect as snapshot', - "{ down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } } }", + "{ down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } } }" ); }); - }, + } ); }); @@ -282,7 +282,7 @@ describe('with snapshot updating on', function () { it('should foo', function () { assess(['a', 'b', 'c']).toInspectAsSnapshot("[ 'a', 'b', 'c' ]"); }); - }, + } ); }); @@ -298,7 +298,7 @@ describe('with snapshot updating on', function () { it('should foo', function () { assess(['a', 'b', 'c']).toInspectAsSnapshot("[ 'a', 'b', 'c' ]"); }); - }, + } ); }); }); @@ -317,7 +317,7 @@ it('should foo', function() { it('should foo', function() { expect('foo', 'to equal snapshot', 'foo'); }); - `, + ` ); }); @@ -336,7 +336,7 @@ it('should foo', function() { \`); }); - `, + ` ); }); @@ -355,7 +355,7 @@ it('should foo', function() { \`); }); - `, + ` ); }); @@ -371,7 +371,7 @@ it('should foo', function() { it('should foo', function() { expect('\\n foo', 'to equal snapshot', '\\n foo'); }); - `, + ` ); }); @@ -387,7 +387,7 @@ it('should foo', function() { it('should foo', function() { expect(' foo\\n', 'to equal snapshot', ' foo\\n'); }); - `, + ` ); }); @@ -411,7 +411,7 @@ it('should foo', function() { 'foo' ); }); - `, + ` ); }); @@ -438,7 +438,7 @@ it('should foo', function() { \` ); }); - `, + ` ); }); @@ -458,7 +458,7 @@ it('should foo', function() { bar \`); }); - `, + ` ); }); @@ -481,7 +481,7 @@ if (true) { \`); }); } - `, + ` ); }); @@ -504,7 +504,7 @@ if (true) { \`); }); } - `, + ` ); }); }); @@ -523,7 +523,7 @@ it('should foo', function() { it('should foo', function() { expect('foo', 'to equal snapshot', 'foo'); }); - `, + ` ); }); @@ -539,7 +539,7 @@ it('should foo', function() { it('should foo', function() { expect('foo', 'to equal snapshot', 'foo'); }); - `, + ` ); }); @@ -559,7 +559,7 @@ it('should foo', function() { bar \`); }); - `, + ` ); }); @@ -581,7 +581,7 @@ it('should foo', function() { bar \`); }); - `, + ` ); }); @@ -597,7 +597,7 @@ it('should foo', function() { it('should foo', function () { expect({ foo: 'bar' }, 'to equal snapshot', { foo: 'bar' }); }); - }, + } ); }); @@ -613,7 +613,7 @@ it('should foo', function() { it('should foo', function () { expect([123, 'abc'], 'to equal snapshot', [123, 'abc']); }); - }, + } ); }); @@ -635,10 +635,10 @@ it('should foo', function() { expect( foo, 'to inspect as snapshot', - '{ bar: 123, quux: [Circular] }', + '{ bar: 123, quux: [Circular] }' ); }); - }, + } ); }); @@ -647,7 +647,7 @@ it('should foo', function() { return expect( () => { expect.addAssertion(' noop ', (expect) => - expect.shift(), + expect.shift() ); it('should foo', function () { @@ -659,7 +659,7 @@ it('should foo', function() { 'to come out as', function () { expect.addAssertion(' noop ', (expect) => - expect.shift(), + expect.shift() ); it('should foo', function () { @@ -668,10 +668,10 @@ it('should foo', function() { expect( foo, 'noop to inspect as snapshot', - '{ bar: 123, quux: [Circular] }', + '{ bar: 123, quux: [Circular] }' ); }); - }, + } ); }); @@ -680,7 +680,7 @@ it('should foo', function() { return expect( () => { expect.addAssertion(' noop ', (expect) => - expect.shift(), + expect.shift() ); it('should foo', function () { @@ -692,7 +692,7 @@ it('should foo', function() { 'to come out as', function () { expect.addAssertion(' noop ', (expect) => - expect.shift(), + expect.shift() ); it('should foo', function () { @@ -701,10 +701,10 @@ it('should foo', function() { expect( foo, 'noop to inspect as snapshot', - '{ bar: 123, quux: [Circular] }', + '{ bar: 123, quux: [Circular] }' ); }); - }, + } ); }); }); @@ -730,10 +730,10 @@ it('should foo', function() { expect( new Person('Eigil'), 'to inspect as snapshot', - "Person({ name: 'Eigil' })", + "Person({ name: 'Eigil' })" ); }); - }, + } ); }); @@ -752,7 +752,7 @@ it('should foo', function() { number: 123.456, regexp: /abc(?:)/gim, }, - 'to equal snapshot', + 'to equal snapshot' ); }); }, @@ -780,10 +780,10 @@ it('should foo', function() { Infinity: Infinity, number: 123.456, regexp: /abc(?:)/gim, - }, + } ); }); - }, + } ); }); @@ -806,7 +806,7 @@ it('should foo', function() { 'c', ]); }); - }, + } ); }); @@ -819,7 +819,7 @@ it('should foo', function() { down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } }, }, 'to equal snapshot', - { down: { the: { rabbit: { hole: {} } } } }, + { down: { the: { rabbit: { hole: {} } } } } ); }); }, @@ -833,10 +833,10 @@ it('should foo', function() { 'to equal snapshot', { down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } }, - }, + } ); }); - }, + } ); }); @@ -857,7 +857,7 @@ it('should foo', function() { bar: expect.it('to equal snapshot', 'foo'), }); }); - }, + } ); }); @@ -879,7 +879,7 @@ it('should foo', function() { }), }); }); - }, + } ); }); }); @@ -900,12 +900,12 @@ it('should foo', function() { UNEXPECTED_SNAPSHOT: 'on', }); const fixedSrcs = await Promise.all( - tmpFileNames.map((fileName) => fs.readFileAsync(fileName, 'utf-8')), + tmpFileNames.map((fileName) => fs.readFileAsync(fileName, 'utf-8')) ); expect( fixedSrcs, 'to have items satisfying to contain', - `expect("foo", "to equal snapshot", "foo");`, + `expect("foo", "to equal snapshot", "foo");` ); }); }); @@ -927,7 +927,7 @@ it('should foo', function() { 'to equal snapshot', 'foo' ); }); -`, +` ); }); @@ -946,7 +946,7 @@ it('should foo', function() { it('should foo', function () { expect('foo', 'to equal snapshot', 'foo'); }); -`, +` ); }); }); @@ -966,7 +966,7 @@ it('should foo', function () { it('should foo', function () { assess('foo').toEqualSnapshot('foo'); }); - }, + } ); }); @@ -986,7 +986,7 @@ it('should foo', function () { foo.quux = foo; assess(foo).toInspectAsSnapshot('{ bar: 123, quux: [Circular] }'); }); - }, + } ); }); @@ -1006,7 +1006,7 @@ it('should foo', function() { baz \`); }); -`, +` ); }); }); @@ -1024,7 +1024,7 @@ it('should foo', function() { it('should foo', function () { assess('foo').toEqualSnapshot('foo'); }); - }, + } ); }); }); @@ -1043,7 +1043,7 @@ describe('with snapshot updating off', function () { 'to throw', 'expected 42 to equal snapshot\n' + '\n' + - 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots', + 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots' ); }); @@ -1061,7 +1061,7 @@ describe('with snapshot updating off', function () { 'to throw', 'expected 42 to equal snapshot 666\n' + '\n' + - 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots', + 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots' ); }); @@ -1070,7 +1070,7 @@ describe('with snapshot updating off', function () { expect( { down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } } }, 'to equal snapshot', - { down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } } }, + { down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } } } ); }, 'not to throw'); }); @@ -1085,7 +1085,7 @@ describe('with snapshot updating off', function () { 'to throw', 'expected 42 to inspect as snapshot\n' + '\n' + - 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots', + 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots' ); }); @@ -1106,7 +1106,7 @@ describe('with snapshot updating off', function () { '-42\n' + '+666\n' + '\n' + - 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots', + 'Rerun the tests with UNEXPECTED_SNAPSHOT=yes in Node to update the snapshots' ); }); @@ -1115,7 +1115,7 @@ describe('with snapshot updating off', function () { expect( { down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } } }, 'to inspect as snapshot', - "{ down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } } }", + "{ down: { the: { rabbit: { hole: { you: { find: 'Alice' } } } } } }" ); }, 'not to throw'); });