Update tests to use await in front of t.snapshot
MODIFY
packages/@romejs/cli-flags/Parser.test.ts
packages/@romejs/cli-flags/Parser.test.ts
@@ -31,7 +31,7 @@ async function testParser<T>(t: TestHelper, {
const {diagnostics} = await catchDiagnostics(async () => {
const flags = await parser.init();
- t.snapshotNamed('flags', flags);
+ await t.snapshotNamed('flags', flags);
if (callback !== undefined) {
callback(parser, flags);
}
@@ -47,11 +47,11 @@ async function testParser<T>(t: TestHelper, {
});
}
- t.snapshotNamed('output', stream.read());
+ await t.snapshotNamed('output', stream.read());
const helpStream = reporter.attachCaptureStream();
await parser.showHelp();
- t.snapshotNamed('help', helpStream.read());
+ await t.snapshotNamed('help', helpStream.read());
}
test('does not allow shorthands', async (t) => {

MODIFY
packages/@romejs/codec-js-manifest/dependencies.test.ts
packages/@romejs/codec-js-manifest/dependencies.test.ts
@@ -9,20 +9,20 @@ import {test} from 'rome';
import {parseDependencyPattern} from './dependencies';
import {consumeUnknown} from '@romejs/consume';
-test('can parse npm dependency patterns', (t) => {
- t.snapshot(parseDependencyPattern(
+test('can parse npm dependency patterns', async (t) => {
+ await t.snapshot(parseDependencyPattern(
consumeUnknown('npm:foo', 'parse/json'),
false,
));
- t.snapshot(parseDependencyPattern(
- consumeUnknown('npm:@foo/bar', 'parse/json'),
- false,
- ));
- t.snapshot(parseDependencyPattern(
- consumeUnknown('npm:foo@1.0.0', 'parse/json'),
- false,
- ));
- t.snapshot(parseDependencyPattern(consumeUnknown(
+ await t.snapshot(parseDependencyPattern(consumeUnknown(
+ 'npm:@foo/bar',
+ 'parse/json',
+ ), false));
+ await t.snapshot(parseDependencyPattern(consumeUnknown(
+ 'npm:foo@1.0.0',
+ 'parse/json',
+ ), false));
+ await t.snapshot(parseDependencyPattern(consumeUnknown(
'npm:@foo/bar@1.0.0',
'parse/json',
), false));

MODIFY
packages/@romejs/codec-semver/parse.test.ts
packages/@romejs/codec-semver/parse.test.ts
@@ -9,7 +9,7 @@ import '@romejs/string-markup';
import {parseSemverRange, parseSemverVersion} from '@romejs/codec-semver';
import {test} from 'rome';
-test('parse', (t) => {
+test('parse', async (t) => {
// versions in version mode
const versionTests = [
'1.2.3',
@@ -24,13 +24,13 @@ test('parse', (t) => {
'1.2.3-45pre.42yes+45build',
];
for (const str of versionTests) {
- t.snapshot(parseSemverVersion({input: str}));
+ await t.snapshot(parseSemverVersion({input: str}));
}
// loose mode
const looseRangeTests = ['* - 1.2.3', 'v1.2.3', '||', '', '1.2.3prerelease'];
for (const str of looseRangeTests) {
- t.snapshot(parseSemverRange({input: str, loose: true}));
+ await t.snapshot(parseSemverRange({input: str, loose: true}));
t.throws(() => {
parseSemverRange({input: str, loose: false});
@@ -90,7 +90,7 @@ test('parse', (t) => {
// run range tests
for (const str of rangeTests) {
- t.snapshot(parseSemverRange({input: str}));
+ await t.snapshot(parseSemverRange({input: str}));
}
// ensure ranges throw in version mode

MODIFY
packages/@romejs/js-ast-utils/getCompletionRecords.test.ts
packages/@romejs/js-ast-utils/getCompletionRecords.test.ts
@@ -17,25 +17,30 @@ function helper(input: string) {
}).body[0]).body);
}
-test('invalid', (t) => {
- t.snapshot(helper(`{}`));
- t.snapshot(helper(`'foobar';`));
- t.snapshot(helper(`if (bar) {'foobar';}`));
- t.snapshot(helper(`if (bar) {'foobar';} else {}`));
- t.snapshot(helper(`switch (foo) {}`));
- t.snapshot(helper(`switch (foo) {case 'bar': {}}`));
- t.snapshot(helper(`switch (foo) {default: {}}`));
+test('invalid', async (t) => {
+ await t.snapshot(helper(`{}`));
+ await t.snapshot(helper(`'foobar';`));
+ await t.snapshot(helper(`if (bar) {'foobar';}`));
+ await t.snapshot(helper(`if (bar) {'foobar';} else {}`));
+ await t.snapshot(helper(`switch (foo) {}`));
+ await t.snapshot(helper(`switch (foo) {case 'bar': {}}`));
+ await t.snapshot(helper(`switch (foo) {default: {}}`));
});
-test('completions', (t) => {
- t.snapshot(helper(`return false;`));
- t.snapshot(helper(`return; invalid;`));
- t.snapshot(helper(`if (bar) {return false;}`));
- t.snapshot(helper(`if (bar) {return false;} else {return true;}`));
- t.snapshot(helper(`switch (foo) {default: {return false;}}`));
- t.snapshot(helper(`switch (foo) {default: {return false;}}`));
+test('completions', async (t) => {
+ await t.snapshot(helper(`return false;`));
+ await t.snapshot(helper(`return; invalid;`));
+ await t.snapshot(helper(`if (bar) {return false;}`));
+ await t.snapshot(helper(`if (bar) {return false;} else {return true;}`));
+ await t.snapshot(helper(`switch (foo) {default: {return false;}}`));
+ await t.snapshot(helper(`switch (foo) {default: {return false;}}`));
});
-test('mix', (t) => {
- t.snapshot(helper(`switch (foo) {default: {if (true) {return false;}}}`));
-});
+test(
+ 'mix',
+ async (t) => {
+ await t.snapshot(helper(
+ `switch (foo) {default: {if (true) {return false;}}}`,
+ ));
+ },
+);

MODIFY
packages/@romejs/js-compiler/api/analyzeDependencies.test.ts
packages/@romejs/js-compiler/api/analyzeDependencies.test.ts
@@ -25,7 +25,7 @@ async function testAnalyzeDeps(input: string, sourceType: ConstSourceType) {
}
test("discovers require('module') call", async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
import * as foo from 'foo';
function yeah() {
@@ -35,13 +35,13 @@ test("discovers require('module') call", async (t) => {
});
test('ignores require(dynamic) call', async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
require(dynamic);
`, 'module'));
});
test('ignores require() call if shadowed', async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
{
function require() {}
require('yes');
@@ -55,7 +55,7 @@ test('ignores require() call if shadowed', async (t) => {
});
test("discovers async import('foo')", async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
import('./foo');
function yes() {
@@ -65,13 +65,13 @@ test("discovers async import('foo')", async (t) => {
});
test('discovers local export specifiers', async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
export {foo, bar, yes as no};
`, 'module'));
});
test('discovers export declarations', async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
export const yes = '';
export function foo() {}
export class Bar {}
@@ -79,73 +79,73 @@ test('discovers export declarations', async (t) => {
});
test('discovers export default', async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
export default 'yes';
`, 'module'));
});
test('discovers export from', async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
export {foo, bar, default as no, boo as noo} from 'foobar';
`, 'module'));
});
test('discovers export star', async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
export * from 'foobar';
`, 'module'));
});
test('discovers import star', async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
import * as bar from 'foobar';
`, 'module'));
});
test('discovers import specifiers', async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
import {bar, foo, default as lol, ya as to} from 'foobar';
`, 'module'));
});
test('discovers import default', async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
import bar from 'foobar';
`, 'module'));
});
test('discovers commonjs exports', async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
exports.yes = function() {};
`, 'script'));
});
test('discovers commonjs module.exports', async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
module.exports = function() {};
`, 'script'));
});
test('discovers top level await', async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
await foobar();
`, 'module'));
});
test('correctly identifies a file with es imports as es', async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
import 'bar';
`, 'module'));
});
test('correctly identifies a file with es exports as es', async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
export const foo = 'bar';
`, 'module'));
});
test('correctly identifies a file with cjs exports as cjs', async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
exports.foo = 'bar';
`, 'module'));
});
@@ -155,21 +155,21 @@ test(
async (
t,
) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
foo();
`, 'module'));
},
);
test('disallow mix of es and cjs exports', async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
export const foo = 'bar';
exports.bar = 'foo';
`, 'script'));
});
test('defines topLevelLocalBindings', async (t) => {
- t.snapshot(await testAnalyzeDeps(`
+ await t.snapshot(await testAnalyzeDeps(`
import {bar} from 'foo';
const foo = 'bar';
`, 'module'));

MODIFY
packages/@romejs/js-compiler/api/lint.test.ts
packages/@romejs/js-compiler/api/lint.test.ts
@@ -103,7 +103,7 @@ export async function testLint(t: TestHelper, input: string, {
}));
if (format) {
- t.snapshotNamed(`${snapshotName}: formatted`, res.src);
+ await t.snapshotNamed(`${snapshotName}: formatted`, res.src);
}
t.clearAdvice();

MODIFY
packages/@romejs/js-compiler/suppressions.test.ts
packages/@romejs/js-compiler/suppressions.test.ts
@@ -29,8 +29,8 @@ function generateComment(value: string, line: number): CommentBlock {
};
}
-test('single category', (t) => {
- t.snapshot(extractSuppressionsFromComments([
+test('single category', async (t) => {
+ await t.snapshot(extractSuppressionsFromComments([
generateComment('rome-suppress foo', 1),
generateComment('* rome-suppress foo', 2),
generateComment(' * rome-suppress foo', 3),
@@ -38,8 +38,8 @@ test('single category', (t) => {
]));
});
-test('multiple categories', (t) => {
- t.snapshot(extractSuppressionsFromComments([
+test('multiple categories', async (t) => {
+ await t.snapshot(extractSuppressionsFromComments([
generateComment('rome-suppress foo bar', 1),
generateComment('* rome-suppress foo bar', 2),
generateComment(' * rome-suppress foo bar', 3),
@@ -50,14 +50,14 @@ test('multiple categories', (t) => {
]));
});
-test('typos', (t) => {
- t.snapshot(extractSuppressionsFromComments([
+test('typos', async (t) => {
+ await t.snapshot(extractSuppressionsFromComments([
generateComment('rome-ignore foo bar', 1),
]));
});
-test('duplicates', (t) => {
- t.snapshot(extractSuppressionsFromComments([
+test('duplicates', async (t) => {
+ await t.snapshot(extractSuppressionsFromComments([
generateComment('rome-suppress foo foo', 1),
]));
});

MODIFY
packages/@romejs/js-parser/index.test.ts
packages/@romejs/js-parser/index.test.ts
@@ -9,10 +9,9 @@ import {parseJS} from '@romejs/js-parser';
import {createFixtureTests} from '@romejs/test-helpers';
import {ConstProgramSyntax} from '@romejs/js-ast';
import {removeCarriageReturn} from '@romejs/string-utils';
-import {createAbsoluteFilePath} from '@romejs/path';
const promise = createFixtureTests(
- (fixture, t) => {
+ async (fixture, t) => {
const {options, files} = fixture;
// Get the input JS
@@ -72,7 +71,7 @@ const promise = createFixtureTests(
const outputFile = inputFile.absolute.getParent().append(
`${inputFile.absolute.getExtensionlessBasename()}.test.md`,
).join();
- t.snapshot(ast, undefined, outputFile);
+ await t.snapshot(ast, undefined, outputFile);
},
);

MODIFY
packages/@romejs/path-match/parse.test.ts
packages/@romejs/path-match/parse.test.ts
@@ -13,39 +13,39 @@ function _parsePathPattern(input: string): PathPattern {
return parsePathPattern({input});
}
-test('pattern', (t) => {
+test('pattern', async (t) => {
// Negate and wildcard
- t.snapshot(_parsePathPattern('!foo'));
- t.snapshot(_parsePathPattern(''));
+ await t.snapshot(_parsePathPattern('!foo'));
+ await t.snapshot(_parsePathPattern(''));
// Trailing slash and wildcards
- t.snapshot(_parsePathPattern('/foo/bar'));
- t.snapshot(_parsePathPattern('*/foo/bar'));
- t.snapshot(_parsePathPattern('**/foo/bar'));
- t.snapshot(_parsePathPattern('**/*foo/bar'));
+ await t.snapshot(_parsePathPattern('/foo/bar'));
+ await t.snapshot(_parsePathPattern('*/foo/bar'));
+ await t.snapshot(_parsePathPattern('**/foo/bar'));
+ await t.snapshot(_parsePathPattern('**/*foo/bar'));
// Random
- t.snapshot(_parsePathPattern('foo'));
- t.snapshot(_parsePathPattern('foo/'));
- t.snapshot(_parsePathPattern('foo/bar'));
- t.snapshot(_parsePathPattern('foo//bar'));
- t.snapshot(_parsePathPattern('foo/*/bar'));
- t.snapshot(_parsePathPattern('foo/**/bar'));
- t.snapshot(_parsePathPattern('foo/*bar'));
- t.snapshot(_parsePathPattern('foo/bar*'));
- t.snapshot(_parsePathPattern('foo/*bar*'));
- t.snapshot(_parsePathPattern('foo/*bar*foob'));
+ await t.snapshot(_parsePathPattern('foo'));
+ await t.snapshot(_parsePathPattern('foo/'));
+ await t.snapshot(_parsePathPattern('foo/bar'));
+ await t.snapshot(_parsePathPattern('foo//bar'));
+ await t.snapshot(_parsePathPattern('foo/*/bar'));
+ await t.snapshot(_parsePathPattern('foo/**/bar'));
+ await t.snapshot(_parsePathPattern('foo/*bar'));
+ await t.snapshot(_parsePathPattern('foo/bar*'));
+ await t.snapshot(_parsePathPattern('foo/*bar*'));
+ await t.snapshot(_parsePathPattern('foo/*bar*foob'));
// Comments
- t.snapshot(_parsePathPattern('# foobar'));
- t.snapshot(_parsePathPattern('foo/bar # foobar'));
- t.snapshot(_parsePathPattern('foo/bar\\#foobar'));
- t.snapshot(_parsePathPattern('foo/\\#foobar'));
+ await t.snapshot(_parsePathPattern('# foobar'));
+ await t.snapshot(_parsePathPattern('foo/bar # foobar'));
+ await t.snapshot(_parsePathPattern('foo/bar\\#foobar'));
+ await t.snapshot(_parsePathPattern('foo/\\#foobar'));
// Windows separators
- t.snapshot(_parsePathPattern('\\\\foo\\\\bar'));
- t.snapshot(_parsePathPattern('*\\\\foo\\\\bar'));
- t.snapshot(_parsePathPattern('**\\\\foo\\\\bar'));
- t.snapshot(_parsePathPattern('**\\\\*foo\\\\bar'));
- t.snapshot(_parsePathPattern('hello\\\\world'));
+ await t.snapshot(_parsePathPattern('\\\\foo\\\\bar'));
+ await t.snapshot(_parsePathPattern('*\\\\foo\\\\bar'));
+ await t.snapshot(_parsePathPattern('**\\\\foo\\\\bar'));
+ await t.snapshot(_parsePathPattern('**\\\\*foo\\\\bar'));
+ await t.snapshot(_parsePathPattern('hello\\\\world'));
});

MODIFY
packages/@romejs/string-markup/parse.test.ts
packages/@romejs/string-markup/parse.test.ts
@@ -10,15 +10,17 @@ import {parseMarkup} from './parse';
test(
'should not parse string escapes',
- (t) => {
- t.snapshot(parseMarkup('<filelink target="C:\\Users\\sebmck\\file.ts" />'));
- t.snapshot(
+ async (t) => {
+ await t.snapshot(parseMarkup(
+ '<filelink target="C:\\Users\\sebmck\\file.ts" />',
+ ));
+ await t.snapshot(
parseMarkup(
'<info>[MemoryFileSystem] Adding new project folder C:\\Users\\sebmck\\rome</info>',
),
);
- t.snapshot(
+ await t.snapshot(
parseMarkup(
' \\<info>[MemoryFileSystem] Adding new project folder C:\\\\Users\\\\Sebastian\\\\rome\\\\\\</info>\n <error><emphasis>^</emphasis></error> ',
),

Update tests to use await in front of t.snapshot