11import { types } from 'node:util' ;
22
3- import { $type } from './ symbols' ;
3+ import { $type } from 'universe: symbols.ts ' ;
44
55import type {
66 MaybePluginTesterTestConfig ,
77 PluginTesterTestConfig ,
88 PluginTesterTestFixtureConfig ,
99 Range
10- } from './index ' ;
10+ } from 'universe ' ;
1111
1212const { isNativeError } = types ;
1313
@@ -40,32 +40,33 @@ export const ErrorMessage = {
4040 BadConfigInvalidTestsObjectProperty : ( title : string ) =>
4141 `failed to validate configuration: \`tests\` object property "${ title } " must have a value of type string, TestObject, or nullish` ,
4242 BadConfigInvalidEndOfLine : ( endOfLine : unknown ) =>
43- `failed to validate configuration: invalid \`endOfLine\` option "${ endOfLine } "` ,
43+ `failed to validate configuration: invalid \`endOfLine\` option "${ String ( endOfLine ) } "` ,
4444 BadEnvironmentVariableRange : ( name : string , rangeStr : string , range ?: Range ) =>
4545 `invalid environment variable "${ name } ": invalid range ${ rangeStr } ` +
4646 ( range ? `: ${ range . start } is greater than ${ range . end } ` : '' ) ,
4747 SetupFunctionFailed : ( error : unknown ) =>
48- `setup function failed: ${ isNativeError ( error ) ? error . message : error } ` ,
48+ `setup function failed: ${ String ( isNativeError ( error ) ? error . message : error ) } ` ,
4949 TeardownFunctionFailed : ( functionError : unknown , frameworkError ?: unknown ) => {
5050 const frameworkErrorMessage = frameworkError
5151 ? `\n\nAdditionally, the testing framework reported the following error: ${
52- isNativeError ( frameworkError ) ? frameworkError . message : frameworkError
52+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
53+ String ( isNativeError ( frameworkError ) ? frameworkError . message : frameworkError )
5354 } `
5455 : '' ;
55- return `teardown function failed: ${
56+ return `teardown function failed: ${ String (
5657 isNativeError ( functionError ) ? functionError . message : functionError
57- } ${ frameworkErrorMessage } `;
58+ ) } ${ frameworkErrorMessage } `;
5859 } ,
5960 ExpectedBabelToThrow : ( ) => 'expected babel to throw an error, but it did not' ,
60- // eslint-disable-next-line @typescript-eslint/ban-types
61+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
6162 ExpectedErrorToBeInstanceOf : ( expectedError : Function | { name ?: string } ) =>
6263 `expected error to be an instance of ${ expectedError . name || 'the expected error' } ` ,
6364 ExpectedThrowsFunctionToReturnTrue : ( ) =>
6465 'expected `throws`/`error` function to return true' ,
6566 ExpectedErrorToIncludeString : ( resultString : string , expectedError : string ) =>
6667 `expected "${ resultString } " to include "${ expectedError } "` ,
6768 ExpectedErrorToMatchRegExp : ( resultString : string , expectedError : RegExp ) =>
68- `expected "${ resultString } " to match ${ expectedError } ` ,
69+ `expected "${ resultString } " to match ${ String ( expectedError ) } ` ,
6970 BabelOutputTypeIsNotString : ( rawBabelOutput : unknown ) =>
7071 `unexpected babel output of type "${ typeof rawBabelOutput } " (expected 'code' property to be of type "string")` ,
7172 BabelOutputUnexpectedlyEmpty : ( ) =>
@@ -79,11 +80,11 @@ export const ErrorMessage = {
7980 }
8081 | Pick < PluginTesterTestFixtureConfig , typeof $type | 'fixtureOutputBasename' >
8182 ) => {
82- return `actual output does not match ${
83+ return `actual output does not match ${ String (
8384 testConfig [ $type ] === 'fixture-object'
8485 ? testConfig . fixtureOutputBasename
8586 : 'expected output'
86- } `;
87+ ) } `;
8788 } ,
8889 ExpectedOutputNotToChange : ( ) => 'expected output not to change, but it did' ,
8990 ValidationFailed : ( title : string , message : string ) =>
@@ -136,7 +137,7 @@ export const ErrorMessage = {
136137 InvalidThrowsType : ( ) =>
137138 '`throws`/`error` must be a function, string, boolean, RegExp, or Error subtype' ,
138139 GenericErrorWithPath : ( error : unknown , path : string | undefined ) => {
139- const message = ` ${ isNativeError ( error ) ? error . message : error } ` ;
140+ const message = String ( isNativeError ( error ) ? error . message : error ) ;
140141 // ? Some realms/runtimes don't include the failing path, so we make sure
141142 return ! path || message . includes ( path ) ? message : `${ path } : ${ message } ` ;
142143 } ,
@@ -148,5 +149,5 @@ export const ErrorMessage = {
148149 basename : unknown ,
149150 basenameName : string
150151 ) =>
151- `unable to derive an absolute path from the provided ${ filepathName } and ${ basenameName } :\n\n${ filepathName } : ${ filepath } \n${ basenameName } : ${ basename } `
152+ `unable to derive an absolute path from the provided ${ filepathName } and ${ basenameName } :\n\n${ filepathName } : ${ String ( filepath ) } \n${ basenameName } : ${ String ( basename ) } `
152153} ;
0 commit comments