Skip to content

Commit

Permalink
Avoid concurrent test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
IanVS committed Nov 24, 2021
1 parent 1faf93d commit 56b5948
Show file tree
Hide file tree
Showing 33 changed files with 73 additions and 74 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`cra-ts-essentials manager dev mode 1`] = `
exports[`cra-ts-essentials manager dev 1`] = `
Object {
"entry": Array [
"NODE_MODULES/@storybook/addon-ie11/dist/event-source-polyfill.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`cra-ts-essentials manager dev mode 1`] = `
exports[`cra-ts-essentials manager dev 1`] = `
Object {
"entry": Array [
"NODE_MODULES\\\\@storybook\\\\addon-ie11\\\\dist\\\\event-source-polyfill.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`cra-ts-essentials manager production mode 1`] = `
exports[`cra-ts-essentials manager prod 1`] = `
Object {
"entry": Array [
"NODE_MODULES/@storybook/addon-ie11/dist/event-source-polyfill.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`cra-ts-essentials manager production mode 1`] = `
exports[`cra-ts-essentials manager prod 1`] = `
Object {
"entry": Array [
"NODE_MODULES\\\\@storybook\\\\addon-ie11\\\\dist\\\\event-source-polyfill.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`cra-ts-essentials preview dev mode 1`] = `
exports[`cra-ts-essentials preview dev 1`] = `
Object {
"entry": Array [
"ROOT/lib/core-client/dist/esm/globals/polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`cra-ts-essentials preview dev mode 1`] = `
exports[`cra-ts-essentials preview dev 1`] = `
Object {
"entry": Array [
"ROOT\\\\lib\\\\core-client\\\\dist\\\\esm\\\\globals\\\\polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`cra-ts-essentials preview production mode 1`] = `
exports[`cra-ts-essentials preview prod 1`] = `
Object {
"entry": Array [
"ROOT/lib/core-client/dist/esm/globals/polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`cra-ts-essentials preview production mode 1`] = `
exports[`cra-ts-essentials preview prod 1`] = `
Object {
"entry": Array [
"ROOT\\\\lib\\\\core-client\\\\dist\\\\esm\\\\globals\\\\polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`html-kitchen-sink manager dev mode 1`] = `
exports[`html-kitchen-sink manager dev 1`] = `
Object {
"entry": Array [
"ROOT/lib/core-client/dist/esm/globals/polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`html-kitchen-sink manager dev mode 1`] = `
exports[`html-kitchen-sink manager dev 1`] = `
Object {
"entry": Array [
"ROOT\\\\lib\\\\core-client\\\\dist\\\\esm\\\\globals\\\\polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`html-kitchen-sink manager production mode 1`] = `
exports[`html-kitchen-sink manager prod 1`] = `
Object {
"entry": Array [
"ROOT/lib/core-client/dist/esm/globals/polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`html-kitchen-sink manager production mode 1`] = `
exports[`html-kitchen-sink manager prod 1`] = `
Object {
"entry": Array [
"ROOT\\\\lib\\\\core-client\\\\dist\\\\esm\\\\globals\\\\polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`html-kitchen-sink preview dev mode 1`] = `
exports[`html-kitchen-sink preview dev 1`] = `
Object {
"entry": Array [
"ROOT/lib/core-client/dist/esm/globals/polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`html-kitchen-sink preview dev mode 1`] = `
exports[`html-kitchen-sink preview dev 1`] = `
Object {
"entry": Array [
"ROOT\\\\lib\\\\core-client\\\\dist\\\\esm\\\\globals\\\\polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`html-kitchen-sink preview production mode 1`] = `
exports[`html-kitchen-sink preview prod 1`] = `
Object {
"entry": Array [
"ROOT/lib/core-client/dist/esm/globals/polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`html-kitchen-sink preview production mode 1`] = `
exports[`html-kitchen-sink preview prod 1`] = `
Object {
"entry": Array [
"ROOT\\\\lib\\\\core-client\\\\dist\\\\esm\\\\globals\\\\polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`vue-3-cli manager dev mode 1`] = `
exports[`vue-3-cli manager dev 1`] = `
Object {
"entry": Array [
"ROOT/lib/core-client/dist/esm/globals/polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`vue-3-cli manager dev mode 1`] = `
exports[`vue-3-cli manager dev 1`] = `
Object {
"entry": Array [
"ROOT\\\\lib\\\\core-client\\\\dist\\\\esm\\\\globals\\\\polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`vue-3-cli manager production mode 1`] = `
exports[`vue-3-cli manager prod 1`] = `
Object {
"entry": Array [
"ROOT/lib/core-client/dist/esm/globals/polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`vue-3-cli manager production mode 1`] = `
exports[`vue-3-cli manager prod 1`] = `
Object {
"entry": Array [
"ROOT\\\\lib\\\\core-client\\\\dist\\\\esm\\\\globals\\\\polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`vue-3-cli preview dev mode 1`] = `
exports[`vue-3-cli preview dev 1`] = `
Object {
"entry": Array [
"ROOT/lib/core-client/dist/esm/globals/polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`vue-3-cli preview dev mode 1`] = `
exports[`vue-3-cli preview dev 1`] = `
Object {
"entry": Array [
"ROOT\\\\lib\\\\core-client\\\\dist\\\\esm\\\\globals\\\\polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`vue-3-cli preview production mode 1`] = `
exports[`vue-3-cli preview prod 1`] = `
Object {
"entry": Array [
"ROOT/lib/core-client/dist/esm/globals/polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`vue-3-cli preview production mode 1`] = `
exports[`vue-3-cli preview prod 1`] = `
Object {
"entry": Array [
"ROOT\\\\lib\\\\core-client\\\\dist\\\\esm\\\\globals\\\\polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`web-components-kitchen-sink manager dev mode 1`] = `
exports[`web-components-kitchen-sink manager dev 1`] = `
Object {
"entry": Array [
"ROOT/lib/core-client/dist/esm/globals/polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`web-components-kitchen-sink manager dev mode 1`] = `
exports[`web-components-kitchen-sink manager dev 1`] = `
Object {
"entry": Array [
"ROOT\\\\lib\\\\core-client\\\\dist\\\\esm\\\\globals\\\\polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`web-components-kitchen-sink manager production mode 1`] = `
exports[`web-components-kitchen-sink manager prod 1`] = `
Object {
"entry": Array [
"ROOT/lib/core-client/dist/esm/globals/polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`web-components-kitchen-sink manager production mode 1`] = `
exports[`web-components-kitchen-sink manager prod 1`] = `
Object {
"entry": Array [
"ROOT\\\\lib\\\\core-client\\\\dist\\\\esm\\\\globals\\\\polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`web-components-kitchen-sink preview dev mode 1`] = `
exports[`web-components-kitchen-sink preview dev 1`] = `
Object {
"entry": Array [
"ROOT/lib/core-client/dist/esm/globals/polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`web-components-kitchen-sink preview dev mode 1`] = `
exports[`web-components-kitchen-sink preview dev 1`] = `
Object {
"entry": Array [
"ROOT\\\\lib\\\\core-client\\\\dist\\\\esm\\\\globals\\\\polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`web-components-kitchen-sink preview production mode 1`] = `
exports[`web-components-kitchen-sink preview prod 1`] = `
Object {
"entry": Array [
"ROOT/lib/core-client/dist/esm/globals/polyfills.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`web-components-kitchen-sink preview production mode 1`] = `
exports[`web-components-kitchen-sink preview prod 1`] = `
Object {
"entry": Array [
"ROOT\\\\lib\\\\core-client\\\\dist\\\\esm\\\\globals\\\\polyfills.js",
Expand Down
83 changes: 41 additions & 42 deletions lib/core-server/src/core-presets.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import 'jest-specific-snapshot';
import path from 'path';
import { mkdtemp as mkdtempCb } from 'fs';
import os from 'os';
import { promisify } from 'util';
import { Configuration } from 'webpack';
import Cache from 'file-system-cache';
import { resolvePathInStorybookCache } from '@storybook/core-common';
Expand All @@ -20,10 +23,12 @@ import webComponentsOptions from '../../../app/web-components/src/server/options
import { outputStats } from './utils/output-stats';

const { SNAPSHOT_OS } = global;
const mkdtemp = promisify(mkdtempCb);

// this only applies to this file
jest.setTimeout(10000);

// FIXME: this doesn't work
const skipStoriesJsonPreset = [{ features: { buildStoriesJson: false, storyStoreV7: false } }];

jest.mock('@storybook/builder-webpack4', () => {
Expand Down Expand Up @@ -87,7 +92,6 @@ const baseOptions = {
docsMode: false,
cache,
configDir: path.resolve(`${__dirname}/../../../examples/react-ts/.storybook`),
outputDir: `${__dirname}/storybook-static`, // production
ci: true,
managerCache: false,
};
Expand Down Expand Up @@ -137,44 +141,35 @@ describe.each([
['web-components-kitchen-sink', webComponentsOptions],
['html-kitchen-sink', htmlOptions],
])('%s', (example, frameworkOptions) => {
beforeEach(() => {
jest.clearAllMocks();
cache.clear();
});

const options = {
...baseOptions,
...frameworkOptions,
configDir: path.resolve(`${__dirname}/../../../examples/${example}/.storybook`),
};

describe('manager', () => {
it('dev mode', async () => {
await buildDevStandalone({ ...options, ignorePreview: true });

const managerConfig = prepareSnap(managerExecutor.get, 'manager');
expect(managerConfig).toMatchSpecificSnapshot(snap(`${example}_manager-dev-${SNAPSHOT_OS}`));
});
it('production mode', async () => {
await buildStaticStandalone({ ...options, ignorePreview: true });

const managerConfig = prepareSnap(managerExecutor.get, 'manager');
expect(managerConfig).toMatchSpecificSnapshot(snap(`${example}_manager-prod-${SNAPSHOT_OS}`));
});
});

describe('preview', () => {
it('dev mode', async () => {
await buildDevStandalone({ ...options, managerCache: true });

const previewConfig = prepareSnap(previewExecutor.get, 'preview');
expect(previewConfig).toMatchSpecificSnapshot(snap(`${example}_preview-dev-${SNAPSHOT_OS}`));
describe.each([
['manager', managerExecutor],
['preview', previewExecutor],
])('%s', (component, executor) => {
beforeEach(async () => {
jest.clearAllMocks();
await cache.clear();
});
it('production mode', async () => {
await buildStaticStandalone({ ...options, managerCache: true });

const previewConfig = prepareSnap(previewExecutor.get, 'preview');
expect(previewConfig).toMatchSpecificSnapshot(snap(`${example}_preview-prod-${SNAPSHOT_OS}`));
it.each([
['prod', buildStaticStandalone],
['dev', buildDevStandalone],
])('%s', async (mode, builder) => {
const options = {
...baseOptions,
...frameworkOptions,
configDir: path.resolve(`${__dirname}/../../../examples/${example}/.storybook`),
// Only add an outputDir in production mode.
outputDir:
mode === 'prod' ? await mkdtemp(path.join(os.tmpdir(), 'storybook-static-')) : undefined,
ignorePreview: component === 'manager',
managerCache: component === 'preview',
};

await builder(options);
const config = prepareSnap(executor.get, component);
expect(config).toMatchSpecificSnapshot(
snap(`${example}_${component}-${mode}-${SNAPSHOT_OS}`)
);
});
});
});
Expand All @@ -183,9 +178,9 @@ const progressPlugin = (config) =>
config.plugins.find((p) => p.constructor.name === 'ProgressPlugin');

describe('dev cli flags', () => {
beforeEach(() => {
beforeEach(async () => {
jest.clearAllMocks();
cache.clear();
await cache.clear();
});

const cliOptions = { ...reactOptions, ...baseOptions };
Expand Down Expand Up @@ -250,11 +245,15 @@ describe('dev cli flags', () => {
});

describe('build cli flags', () => {
beforeEach(() => {
beforeEach(async () => {
jest.clearAllMocks();
cache.clear();
await cache.clear();
});
const cliOptions = { ...reactOptions, ...baseOptions };
const cliOptions = {
...reactOptions,
...baseOptions,
outputDir: `${__dirname}/storybook-static`,
};

it('--webpack-stats-json calls output-stats', async () => {
await buildStaticStandalone(cliOptions);
Expand Down

0 comments on commit 56b5948

Please sign in to comment.