Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix paths generated in defaultErrorMessages",
"packageName": "@fluentui/react-conformance",
"email": "olfedias@microsoft.com",
"dependentChangeType": "patch"
}
11 changes: 4 additions & 7 deletions packages/react-conformance/src/defaultErrorMessages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { EOL } from 'os';
import * as path from 'path';

import { errorMessageColors, formatArray, getErrorMessage, formatErrors } from './utils/errorMessages';
import { getPackagePath } from './defaultTests';

/* eslint-disable @typescript-eslint/naming-convention */

Expand Down Expand Up @@ -362,8 +363,7 @@ export const defaultErrorMessages = {
'exported-top-level': (testInfo: IsConformantOptions, error: Error) => {
const { displayName, componentPath } = testInfo;
const { testErrorPath, resolveInfo } = errorMessageColors;
const rootPath = componentPath.replace(/[\\/]src[\\/].*/, '');
const indexFile = path.join(rootPath, 'src', 'index');
const indexFile = path.join(getPackagePath(componentPath), 'src', 'index');

const exportInfo = testInfo.useDefaultExport
? `export { default as ${displayName} } from './${displayName};`
Expand Down Expand Up @@ -391,8 +391,7 @@ export const defaultErrorMessages = {
'has-top-level-file': (testInfo: IsConformantOptions, error: Error) => {
const { displayName, componentPath } = testInfo;
const { testErrorPath, resolveInfo } = errorMessageColors;
const rootPath = componentPath.replace(/[\\/]src[\\/].*/, '');
const topLevelFile = path.join(rootPath, 'src', displayName);
const topLevelFile = path.join(getPackagePath(componentPath), 'src', displayName);

// Message Description: Handles scenario where the displayName doesn't match the component's filename.
//
Expand Down Expand Up @@ -614,9 +613,7 @@ export const defaultErrorMessages = {
) => {
const { componentPath, displayName } = testInfo;
const { testErrorInfo, resolveInfo, testErrorPath } = errorMessageColors;

const rootPath = componentPath.replace(/[\\/]src[\\/].*/, '');
const indexFile = path.join(rootPath, 'src', 'index.ts');
const indexFile = path.join(getPackagePath(componentPath), 'src', 'index.ts');

const constantValue = `export const ${exportName} = "${componentClassName}";`;

Expand Down
2 changes: 1 addition & 1 deletion packages/react-conformance/src/defaultTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ export const defaultTests: TestObject = {
},
};

function getPackagePath(componentPath: string) {
export function getPackagePath(componentPath: string) {
// Use lastIndexOf in case anyone has all their repos under a folder called "src" (it happens)
const srcIndex = componentPath.replace(/\\/g, '/').lastIndexOf('/src/');
return componentPath.slice(0, srcIndex);
Expand Down