Skip to content

Commit

Permalink
Merge pull request #23305 from storybookjs/valentin/fix-windows-tests
Browse files Browse the repository at this point in the history
Unit Tests: Fix tests on Windows

(cherry picked from commit 7b79548)
  • Loading branch information
valentinpalkovic authored and github-actions[bot] committed Jul 4, 2023
1 parent 1d3f9eb commit 332fe2d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions code/lib/telemetry/src/get-framework-info.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { StorybookConfig } from '@storybook/types';
import path from 'path';
import { getFrameworkInfo } from './get-framework-info';
import { getActualPackageJson } from './package-json';

Expand All @@ -25,7 +26,7 @@ describe('getFrameworkInfo', () => {
});

it('should resolve the framework package json correctly and strip project paths in the metadata', async () => {
const packageName = '/path/to/project/@storybook/react';
const packageName = `${process.cwd()}/@storybook/react`.split('/').join(path.sep);
const framework = { name: packageName };
const frameworkPackageJson = {
name: packageName,
Expand All @@ -35,8 +36,6 @@ describe('getFrameworkInfo', () => {
},
};

jest.spyOn(process, 'cwd').mockReturnValue('/path/to/project');

(getActualPackageJson as jest.Mock).mockResolvedValueOnce(frameworkPackageJson);

const result = await getFrameworkInfo({ framework } as StorybookConfig);
Expand All @@ -45,7 +44,7 @@ describe('getFrameworkInfo', () => {

expect(result).toEqual({
framework: {
name: '$SNIP/@storybook/react',
name: '$SNIP/@storybook/react'.split('/').join(path.sep),
options: undefined,
},
builder: '@storybook/builder-vite',
Expand Down

0 comments on commit 332fe2d

Please sign in to comment.