Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Support Storybook 6.5 #107

Merged
merged 5 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@
"@babel/template": "^7.14.5",
"@babel/types": "^7.14.8",
"@jest/types": "^27.0.6",
"@storybook/addon-essentials": "^6.4.14",
"@storybook/addon-interactions": "^6.4.14",
"@storybook/jest": "^0.0.5",
"@storybook/react": "^6.4.14",
"@storybook/testing-library": "^0.0.7",
"@storybook/testing-react": "^1.2.3",
"@storybook/addon-essentials": "^6.5.0-rc.0",
"@storybook/addon-interactions": "^6.5.0-rc.0",
"@storybook/jest": "^0.0.10",
"@storybook/react": "^6.5.0-rc.0",
"@storybook/testing-library": "^0.0.11",
"@storybook/testing-react": "^1.2.4",
"@testing-library/dom": "^8.1.0",
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^13.2.1",
Expand Down Expand Up @@ -97,7 +97,7 @@
"icon": "https://user-images.githubusercontent.com/321738/63501763-88dbf600-c4cc-11e9-96cd-94adadc2fd72.png"
},
"dependencies": {
"@storybook/csf": "0.0.2--canary.87bc651.0",
"@storybook/csf": "0.0.2-alpha.0",
yannbf marked this conversation as resolved.
Show resolved Hide resolved
"commander": "^9.0.0",
"global": "^4.4.0",
"is-localhost-ip": "^1.4.0",
Expand All @@ -109,9 +109,9 @@
"ts-dedent": "^2.0.0"
},
"peerDependencies": {
"@storybook/core-common": "^6.4.0 || >= 6.5.0-alpha.1",
"@storybook/csf-tools": "^6.4.0 || >= 6.5.0-alpha.1",
"@storybook/store": "^6.4.0 || >= 6.5.0-alpha.1",
"@storybook/core-common": ">= 6.5.0-rc.0",
yannbf marked this conversation as resolved.
Show resolved Hide resolved
"@storybook/csf-tools": ">= 6.5.0-rc.0",
"@storybook/store": ">= 6.5.0-rc.0",
"jest": "^26.6.3 || ^27.0.0"
}
}
6 changes: 3 additions & 3 deletions src/csf/transformCsf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface TransformOptions {
beforeEachPrefixer?: FilePrefixer;
testPrefixer?: TestPrefixer;
insertTestIfEmpty?: boolean;
defaultTitle?: string;
makeTitle?: (userTitle: string) => string;
}

