-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Is your feature request related to a problem? Please describe.
Currently, I am able to start a standalone storybook in dev mode but cannot stop it. I am attempting to start the server before running storyshots+puppeteer then tear it down.
I have the following jest globalSetup module but it does not seem to work because jest complains that it was unable to exit cleanly:
// jest/globalSetup.js
import { join } from "path";
import storybook from "@storybook/react/standalone";
module.exports = async () => {
await storybook({
port: 6006,
mode: "dev",
ci: true,
configDir: join(process.cwd(), ".storybook"),
extendServer: srv => {
srv.unref();
}
});
};
Jest output:
Test Suites: 1 passed, 1 total
Tests: 10 passed, 10 total
Snapshots: 0 total
Time: 7.167s
Ran all test suites.
Jest did not exit one second after the test run has completed.
This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.
So it seems that calling unref()
is not enough.
Describe the solution you'd like
Ideally the following would work just fine without needing jest's globalSetup:
// storyshots.test.js
import { join } from "path";
import storybook from "@storybook/react/standalone";
import initStoryshots from "@storybook/addon-storyshots";
import { imageSnapshot } from "@storybook/addon-storyshots-puppeteer";
let instance = null;
beforeAll(async () => {
instance = await storybook({
port: 6006,
mode: "dev",
ci: true,
configDir: join(process.cwd(), ".storybook"),
extendServer: srv => {
srv.unref();
}
});
})
afterAll(async () => {
if (instance) {
await instance.stop();
}
})
describe("Image storyshots", () => {
initStoryshots({ suite: , test: imageSnapshot() });
});
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Are you able to assist bring the feature to reality?
I think I can but would appreciate guidance...