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

Expose method to stop in standalone dev server #6554

Closed
disintegrator opened this issue Apr 17, 2019 · 3 comments
Closed

Expose method to stop in standalone dev server #6554

disintegrator opened this issue Apr 17, 2019 · 3 comments

Comments

@disintegrator
Copy link

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...

@stale
Copy link

stale bot commented May 9, 2019

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label May 9, 2019
@stale
Copy link

stale bot commented Jun 8, 2019

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

@stale stale bot closed this as completed Jun 8, 2019
This was referenced Mar 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants