snapshotNamed -> namedSnapshot
MODIFY
packages/@romejs-runtime/rome/test.ts
packages/@romejs-runtime/rome/test.ts
@@ -86,7 +86,7 @@ export interface TestHelper {
opts?: TestSnapshotOptions,
): Promise<string>;
inlineSnapshot(received: unknown, expected?: string): void;
- snapshotNamed(
+ namedSnapshot(
name: string,
expected: unknown,
message?: string,

MODIFY
packages/@romejs/cli-flags/Parser.test.ts
packages/@romejs/cli-flags/Parser.test.ts
@@ -38,7 +38,7 @@ async function testParser<T>(
const {diagnostics} = await catchDiagnostics(async () => {
const flags = await parser.init();
- await t.snapshotNamed('flags', flags);
+ await t.namedSnapshot('flags', flags);
if (callback !== undefined) {
callback(parser, flags);
}
@@ -54,11 +54,11 @@ async function testParser<T>(
});
}
- await t.snapshotNamed('output', stream.read());
+ await t.namedSnapshot('output', stream.read());
const helpStream = reporter.attachCaptureStream();
await parser.showHelp();
- await t.snapshotNamed('help', helpStream.read());
+ await t.namedSnapshot('help', helpStream.read());
}
test(

MODIFY
packages/@romejs/core/master/fs/runtime-modules.ts
packages/@romejs/core/master/fs/runtime-modules.ts
@@ -22,7 +22,7 @@ modules.set(
],
[
'test.ts',
- "/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {JSONPropertyValue} from './types';\n\nexport type AsyncFunc = () => undefined | Promise<void>;\n\nexport type SyncThrower = () => void;\n\nexport type ExpectedError = undefined | string | RegExp | Function;\n\nexport type TestSnapshotOptions = {\n filename?: string;\n language?: string;\n};\n\n// These diagnostics are subsets of the official diagnostics\n// We can potentially normalize these and ensure backwards compatibility with the official diagnostics\n\nexport type TestDiagnosticLogCategory = 'none' | 'info' | 'warn' | 'error';\n\nexport type TestDiagnosticAdviceInspect = {\n type: 'inspect';\n data: JSONPropertyValue;\n};\n\nexport type TestDiagnosticAdviceList = {\n type: 'list';\n list: Array<string>;\n};\n\nexport type TestDiagnosticAdviceCode = {\n type: 'code';\n code: string;\n};\n\nexport type TestDiagnosticAdviceLog = {\n type: 'log';\n category: TestDiagnosticLogCategory;\n text: string;\n};\n\nexport type TestDiagnosticAdviceItem =\n | TestDiagnosticAdviceInspect\n | TestDiagnosticAdviceCode\n | TestDiagnosticAdviceLog\n | TestDiagnosticAdviceList;\n\nexport interface TestHelper {\n addToAdvice(item: TestDiagnosticAdviceItem): void;\n clearAdvice(): void;\n onTeardown(callback: AsyncFunc): void;\n clearTimeout(): void;\n extendTimeout(time: number): void;\n setTimeout(time: number): void;\n checkTimeout(): void;\n truthy(value: unknown, message?: string): void;\n falsy(value: unknown, message?: string): void;\n true(value: unknown, message?: string): void;\n false(value: unknown, message?: string): void;\n is(received: unknown, expected: unknown, message?: string): void;\n not(received: unknown, expected: unknown, message?: string): void;\n looksLike(received: unknown, expected: unknown, message?: string): void;\n notLooksLike(received: unknown, expected: unknown, message?: string): void;\n throws(\n thrower: SyncThrower,\n expected?: ExpectedError,\n message?: string,\n ): void;\n throwsAsync(\n thrower: AsyncFunc,\n expected?: ExpectedError,\n message?: string,\n ): Promise<void>;\n notThrows(nonThrower: SyncThrower, message?: string): void;\n notThrowsAsync(nonThrower: AsyncFunc, message?: string): Promise<void>;\n regex(contents: string, regex: RegExp, message?: string): void;\n notRegex(contents: string, regex: RegExp, message?: string): void;\n snapshot(\n expected: unknown,\n message?: string,\n opts?: TestSnapshotOptions,\n ): Promise<string>;\n snapshotNamed(\n name: string,\n expected: unknown,\n message?: string,\n opts?: TestSnapshotOptions,\n ): Promise<string>;\n}\n\nexport type TestName = string | Array<string>;\n\ndeclare const __ROME__TEST_OPTIONS__: GlobalTestOptions;\n\nexport type GlobalTestOptions =\n | undefined\n | {\n dirname?: string;\n register?: (\n err: Error,\n opts: TestOptions,\n callback?: TestCallback,\n ) => void;\n };\n\ntype NamelessTestOptions = {\n timeout?: number;\n only?: boolean;\n};\n\nexport type TestCallback = (t: TestHelper) => void | undefined | Promise<void>;\n\nexport type TestOptions = NamelessTestOptions & {\n name: TestName;\n};\n\ntype TestArg = TestName | NamelessTestOptions | TestCallback | undefined;\n\nexport const testOptions: NonNullable<GlobalTestOptions> =\n __ROME__TEST_OPTIONS__ === undefined ? {} : __ROME__TEST_OPTIONS__;\n\nfunction registerTest(\n callsiteError: Error,\n opts: TestOptions,\n callback: undefined | TestCallback,\n) {\n const register = testOptions.register;\n\n if (typeof register !== 'function') {\n throw new Error('Test harness does not exist');\n }\n\n register(callsiteError, opts, callback);\n}\n\nfunction isOptionsObject(arg: TestArg): arg is NamelessTestOptions {\n return typeof arg === 'object' && arg != null && !Array.isArray(arg);\n}\n\nfunction splitArgs(\n args: TestRegisterFunctionArgs,\n): {\n options: TestOptions;\n callback: undefined | TestCallback;\n} {\n const name: TestName = args[0];\n if (typeof name !== 'string' && !Array.isArray(name)) {\n throw new Error('Expected test name to be a string or an array of strings');\n }\n args.shift();\n\n let foundOptions;\n let options: NamelessTestOptions = {};\n let callback;\n\n // Try callback which will always be at the end\n const callbackOrOpts = args.pop();\n if (typeof callbackOrOpts === 'function' || callbackOrOpts === undefined) {\n callback = callbackOrOpts;\n } else if (isOptionsObject(callbackOrOpts)) {\n options = callbackOrOpts;\n foundOptions = true;\n } else {\n throw new Error('Expected to find callback or options at the end');\n }\n\n // Try options which should be in the middle position\n if (!foundOptions && args.length > 0) {\n const maybeOptions = args.pop();\n if (isOptionsObject(maybeOptions)) {\n options = maybeOptions;\n } else {\n throw new Error('Expected to find test options');\n }\n }\n\n if (args.length > 0) {\n throw new Error('Expected to have exhausted test register arguments');\n }\n\n return {\n options: {\n ...options,\n name,\n },\n callback,\n };\n}\n\ntype TestRegisterFunctionArgs =\n | [TestName]\n | [TestName, TestCallback]\n | [TestName, NamelessTestOptions, TestCallback];\n\ntype TestRegisterFunction = (...args: TestRegisterFunctionArgs) => void;\n\nexport const test: {\n (\n ...args: TestRegisterFunctionArgs\n ): void;\n skip: TestRegisterFunction;\n only: TestRegisterFunction;\n} = function(...args: TestRegisterFunctionArgs) {\n const {options, callback} = splitArgs(args);\n registerTest(new Error(), options, callback);\n};\n\ntest.skip = function(...args: TestRegisterFunctionArgs) {\n const {options} = splitArgs(args);\n registerTest(new Error(), options, undefined);\n};\n\ntest.only = function(...args: TestRegisterFunctionArgs) {\n const {options, callback} = splitArgs(args);\n registerTest(\n new Error(),\n {\n ...options,\n only: true,\n },\n callback,\n );\n};\n",
+ "/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {JSONPropertyValue} from './types';\n\nexport type AsyncFunc = () => undefined | Promise<void>;\n\nexport type SyncThrower = () => void;\n\nexport type ExpectedError = undefined | string | RegExp | Function;\n\nexport type TestSnapshotOptions = {\n filename?: string;\n language?: string;\n};\n\n// These diagnostics are subsets of the official diagnostics\n// We can potentially normalize these and ensure backwards compatibility with the official diagnostics\n\nexport type TestDiagnosticLogCategory = 'none' | 'info' | 'warn' | 'error';\n\nexport type TestDiagnosticAdviceInspect = {\n type: 'inspect';\n data: JSONPropertyValue;\n};\n\nexport type TestDiagnosticAdviceList = {\n type: 'list';\n list: Array<string>;\n};\n\nexport type TestDiagnosticAdviceCode = {\n type: 'code';\n code: string;\n};\n\nexport type TestDiagnosticAdviceLog = {\n type: 'log';\n category: TestDiagnosticLogCategory;\n text: string;\n};\n\nexport type TestDiagnosticAdviceItem =\n | TestDiagnosticAdviceInspect\n | TestDiagnosticAdviceCode\n | TestDiagnosticAdviceLog\n | TestDiagnosticAdviceList;\n\nexport interface TestHelper {\n addToAdvice(item: TestDiagnosticAdviceItem): void;\n clearAdvice(): void;\n onTeardown(callback: AsyncFunc): void;\n clearTimeout(): void;\n extendTimeout(time: number): void;\n setTimeout(time: number): void;\n checkTimeout(): void;\n truthy(value: unknown, message?: string): void;\n falsy(value: unknown, message?: string): void;\n true(value: unknown, message?: string): void;\n false(value: unknown, message?: string): void;\n is(received: unknown, expected: unknown, message?: string): void;\n not(received: unknown, expected: unknown, message?: string): void;\n looksLike(received: unknown, expected: unknown, message?: string): void;\n notLooksLike(received: unknown, expected: unknown, message?: string): void;\n throws(\n thrower: SyncThrower,\n expected?: ExpectedError,\n message?: string,\n ): void;\n throwsAsync(\n thrower: AsyncFunc,\n expected?: ExpectedError,\n message?: string,\n ): Promise<void>;\n notThrows(nonThrower: SyncThrower, message?: string): void;\n notThrowsAsync(nonThrower: AsyncFunc, message?: string): Promise<void>;\n regex(contents: string, regex: RegExp, message?: string): void;\n notRegex(contents: string, regex: RegExp, message?: string): void;\n snapshot(\n expected: unknown,\n message?: string,\n opts?: TestSnapshotOptions,\n ): Promise<string>;\n inlineSnapshot(received: unknown, expected?: string): void;\n namedSnapshot(\n name: string,\n expected: unknown,\n message?: string,\n opts?: TestSnapshotOptions,\n ): Promise<string>;\n}\n\nexport type TestName = string | Array<string>;\n\ndeclare const __ROME__TEST_OPTIONS__: GlobalTestOptions;\n\nexport type GlobalTestOptions =\n | undefined\n | {\n dirname?: string;\n register?: (\n err: Error,\n opts: TestOptions,\n callback?: TestCallback,\n ) => void;\n };\n\ntype NamelessTestOptions = {\n timeout?: number;\n only?: boolean;\n};\n\nexport type TestCallback = (t: TestHelper) => void | undefined | Promise<void>;\n\nexport type TestOptions = NamelessTestOptions & {\n name: TestName;\n};\n\ntype TestArg = TestName | NamelessTestOptions | TestCallback | undefined;\n\nexport const testOptions: NonNullable<GlobalTestOptions> =\n __ROME__TEST_OPTIONS__ === undefined ? {} : __ROME__TEST_OPTIONS__;\n\nfunction registerTest(\n callsiteError: Error,\n opts: TestOptions,\n callback: undefined | TestCallback,\n) {\n const register = testOptions.register;\n\n if (typeof register !== 'function') {\n throw new Error('Test harness does not exist');\n }\n\n register(callsiteError, opts, callback);\n}\n\nfunction isOptionsObject(arg: TestArg): arg is NamelessTestOptions {\n return typeof arg === 'object' && arg != null && !Array.isArray(arg);\n}\n\nfunction splitArgs(\n args: TestRegisterFunctionArgs,\n): {\n options: TestOptions;\n callback: undefined | TestCallback;\n} {\n const name: TestName = args[0];\n if (typeof name !== 'string' && !Array.isArray(name)) {\n throw new Error('Expected test name to be a string or an array of strings');\n }\n args.shift();\n\n let foundOptions;\n let options: NamelessTestOptions = {};\n let callback;\n\n // Try callback which will always be at the end\n const callbackOrOpts = args.pop();\n if (typeof callbackOrOpts === 'function' || callbackOrOpts === undefined) {\n callback = callbackOrOpts;\n } else if (isOptionsObject(callbackOrOpts)) {\n options = callbackOrOpts;\n foundOptions = true;\n } else {\n throw new Error('Expected to find callback or options at the end');\n }\n\n // Try options which should be in the middle position\n if (!foundOptions && args.length > 0) {\n const maybeOptions = args.pop();\n if (isOptionsObject(maybeOptions)) {\n options = maybeOptions;\n } else {\n throw new Error('Expected to find test options');\n }\n }\n\n if (args.length > 0) {\n throw new Error('Expected to have exhausted test register arguments');\n }\n\n return {\n options: {\n ...options,\n name,\n },\n callback,\n };\n}\n\ntype TestRegisterFunctionArgs =\n | [TestName]\n | [TestName, TestCallback]\n | [TestName, NamelessTestOptions, TestCallback];\n\ntype TestRegisterFunction = (...args: TestRegisterFunctionArgs) => void;\n\nexport const test: {\n (...args: TestRegisterFunctionArgs): void;\n skip: TestRegisterFunction;\n only: TestRegisterFunction;\n} = function (...args: TestRegisterFunctionArgs) {\n const {options, callback} = splitArgs(args);\n registerTest(new Error(), options, callback);\n};\n\ntest.skip = function (...args: TestRegisterFunctionArgs) {\n const {options} = splitArgs(args);\n registerTest(new Error(), options, undefined);\n};\n\ntest.only = function (...args: TestRegisterFunctionArgs) {\n const {options, callback} = splitArgs(args);\n registerTest(\n new Error(),\n {\n ...options,\n only: true,\n },\n callback,\n );\n};\n",
],
[
'types.ts',

MODIFY
packages/@romejs/core/test-worker/TestAPI.ts
packages/@romejs/core/test-worker/TestAPI.ts
@@ -623,7 +623,7 @@ export default class TestAPI implements TestHelper {
});
}
- snapshotNamed(
+ namedSnapshot(
entryName: string,
expected: unknown,
message?: string,

MODIFY
packages/@romejs/js-compiler/lint/testHelpers.ts
packages/@romejs/js-compiler/lint/testHelpers.ts
@@ -98,7 +98,7 @@ export async function testLint(
}),
);
- await t.snapshotNamed(`${snapshotName}: formatted`, res.src);
+ await t.namedSnapshot(`${snapshotName}: formatted`, res.src);
t.clearAdvice();
}

MODIFY
packages/@romejs/js-formatter/index.test.ts
packages/@romejs/js-formatter/index.test.ts
@@ -73,7 +73,7 @@ const promise = createFixtureTests(async (fixture, t) => {
inputFile.absolute.getExtensionlessBasename(),
).join();
- await t.snapshotNamed(
+ await t.namedSnapshot(
'Input',
inputContent,
undefined,
@@ -83,7 +83,7 @@ const promise = createFixtureTests(async (fixture, t) => {
},
);
- await t.snapshotNamed(
+ await t.namedSnapshot(
'Output',
printed.code,
undefined,

snapshotNamed -> namedSnapshot