const prefixFunction = (
Expand Down Expand Up @@ -92,10 +92,10 @@ export const transformCsf = (
testPrefixer,
beforeEachPrefixer,
insertTestIfEmpty,
defaultTitle,
makeTitle,
}: TransformOptions = {}
) => {
const csf = loadCsf(code, { defaultTitle });
const csf = loadCsf(code, { makeTitle });
csf.parse();

const storyExports = Object.keys(csf._stories);
Expand Down
268 changes: 134 additions & 134 deletions src/playwright/transformPlaywright.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,57 +54,57 @@ describe('Playwright', () => {
} = require('@storybook/test-runner');

if (!require.main) {
describe("foo/bar", () => {
describe("A", () => {
it("play-test", async () => {
const testFn = async () => {
const context = {
id: "foo-bar--a",
title: "foo/bar",
name: "A"
};
page.on('pageerror', err => {
page.evaluate(({
describe("Example/foo/bar", () => {
describe("A", () => {
it("play-test", async () => {
const testFn = async () => {
const context = {
id: "example-foo-bar--a",
title: "Example/foo/bar",
name: "A"
};
page.on('pageerror', err => {
page.evaluate(({
id,
err
}) => __throwError(id, err), {
id: "example-foo-bar--a",
err: err.message
});
});

if (global.__sbPreRender) {
await global.__sbPreRender(page, context);
}

const result = await page.evaluate(({
id,
err
}) => __throwError(id, err), {
id: "foo-bar--a",
err: err.message
hasPlayFn
}) => __test(id, hasPlayFn), {
id: "example-foo-bar--a"
});
});

if (global.__sbPreRender) {
await global.__sbPreRender(page, context);
}

const result = await page.evaluate(({
id,
hasPlayFn
}) => __test(id, hasPlayFn), {
id: "foo-bar--a"
});

if (global.__sbPostRender) {
await global.__sbPostRender(page, context);
}

return result;
};

try {
await testFn();
} catch (err) {
if (err.toString().includes('Execution context was destroyed')) {
await jestPlaywright.resetPage();
await setupPage(global.page);

if (global.__sbPostRender) {
await global.__sbPostRender(page, context);
}

return result;
};

try {
await testFn();
} else {
throw err;
} catch (err) {
if (err.toString().includes('Execution context was destroyed')) {
await jestPlaywright.resetPage();
await setupPage(global.page);
await testFn();
} else {
throw err;
}
}
}
});
});
});
});
}
`);
});
Expand All @@ -125,57 +125,57 @@ describe('Playwright', () => {
} = require('@storybook/test-runner');

if (!require.main) {
describe("foo/bar", () => {
describe("A", () => {
it("smoke-test", async () => {
const testFn = async () => {
const context = {
id: "foo-bar--a",
title: "foo/bar",
name: "A"
};
page.on('pageerror', err => {
page.evaluate(({
describe("Example/foo/bar", () => {
describe("A", () => {
it("smoke-test", async () => {
const testFn = async () => {
const context = {
id: "example-foo-bar--a",
title: "Example/foo/bar",
name: "A"
};
page.on('pageerror', err => {
page.evaluate(({
id,
err
}) => __throwError(id, err), {
id: "example-foo-bar--a",
err: err.message
});
});

if (global.__sbPreRender) {
await global.__sbPreRender(page, context);
}

const result = await page.evaluate(({
id,
err
}) => __throwError(id, err), {
id: "foo-bar--a",
err: err.message
hasPlayFn
}) => __test(id, hasPlayFn), {
id: "example-foo-bar--a"
});
});

if (global.__sbPreRender) {
await global.__sbPreRender(page, context);
}

const result = await page.evaluate(({
id,
hasPlayFn
}) => __test(id, hasPlayFn), {
id: "foo-bar--a"
});

if (global.__sbPostRender) {
await global.__sbPostRender(page, context);
}

return result;
};

try {
await testFn();
} catch (err) {
if (err.toString().includes('Execution context was destroyed')) {
await jestPlaywright.resetPage();
await setupPage(global.page);

if (global.__sbPostRender) {
await global.__sbPostRender(page, context);
}

return result;
};

try {
await testFn();
} else {
throw err;
} catch (err) {
if (err.toString().includes('Execution context was destroyed')) {
await jestPlaywright.resetPage();
await setupPage(global.page);
await testFn();
} else {
throw err;
}
}
}
});
});
});
});
}
`);
});
Expand All @@ -198,56 +198,56 @@ describe('Playwright', () => {

if (!require.main) {
describe("Example/Header", () => {
describe("A", () => {
it("smoke-test", async () => {
const testFn = async () => {
const context = {
id: "example-header--a",
title: "Example/Header",
name: "A"
};
page.on('pageerror', err => {
page.evaluate(({
id,
err
}) => __throwError(id, err), {
describe("A", () => {
it("smoke-test", async () => {
const testFn = async () => {
const context = {
id: "example-header--a",
err: err.message
title: "Example/Header",
name: "A"
};
page.on('pageerror', err => {
page.evaluate(({
id,
err
}) => __throwError(id, err), {
id: "example-header--a",
err: err.message
});
});
});

if (global.__sbPreRender) {
await global.__sbPreRender(page, context);
}

const result = await page.evaluate(({
id,
hasPlayFn
}) => __test(id, hasPlayFn), {
id: "example-header--a"
});

if (global.__sbPostRender) {
await global.__sbPostRender(page, context);
}

return result;
};

try {
await testFn();
} catch (err) {
if (err.toString().includes('Execution context was destroyed')) {
await jestPlaywright.resetPage();
await setupPage(global.page);

if (global.__sbPreRender) {
await global.__sbPreRender(page, context);
}

const result = await page.evaluate(({
id,
hasPlayFn
}) => __test(id, hasPlayFn), {
id: "example-header--a"
});

if (global.__sbPostRender) {
await global.__sbPostRender(page, context);
}

return result;
};

try {
await testFn();
} else {
throw err;
} catch (err) {
if (err.toString().includes('Execution context was destroyed')) {
await jestPlaywright.resetPage();
await setupPage(global.page);
await testFn();
} else {
throw err;
}
}
}
});
});
});
});
}
`);
});
Expand Down
Loading