More Angular test fixes and others

This commit is contained in:
Mark 2022-11-01 03:08:53 -05:00
parent 22bcdd0d89
commit 2c509cb2f7
16 changed files with 221 additions and 184 deletions

View File

@ -1,5 +1,5 @@
module.exports = {
preset: 'jest-preset-angular',
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
transformIgnorePatterns: ['^.+\\.js$'],
transformIgnorePatterns: ['/node_modules/(?!@angular|rxjs|nanoid|uuid)'],
};

View File

@ -1,4 +1,12 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import 'jest-preset-angular/setup-jest';
import { webcrypto } from 'node:crypto';
Object.defineProperty(window, 'crypto', {
get() {
return webcrypto;
},
});
global.EventSource = class {} as any;

View File

@ -3,8 +3,13 @@ import { TestingArchitectHost } from '@angular-devkit/architect/testing';
import { schema } from '@angular-devkit/core';
import * as path from 'path';
const buildStandaloneMock = jest.fn();
jest.doMock('@storybook/core-server/standalone', () => buildStandaloneMock);
const buildDevStandaloneMock = jest.fn();
const buildStaticStandaloneMock = jest.fn();
const buildMock = {
buildDevStandalone: buildDevStandaloneMock,
buildStaticStandalone: buildStaticStandaloneMock,
};
jest.doMock('@storybook/core-server', () => buildMock);
jest.doMock('find-up', () => ({ sync: () => './storybook/tsconfig.ts' }));
const cpSpawnMock = {
@ -50,7 +55,7 @@ describe('Build Storybook Builder', () => {
});
beforeEach(() => {
buildStandaloneMock.mockImplementation((_options: unknown) => Promise.resolve());
buildStaticStandaloneMock.mockImplementation((_options: unknown) => Promise.resolve());
cpSpawnMock.spawn.mockImplementation(() => ({
stdout: { on: () => {} },
stderr: { on: () => {} },
@ -74,14 +79,16 @@ describe('Build Storybook Builder', () => {
expect(output.success).toBeTruthy();
expect(cpSpawnMock.spawn).not.toHaveBeenCalledWith();
expect(buildStandaloneMock).toHaveBeenCalledWith({
expect(buildStaticStandaloneMock).toHaveBeenCalledWith({
angularBrowserTarget: 'angular-cli:build-2',
angularBuilderContext: expect.any(Object),
angularBuilderOptions: {},
configDir: '.storybook',
docs: undefined,
loglevel: undefined,
quiet: false,
outputDir: 'storybook-static',
packageJson: expect.any(Object),
mode: 'static',
tsConfig: './storybook/tsconfig.ts',
webpackStatsJson: false,
@ -100,14 +107,16 @@ describe('Build Storybook Builder', () => {
expect(output.success).toBeTruthy();
expect(cpSpawnMock.spawn).not.toHaveBeenCalledWith();
expect(buildStandaloneMock).toHaveBeenCalledWith({
expect(buildStaticStandaloneMock).toHaveBeenCalledWith({
angularBrowserTarget: null,
angularBuilderContext: expect.any(Object),
angularBuilderOptions: {},
configDir: '.storybook',
docs: undefined,
loglevel: undefined,
quiet: false,
outputDir: 'storybook-static',
packageJson: expect.any(Object),
mode: 'static',
tsConfig: 'path/to/tsConfig.json',
webpackStatsJson: false,
@ -127,14 +136,16 @@ describe('Build Storybook Builder', () => {
expect(output.success).toBeTruthy();
expect(cpSpawnMock.spawn).not.toHaveBeenCalledWith();
expect(buildStandaloneMock).toHaveBeenCalledWith({
expect(buildStaticStandaloneMock).toHaveBeenCalledWith({
angularBrowserTarget: null,
angularBuilderContext: expect.any(Object),
angularBuilderOptions: {},
configDir: '.storybook',
docs: undefined,
loglevel: undefined,
quiet: false,
outputDir: 'storybook-static',
packageJson: expect.any(Object),
mode: 'static',
tsConfig: 'path/to/tsConfig.json',
webpackStatsJson: true,
@ -142,7 +153,7 @@ describe('Build Storybook Builder', () => {
});
it('should throw error', async () => {
buildStandaloneMock.mockRejectedValue(true);
buildStaticStandaloneMock.mockRejectedValue(true);
const run = await architect.scheduleBuilder('@storybook/angular:start-storybook', {
browserTarget: 'angular-cli:build-2',
@ -177,16 +188,19 @@ describe('Build Storybook Builder', () => {
['compodoc', '-p', './storybook/tsconfig.ts', '-d', '', '-e', 'json'],
{
cwd: '',
shell: true,
}
);
expect(buildStandaloneMock).toHaveBeenCalledWith({
expect(buildStaticStandaloneMock).toHaveBeenCalledWith({
angularBrowserTarget: 'angular-cli:build-2',
angularBuilderContext: expect.any(Object),
angularBuilderOptions: {},
configDir: '.storybook',
docs: undefined,
loglevel: undefined,
quiet: false,
outputDir: 'storybook-static',
packageJson: expect.any(Object),
mode: 'static',
tsConfig: './storybook/tsconfig.ts',
webpackStatsJson: false,
@ -206,14 +220,16 @@ describe('Build Storybook Builder', () => {
expect(output.success).toBeTruthy();
expect(cpSpawnMock.spawn).not.toHaveBeenCalledWith();
expect(buildStandaloneMock).toHaveBeenCalledWith({
expect(buildStaticStandaloneMock).toHaveBeenCalledWith({
angularBrowserTarget: null,
angularBuilderContext: expect.any(Object),
angularBuilderOptions: { styles: ['style.scss'] },
configDir: '.storybook',
docs: undefined,
loglevel: undefined,
quiet: false,
outputDir: 'storybook-static',
packageJson: expect.any(Object),
mode: 'static',
tsConfig: 'path/to/tsConfig.json',
webpackStatsJson: false,

View File

@ -3,8 +3,13 @@ import { TestingArchitectHost } from '@angular-devkit/architect/testing';
import { schema } from '@angular-devkit/core';
import * as path from 'path';
const buildStandaloneMock = jest.fn();
jest.doMock('@storybook/core-server/standalone', () => buildStandaloneMock);
const buildDevStandaloneMock = jest.fn();
const buildStaticStandaloneMock = jest.fn();
const buildMock = {
buildDevStandalone: buildDevStandaloneMock,
buildStaticStandalone: buildStaticStandaloneMock,
};
jest.doMock('@storybook/core-server', () => buildMock);
jest.doMock('find-up', () => ({ sync: () => './storybook/tsconfig.ts' }));
const cpSpawnMock = {
@ -49,7 +54,7 @@ describe('Start Storybook Builder', () => {
});
beforeEach(() => {
buildStandaloneMock.mockImplementation((_options: unknown) => Promise.resolve());
buildDevStandaloneMock.mockImplementation((_options: unknown) => Promise.resolve());
cpSpawnMock.spawn.mockImplementation(() => ({
stdout: { on: () => {} },
stderr: { on: () => {} },
@ -74,14 +79,16 @@ describe('Start Storybook Builder', () => {
expect(output.success).toBeTruthy();
expect(cpSpawnMock.spawn).not.toHaveBeenCalledWith();
expect(buildStandaloneMock).toHaveBeenCalledWith({
expect(buildDevStandaloneMock).toHaveBeenCalledWith({
angularBrowserTarget: 'angular-cli:build-2',
angularBuilderContext: expect.any(Object),
angularBuilderOptions: {},
ci: false,
configDir: '.storybook',
docs: undefined,
host: 'localhost',
https: false,
packageJson: expect.any(Object),
port: 4400,
quiet: false,
smokeTest: false,
@ -105,14 +112,16 @@ describe('Start Storybook Builder', () => {
expect(output.success).toBeTruthy();
expect(cpSpawnMock.spawn).not.toHaveBeenCalledWith();
expect(buildStandaloneMock).toHaveBeenCalledWith({
expect(buildDevStandaloneMock).toHaveBeenCalledWith({
angularBrowserTarget: null,
angularBuilderContext: expect.any(Object),
angularBuilderOptions: {},
ci: false,
configDir: '.storybook',
docs: undefined,
host: 'localhost',
https: false,
packageJson: expect.any(Object),
port: 4400,
quiet: false,
smokeTest: false,
@ -124,7 +133,7 @@ describe('Start Storybook Builder', () => {
});
it('should throw error', async () => {
buildStandaloneMock.mockRejectedValue(true);
buildDevStandaloneMock.mockRejectedValue(true);
const run = await architect.scheduleBuilder('@storybook/angular:start-storybook', {
browserTarget: 'angular-cli:build-2',
@ -159,16 +168,19 @@ describe('Start Storybook Builder', () => {
['compodoc', '-p', './storybook/tsconfig.ts', '-d', '', '-e', 'json'],
{
cwd: '',
shell: true,
}
);
expect(buildStandaloneMock).toHaveBeenCalledWith({
expect(buildDevStandaloneMock).toHaveBeenCalledWith({
angularBrowserTarget: 'angular-cli:build-2',
angularBuilderContext: expect.any(Object),
angularBuilderOptions: {},
ci: false,
configDir: '.storybook',
docs: undefined,
host: 'localhost',
https: false,
packageJson: expect.any(Object),
port: 9009,
quiet: false,
smokeTest: false,
@ -193,7 +205,7 @@ describe('Start Storybook Builder', () => {
expect(output.success).toBeTruthy();
expect(cpSpawnMock.spawn).not.toHaveBeenCalledWith();
expect(buildStandaloneMock).toHaveBeenCalledWith({
expect(buildDevStandaloneMock).toHaveBeenCalledWith({
angularBrowserTarget: null,
angularBuilderContext: expect.any(Object),
angularBuilderOptions: {
@ -201,9 +213,11 @@ describe('Start Storybook Builder', () => {
},
ci: false,
configDir: '.storybook',
docs: undefined,
host: 'localhost',
https: false,
port: 4400,
packageJson: expect.any(Object),
quiet: false,
smokeTest: false,
sslCa: undefined,

View File

@ -10,7 +10,7 @@ Object {
"getSignature": Object {
"description": "<p>Getter for <code>inputValue</code>.</p>
",
"line": 115,
"line": 116,
"name": "inputValue",
"rawdescription": "
Getter for \`inputValue\`.",
@ -42,7 +42,7 @@ Getter for \`inputValue\`.",
"type": "string",
},
],
"line": 110,
"line": 111,
"name": "inputValue",
"rawdescription": "
Setter for \`inputValue\` that is also an \`@Input\`.",
@ -74,7 +74,7 @@ Setter for \`inputValue\` that is also an \`@Input\`.",
"type": "T[]",
},
],
"line": 195,
"line": 196,
"name": "item",
"returnType": "void",
"type": "void",
@ -84,7 +84,7 @@ Setter for \`inputValue\` that is also an \`@Input\`.",
"getSignature": Object {
"description": "<p>Get the private value.</p>
",
"line": 154,
"line": 155,
"name": "value",
"rawdescription": "
Get the private value.",
@ -116,7 +116,7 @@ Get the private value.",
"type": "string | number",
},
],
"line": 149,
"line": 150,
"name": "value",
"rawdescription": "
Set the private value.",
@ -137,14 +137,14 @@ like <strong>bold</strong>, <em>italic</em>, and <code>inline code</code>.</p>
",
"encapsulation": Array [],
"entryComponents": Array [],
"file": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
"file": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"hostBindings": Array [
Object {
"decorators": Array [],
"defaultValue": "false",
"deprecated": false,
"deprecationMessage": "",
"line": 124,
"line": 125,
"name": "class.focused",
"type": "boolean",
},
@ -164,7 +164,7 @@ like <strong>bold</strong>, <em>italic</em>, and <code>inline code</code>.</p>
],
"deprecated": false,
"deprecationMessage": "",
"line": 120,
"line": 121,
"name": "click",
},
],
@ -177,7 +177,7 @@ like <strong>bold</strong>, <em>italic</em>, and <code>inline code</code>.</p>
"deprecationMessage": "",
"description": "<p>Specify the accent-type of the button</p>
",
"line": 56,
"line": 57,
"name": "accent",
"rawdescription": "
Specify the accent-type of the button",
@ -190,7 +190,7 @@ Specify the accent-type of the button",
"deprecationMessage": "",
"description": "<p>Appearance style of the button.</p>
",
"line": 52,
"line": 53,
"name": "appearance",
"rawdescription": "
Appearance style of the button.",
@ -202,7 +202,7 @@ Appearance style of the button.",
"deprecationMessage": "",
"description": "<p>Setter for <code>inputValue</code> that is also an <code>@Input</code>.</p>
",
"line": 110,
"line": 111,
"name": "inputValue",
"rawdescription": "
Setter for \`inputValue\` that is also an \`@Input\`.",
@ -215,7 +215,7 @@ Setter for \`inputValue\` that is also an \`@Input\`.",
"deprecationMessage": "",
"description": "<p>Sets the button to a disabled state.</p>
",
"line": 60,
"line": 61,
"name": "isDisabled",
"rawdescription": "
Sets the button to a disabled state.",
@ -225,7 +225,7 @@ Sets the button to a disabled state.",
"decorators": Array [],
"deprecated": false,
"deprecationMessage": "",
"line": 195,
"line": 196,
"name": "item",
"type": "T[]",
},
@ -238,24 +238,24 @@ Sets the button to a disabled state.",
"jsdoctags": Array [
Object {
"comment": "",
"end": 1525,
"end": 1587,
"flags": 4227072,
"kind": 325,
"modifierFlagsCache": 0,
"pos": 1512,
"pos": 1574,
"tagName": Object {
"end": 1521,
"end": 1583,
"escapedText": "required",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 1513,
"pos": 1575,
"transformFlags": 0,
},
"transformFlags": 0,
},
],
"line": 68,
"line": 69,
"name": "label",
"rawdescription": "
@ -268,7 +268,7 @@ The inner text of the button.
"decorators": Array [],
"deprecated": false,
"deprecationMessage": "",
"line": 192,
"line": 193,
"name": "showKeyAlias",
"type": "",
},
@ -279,7 +279,7 @@ The inner text of the button.
"deprecationMessage": "",
"description": "<p>Size of the button.</p>
",
"line": 72,
"line": 73,
"name": "size",
"rawdescription": "
Size of the button.",
@ -291,7 +291,7 @@ Size of the button.",
"deprecationMessage": "",
"description": "<p>Specifies some arbitrary object</p>
",
"line": 75,
"line": 76,
"name": "someDataObject",
"rawdescription": "
Specifies some arbitrary object",
@ -307,24 +307,24 @@ Specifies some arbitrary object",
"jsdoctags": Array [
Object {
"comment": "",
"end": 1802,
"end": 1864,
"flags": 4227072,
"kind": 329,
"modifierFlagsCache": 0,
"pos": 1787,
"pos": 1849,
"tagName": Object {
"end": 1798,
"end": 1860,
"escapedText": "deprecated",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 1788,
"pos": 1850,
"transformFlags": 0,
},
"transformFlags": 0,
},
],
"line": 83,
"line": 84,
"name": "somethingYouShouldNotUse",
"rawdescription": "
@ -361,21 +361,21 @@ Some input you shouldn't use.
"deprecated": false,
"deprecationMessage": "",
"name": Object {
"end": 3518,
"end": 3580,
"escapedText": "x",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 3517,
"pos": 3579,
"transformFlags": 0,
},
"tagName": Object {
"end": 3516,
"end": 3578,
"escapedText": "param",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 3511,
"pos": 3573,
"transformFlags": 0,
},
"type": "number",
@ -386,27 +386,27 @@ Some input you shouldn't use.
"deprecated": false,
"deprecationMessage": "",
"name": Object {
"end": 3563,
"end": 3625,
"escapedText": "y",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 3562,
"pos": 3624,
"transformFlags": 0,
},
"tagName": Object {
"end": 3561,
"end": 3623,
"escapedText": "param",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 3556,
"pos": 3618,
"transformFlags": 0,
},
"type": "string | number",
},
],
"line": 164,
"line": 165,
"modifierKind": Array [
123,
],
@ -448,7 +448,7 @@ An internal calculation method which adds \`x\` and \`y\` together.
"type": "",
},
],
"line": 120,
"line": 121,
"name": "onClickListener",
"optional": false,
"returnType": "void",
@ -474,27 +474,27 @@ An internal calculation method which adds \`x\` and \`y\` together.
"deprecated": false,
"deprecationMessage": "",
"name": Object {
"end": 4079,
"end": 4141,
"escapedText": "password",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 4071,
"pos": 4133,
"transformFlags": 0,
},
"tagName": Object {
"end": 4070,
"end": 4132,
"escapedText": "param",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 4065,
"pos": 4127,
"transformFlags": 0,
},
"type": "string",
},
],
"line": 187,
"line": 188,
"modifierKind": Array [
121,
],
@ -529,28 +529,28 @@ A private method.
"deprecated": false,
"deprecationMessage": "",
"name": Object {
"end": 3938,
"end": 4000,
"escapedText": "id",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 3936,
"pos": 3998,
"transformFlags": 0,
},
"optional": true,
"tagName": Object {
"end": 3935,
"end": 3997,
"escapedText": "param",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 3930,
"pos": 3992,
"transformFlags": 0,
},
"type": "number",
},
],
"line": 178,
"line": 179,
"modifierKind": Array [
122,
],
@ -588,7 +588,7 @@ A protected method.
"type": "ISomeInterface",
},
],
"line": 169,
"line": 170,
"modifierKind": Array [
123,
],
@ -610,7 +610,7 @@ A public method using an interface.",
"description": "<p>Handler to be called when the button is clicked by a user.</p>
<p>Will also block the emission of the event if <code>isDisabled</code> is true.</p>
",
"line": 91,
"line": 92,
"name": "onClick",
"rawdescription": "
@ -627,7 +627,7 @@ Will also block the emission of the event if \`isDisabled\` is true.
"deprecated": false,
"deprecationMessage": "",
"description": "",
"line": 106,
"line": 107,
"modifierKind": Array [
121,
],
@ -641,7 +641,7 @@ Will also block the emission of the event if \`isDisabled\` is true.
"deprecationMessage": "",
"description": "<p>Private value.</p>
",
"line": 146,
"line": 147,
"modifierKind": Array [
121,
],
@ -661,7 +661,7 @@ Private value.",
"deprecated": false,
"deprecationMessage": "",
"description": "",
"line": 48,
"line": 49,
"name": "buttonRef",
"optional": false,
"type": "ElementRef",
@ -677,7 +677,7 @@ Private value.",
"deprecated": false,
"deprecationMessage": "",
"description": "",
"line": 124,
"line": 125,
"name": "focus",
"optional": false,
"type": "",
@ -688,7 +688,7 @@ Private value.",
"deprecationMessage": "",
"description": "<p>Public value.</p>
",
"line": 143,
"line": 144,
"modifierKind": Array [
123,
],
@ -702,7 +702,7 @@ Public value.",
"deprecated": false,
"deprecationMessage": "",
"description": "",
"line": 199,
"line": 200,
"modifierKind": Array [
123,
],
@ -937,7 +937,7 @@ export class InputComponent<T> {
Object {
"coverageCount": "16/25",
"coveragePercent": 64,
"filePath": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
"filePath": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"linktype": "component",
"name": "InputComponent",
"status": "good",
@ -946,7 +946,7 @@ export class InputComponent<T> {
Object {
"coverageCount": "0/4",
"coveragePercent": 0,
"filePath": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
"filePath": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"linktype": "interface",
"name": "ISomeInterface",
"status": "low",
@ -955,7 +955,7 @@ export class InputComponent<T> {
Object {
"coverageCount": "0/1",
"coveragePercent": 0,
"filePath": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
"filePath": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"linksubtype": "variable",
"linktype": "miscellaneous",
"name": "exportedConstant",
@ -973,7 +973,7 @@ export class InputComponent<T> {
Object {
"deprecated": false,
"deprecationMessage": "",
"file": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
"file": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"id": "interface-ISomeInterface-d145da25329b094ee29610c45a9e46387cb39eddb2a67b4c9fadb84bcec76eacd60d131e48d98b2ee5725dedd25f2eb299b704e8e0a34307d6e84f6e57d57044",
"indexSignatures": Array [],
"kind": 165,
@ -984,7 +984,7 @@ export class InputComponent<T> {
"deprecated": false,
"deprecationMessage": "",
"description": "",
"line": 25,
"line": 26,
"name": "one",
"optional": false,
"type": "string",
@ -993,7 +993,7 @@ export class InputComponent<T> {
"deprecated": false,
"deprecationMessage": "",
"description": "",
"line": 27,
"line": 28,
"name": "three",
"optional": false,
"type": "any[]",
@ -1002,7 +1002,7 @@ export class InputComponent<T> {
"deprecated": false,
"deprecationMessage": "",
"description": "",
"line": 26,
"line": 27,
"name": "two",
"optional": false,
"type": "boolean",
@ -1230,14 +1230,14 @@ export class InputComponent<T> {
"deprecated": false,
"deprecationMessage": "",
"description": "",
"file": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
"file": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"name": "ButtonAccent",
"subtype": "enum",
},
],
"functions": Array [],
"groupedEnumerations": Object {
"addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts": Array [
"frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts": Array [
Object {
"childs": Array [
Object {
@ -1257,7 +1257,7 @@ export class InputComponent<T> {
"deprecated": false,
"deprecationMessage": "",
"description": "",
"file": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
"file": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"name": "ButtonAccent",
"subtype": "enum",
},
@ -1265,13 +1265,13 @@ export class InputComponent<T> {
},
"groupedFunctions": Object {},
"groupedTypeAliases": Object {
"addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts": Array [
"frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts": Array [
Object {
"ctype": "miscellaneous",
"deprecated": false,
"deprecationMessage": "",
"description": "",
"file": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
"file": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"kind": 186,
"name": "ButtonSize",
"rawtype": "\\"small\\" | \\"medium\\" | \\"large\\" | \\"xlarge\\"",
@ -1280,13 +1280,13 @@ export class InputComponent<T> {
],
},
"groupedVariables": Object {
"addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts": Array [
"frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts": Array [
Object {
"ctype": "miscellaneous",
"defaultValue": "'An exported constant'",
"deprecated": false,
"deprecationMessage": "",
"file": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
"file": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"name": "exportedConstant",
"subtype": "variable",
"type": "string",
@ -1299,7 +1299,7 @@ export class InputComponent<T> {
"deprecated": false,
"deprecationMessage": "",
"description": "",
"file": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
"file": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"kind": 186,
"name": "ButtonSize",
"rawtype": "\\"small\\" | \\"medium\\" | \\"large\\" | \\"xlarge\\"",
@ -1312,7 +1312,7 @@ export class InputComponent<T> {
"defaultValue": "'An exported constant'",
"deprecated": false,
"deprecationMessage": "",
"file": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
"file": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"name": "exportedConstant",
"subtype": "variable",
"type": "string",

View File

@ -10,7 +10,7 @@ Object {
"getSignature": Object {
"description": "<p>Getter for <code>inputValue</code>.</p>
",
"line": 115,
"line": 116,
"name": "inputValue",
"rawdescription": "
Getter for \`inputValue\`.",
@ -42,7 +42,7 @@ Getter for \`inputValue\`.",
"type": "string",
},
],
"line": 110,
"line": 111,
"name": "inputValue",
"rawdescription": "
Setter for \`inputValue\` that is also an \`@Input\`.",
@ -74,7 +74,7 @@ Setter for \`inputValue\` that is also an \`@Input\`.",
"type": "T[]",
},
],
"line": 195,
"line": 196,
"name": "item",
"returnType": "void",
"type": "void",
@ -84,7 +84,7 @@ Setter for \`inputValue\` that is also an \`@Input\`.",
"getSignature": Object {
"description": "<p>Get the private value.</p>
",
"line": 154,
"line": 155,
"name": "value",
"rawdescription": "
Get the private value.",
@ -116,7 +116,7 @@ Get the private value.",
"type": "string | number",
},
],
"line": 149,
"line": 150,
"name": "value",
"rawdescription": "
Set the private value.",
@ -144,7 +144,7 @@ like <strong>bold</strong>, <em>italic</em>, and <code>inline code</code>.</p>
"defaultValue": "false",
"deprecated": false,
"deprecationMessage": "",
"line": 124,
"line": 125,
"name": "class.focused",
"type": "boolean",
},
@ -164,7 +164,7 @@ like <strong>bold</strong>, <em>italic</em>, and <code>inline code</code>.</p>
],
"deprecated": false,
"deprecationMessage": "",
"line": 120,
"line": 121,
"name": "click",
},
],
@ -177,7 +177,7 @@ like <strong>bold</strong>, <em>italic</em>, and <code>inline code</code>.</p>
"deprecationMessage": "",
"description": "<p>Specify the accent-type of the button</p>
",
"line": 56,
"line": 57,
"name": "accent",
"rawdescription": "
Specify the accent-type of the button",
@ -190,7 +190,7 @@ Specify the accent-type of the button",
"deprecationMessage": "",
"description": "<p>Appearance style of the button.</p>
",
"line": 52,
"line": 53,
"name": "appearance",
"rawdescription": "
Appearance style of the button.",
@ -202,7 +202,7 @@ Appearance style of the button.",
"deprecationMessage": "",
"description": "<p>Setter for <code>inputValue</code> that is also an <code>@Input</code>.</p>
",
"line": 110,
"line": 111,
"name": "inputValue",
"rawdescription": "
Setter for \`inputValue\` that is also an \`@Input\`.",
@ -215,7 +215,7 @@ Setter for \`inputValue\` that is also an \`@Input\`.",
"deprecationMessage": "",
"description": "<p>Sets the button to a disabled state.</p>
",
"line": 60,
"line": 61,
"name": "isDisabled",
"rawdescription": "
Sets the button to a disabled state.",
@ -225,7 +225,7 @@ Sets the button to a disabled state.",
"decorators": Array [],
"deprecated": false,
"deprecationMessage": "",
"line": 195,
"line": 196,
"name": "item",
"type": "T[]",
},
@ -238,24 +238,24 @@ Sets the button to a disabled state.",
"jsdoctags": Array [
Object {
"comment": "",
"end": 1525,
"end": 1587,
"flags": 4227072,
"kind": 325,
"modifierFlagsCache": 0,
"pos": 1512,
"pos": 1574,
"tagName": Object {
"end": 1521,
"end": 1583,
"escapedText": "required",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 1513,
"pos": 1575,
"transformFlags": 0,
},
"transformFlags": 0,
},
],
"line": 68,
"line": 69,
"name": "label",
"rawdescription": "
@ -268,7 +268,7 @@ The inner text of the button.
"decorators": Array [],
"deprecated": false,
"deprecationMessage": "",
"line": 192,
"line": 193,
"name": "showKeyAlias",
"type": "",
},
@ -279,7 +279,7 @@ The inner text of the button.
"deprecationMessage": "",
"description": "<p>Size of the button.</p>
",
"line": 72,
"line": 73,
"name": "size",
"rawdescription": "
Size of the button.",
@ -291,7 +291,7 @@ Size of the button.",
"deprecationMessage": "",
"description": "<p>Specifies some arbitrary object</p>
",
"line": 75,
"line": 76,
"name": "someDataObject",
"rawdescription": "
Specifies some arbitrary object",
@ -307,24 +307,24 @@ Specifies some arbitrary object",
"jsdoctags": Array [
Object {
"comment": "",
"end": 1802,
"end": 1864,
"flags": 4227072,
"kind": 329,
"modifierFlagsCache": 0,
"pos": 1787,
"pos": 1849,
"tagName": Object {
"end": 1798,
"end": 1860,
"escapedText": "deprecated",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 1788,
"pos": 1850,
"transformFlags": 0,
},
"transformFlags": 0,
},
],
"line": 83,
"line": 84,
"name": "somethingYouShouldNotUse",
"rawdescription": "
@ -361,21 +361,21 @@ Some input you shouldn't use.
"deprecated": false,
"deprecationMessage": "",
"name": Object {
"end": 3518,
"end": 3580,
"escapedText": "x",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 3517,
"pos": 3579,
"transformFlags": 0,
},
"tagName": Object {
"end": 3516,
"end": 3578,
"escapedText": "param",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 3511,
"pos": 3573,
"transformFlags": 0,
},
"type": "number",
@ -386,27 +386,27 @@ Some input you shouldn't use.
"deprecated": false,
"deprecationMessage": "",
"name": Object {
"end": 3563,
"end": 3625,
"escapedText": "y",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 3562,
"pos": 3624,
"transformFlags": 0,
},
"tagName": Object {
"end": 3561,
"end": 3623,
"escapedText": "param",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 3556,
"pos": 3618,
"transformFlags": 0,
},
"type": "string | number",
},
],
"line": 164,
"line": 165,
"modifierKind": Array [
123,
],
@ -448,7 +448,7 @@ An internal calculation method which adds \`x\` and \`y\` together.
"type": "",
},
],
"line": 120,
"line": 121,
"name": "onClickListener",
"optional": false,
"returnType": "void",
@ -474,27 +474,27 @@ An internal calculation method which adds \`x\` and \`y\` together.
"deprecated": false,
"deprecationMessage": "",
"name": Object {
"end": 4079,
"end": 4141,
"escapedText": "password",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 4071,
"pos": 4133,
"transformFlags": 0,
},
"tagName": Object {
"end": 4070,
"end": 4132,
"escapedText": "param",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 4065,
"pos": 4127,
"transformFlags": 0,
},
"type": "string",
},
],
"line": 187,
"line": 188,
"modifierKind": Array [
121,
],
@ -529,28 +529,28 @@ A private method.
"deprecated": false,
"deprecationMessage": "",
"name": Object {
"end": 3938,
"end": 4000,
"escapedText": "id",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 3936,
"pos": 3998,
"transformFlags": 0,
},
"optional": true,
"tagName": Object {
"end": 3935,
"end": 3997,
"escapedText": "param",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
"pos": 3930,
"pos": 3992,
"transformFlags": 0,
},
"type": "number",
},
],
"line": 178,
"line": 179,
"modifierKind": Array [
122,
],
@ -588,7 +588,7 @@ A protected method.
"type": "ISomeInterface",
},
],
"line": 169,
"line": 170,
"modifierKind": Array [
123,
],
@ -610,7 +610,7 @@ A public method using an interface.",
"description": "<p>Handler to be called when the button is clicked by a user.</p>
<p>Will also block the emission of the event if <code>isDisabled</code> is true.</p>
",
"line": 91,
"line": 92,
"name": "onClick",
"rawdescription": "
@ -627,7 +627,7 @@ Will also block the emission of the event if \`isDisabled\` is true.
"deprecated": false,
"deprecationMessage": "",
"description": "",
"line": 106,
"line": 107,
"modifierKind": Array [
121,
],
@ -641,7 +641,7 @@ Will also block the emission of the event if \`isDisabled\` is true.
"deprecationMessage": "",
"description": "<p>Private value.</p>
",
"line": 146,
"line": 147,
"modifierKind": Array [
121,
],
@ -661,7 +661,7 @@ Private value.",
"deprecated": false,
"deprecationMessage": "",
"description": "",
"line": 48,
"line": 49,
"name": "buttonRef",
"optional": false,
"type": "ElementRef",
@ -677,7 +677,7 @@ Private value.",
"deprecated": false,
"deprecationMessage": "",
"description": "",
"line": 124,
"line": 125,
"name": "focus",
"optional": false,
"type": "",
@ -688,7 +688,7 @@ Private value.",
"deprecationMessage": "",
"description": "<p>Public value.</p>
",
"line": 143,
"line": 144,
"modifierKind": Array [
123,
],
@ -702,7 +702,7 @@ Public value.",
"deprecated": false,
"deprecationMessage": "",
"description": "",
"line": 199,
"line": 200,
"modifierKind": Array [
123,
],
@ -984,7 +984,7 @@ export class InputComponent<T> {
"deprecated": false,
"deprecationMessage": "",
"description": "",
"line": 25,
"line": 26,
"name": "one",
"optional": false,
"type": "string",
@ -993,7 +993,7 @@ export class InputComponent<T> {
"deprecated": false,
"deprecationMessage": "",
"description": "",
"line": 27,
"line": 28,
"name": "three",
"optional": false,
"type": "any[]",
@ -1002,7 +1002,7 @@ export class InputComponent<T> {
"deprecated": false,
"deprecationMessage": "",
"description": "",
"line": 26,
"line": 27,
"name": "two",
"optional": false,
"type": "boolean",

View File

@ -31,10 +31,7 @@ module.exports = {
'^.+\\.[jt]sx?$': '<rootDir>/../scripts/utils/jest-transform-js.js',
'^.+\\.mdx$': '@storybook/addon-docs/jest-transform-mdx',
},
transformIgnorePatterns: [
'/node_modules/(?!(lit-html|@mdx-js)).+\\.js',
'/node_modules/(?!).+\\.js',
],
transformIgnorePatterns: ['/node_modules/(?!@angular|rxjs|nanoid|uuid|lit-html|@mdx-js)'],
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
testPathIgnorePatterns: [
'/storybook-static/',
@ -43,7 +40,6 @@ module.exports = {
'/prebuilt/',
'/template/',
'addon-jest.test.js',
'/frameworks/angular/*',
'/examples/*/src/*.*',
'/examples/*/src/*/*.*',
'/examples/*/src/*/*/*.*',

View File

@ -9,6 +9,7 @@ import Adapter from 'enzyme-adapter-react-16';
import regeneratorRuntime from 'regenerator-runtime';
import registerRequireContextHook from '@storybook/babel-plugin-require-context-hook/register';
import EventEmitter from 'events';
import { webcrypto } from 'node:crypto';
registerRequireContextHook();
@ -96,3 +97,9 @@ class EventSourceMock {
}
global.window.EventSource = EventSourceMock as any;
Object.defineProperty(window, 'crypto', {
get() {
return webcrypto;
},
});

View File

@ -62,7 +62,7 @@
"util-deprecate": "^1.0.2"
},
"devDependencies": {
"@jest/globals": "^26.6.2",
"@jest/globals": "^28.0.0",
"@storybook/core-common": "7.0.0-alpha.42",
"@types/lodash": "^4.14.167",
"@types/qs": "^6",

View File

@ -83,7 +83,7 @@
"@types/ws": "^8",
"jest-os-detection": "^1.3.1",
"jest-specific-snapshot": "^4.0.0",
"ts-jest": "^26.4.4",
"ts-jest": "^28.0.0",
"typescript": "~4.6.3",
"webpack": "5"
},

View File

@ -7,7 +7,6 @@ import type { NormalizedStoriesSpecifier } from '@storybook/core-common';
import { loadCsf, getStorySortParameter } from '@storybook/csf-tools';
import { toId } from '@storybook/csf';
import { logger } from '@storybook/node-logger';
import { mocked } from 'ts-jest/utils';
import { StoryIndexGenerator } from './StoryIndexGenerator';
@ -59,7 +58,7 @@ describe('StoryIndexGenerator', () => {
beforeEach(() => {
const actual = jest.requireActual('@storybook/csf-tools');
loadCsfMock.mockImplementation(actual.loadCsf);
mocked(logger.warn).mockClear();
jest.mocked(logger.warn).mockClear();
});
describe('extraction', () => {
const storiesSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry(
@ -701,7 +700,7 @@ describe('StoryIndexGenerator', () => {
`);
expect(logger.warn).toHaveBeenCalledTimes(1);
expect(mocked(logger.warn).mock.calls[0][0]).toMatchInlineSnapshot(
expect(jest.mocked(logger.warn).mock.calls[0][0]).toMatchInlineSnapshot(
`"🚨 You have two component docs pages with the same name A:docs. Use \`<Meta of={} name=\\"Other Name\\">\` to distinguish them."`
);
});
@ -729,7 +728,7 @@ describe('StoryIndexGenerator', () => {
`);
expect(logger.warn).toHaveBeenCalledTimes(1);
expect(mocked(logger.warn).mock.calls[0][0]).toMatchInlineSnapshot(
expect(jest.mocked(logger.warn).mock.calls[0][0]).toMatchInlineSnapshot(
`"🚨 You have a story for A with the same name as your component docs page (Story One), so the docs page is being dropped. Use \`<Meta of={} name=\\"Other Name\\">\` to distinguish them."`
);
});
@ -751,7 +750,7 @@ describe('StoryIndexGenerator', () => {
`);
expect(logger.warn).toHaveBeenCalledTimes(1);
expect(mocked(logger.warn).mock.calls[0][0]).toMatchInlineSnapshot(
expect(jest.mocked(logger.warn).mock.calls[0][0]).toMatchInlineSnapshot(
`"🚨 You have a story for A with the same name as your default docs entry name (Story One), so the docs page is being dropped. Consider changing the story name."`
);
});

View File

@ -3,7 +3,6 @@
import prompts from 'prompts';
import { loadAllPresets, cache } from '@storybook/core-common';
import { telemetry } from '@storybook/telemetry';
import { mocked } from 'ts-jest/utils';
import { withTelemetry } from './withTelemetry';
@ -57,7 +56,7 @@ describe('when command fails', () => {
});
it('does not send error message when crash reports are disabled', async () => {
mocked(loadAllPresets).mockResolvedValueOnce({
jest.mocked(loadAllPresets).mockResolvedValueOnce({
apply: async () => ({ enableCrashReports: false } as any),
});
await expect(async () =>
@ -73,7 +72,7 @@ describe('when command fails', () => {
});
it('does send error message when crash reports are enabled', async () => {
mocked(loadAllPresets).mockResolvedValueOnce({
jest.mocked(loadAllPresets).mockResolvedValueOnce({
apply: async () => ({ enableCrashReports: true } as any),
});
@ -90,7 +89,7 @@ describe('when command fails', () => {
});
it('does not send error message when telemetry is disabled', async () => {
mocked(loadAllPresets).mockResolvedValueOnce({
jest.mocked(loadAllPresets).mockResolvedValueOnce({
apply: async () => ({ disableTelemetry: true } as any),
});
@ -107,7 +106,7 @@ describe('when command fails', () => {
});
it('does send error messages when telemetry is disabled, but crash reports are enabled', async () => {
mocked(loadAllPresets).mockResolvedValueOnce({
jest.mocked(loadAllPresets).mockResolvedValueOnce({
apply: async () => ({ disableTelemetry: true, enableCrashReports: true } as any),
});
@ -124,10 +123,10 @@ describe('when command fails', () => {
});
it('does not send error messages when disabled crash reports are cached', async () => {
mocked(loadAllPresets).mockResolvedValueOnce({
jest.mocked(loadAllPresets).mockResolvedValueOnce({
apply: async () => ({} as any),
});
mocked(cache.get).mockResolvedValueOnce(false);
jest.mocked(cache.get).mockResolvedValueOnce(false);
await expect(async () =>
withTelemetry('dev', { presetOptions: {} as any }, run)
@ -142,10 +141,10 @@ describe('when command fails', () => {
});
it('does send error messages when enabled crash reports are cached', async () => {
mocked(loadAllPresets).mockResolvedValueOnce({
jest.mocked(loadAllPresets).mockResolvedValueOnce({
apply: async () => ({} as any),
});
mocked(cache.get).mockResolvedValueOnce(true);
jest.mocked(cache.get).mockResolvedValueOnce(true);
await expect(async () =>
withTelemetry('dev', { presetOptions: {} as any }, run)
@ -160,11 +159,11 @@ describe('when command fails', () => {
});
it('does not send error messages when disabled crash reports are prompted', async () => {
mocked(loadAllPresets).mockResolvedValueOnce({
jest.mocked(loadAllPresets).mockResolvedValueOnce({
apply: async () => ({} as any),
});
mocked(cache.get).mockResolvedValueOnce(undefined);
mocked(prompts).mockResolvedValueOnce({ enableCrashReports: false });
jest.mocked(cache.get).mockResolvedValueOnce(undefined);
jest.mocked(prompts).mockResolvedValueOnce({ enableCrashReports: false });
await expect(async () =>
withTelemetry('dev', { presetOptions: {} as any }, run)
@ -179,11 +178,11 @@ describe('when command fails', () => {
});
it('does send error messages when enabled crash reports are prompted', async () => {
mocked(loadAllPresets).mockResolvedValueOnce({
jest.mocked(loadAllPresets).mockResolvedValueOnce({
apply: async () => ({} as any),
});
mocked(cache.get).mockResolvedValueOnce(undefined);
mocked(prompts).mockResolvedValueOnce({ enableCrashReports: true });
jest.mocked(cache.get).mockResolvedValueOnce(undefined);
jest.mocked(prompts).mockResolvedValueOnce({ enableCrashReports: true });
await expect(async () =>
withTelemetry('dev', { presetOptions: {} as any }, run)
@ -199,7 +198,7 @@ describe('when command fails', () => {
// if main.js has errors, we have no way to tell if they've disabled telemetry
it('does not send error messages when presets fail to evaluate', async () => {
mocked(loadAllPresets).mockRejectedValueOnce(error);
jest.mocked(loadAllPresets).mockRejectedValueOnce(error);
await expect(async () =>
withTelemetry('dev', { presetOptions: {} as any }, run)

View File

@ -3,7 +3,6 @@ import global from 'global';
import { RenderContext } from '@storybook/store';
import addons, { mockChannel as createMockChannel } from '@storybook/addons';
import { mocked } from 'ts-jest/utils';
import { expect } from '@jest/globals';
import { PreviewWeb } from './PreviewWeb';
@ -63,8 +62,8 @@ beforeEach(() => {
addons.setChannel(mockChannel as any);
addons.setServerChannel(createMockChannel());
mocked(WebView.prototype).prepareForDocs.mockReturnValue('docs-element' as any);
mocked(WebView.prototype).prepareForStory.mockReturnValue('story-element' as any);
jest.mocked(WebView.prototype).prepareForDocs.mockReturnValue('docs-element' as any);
jest.mocked(WebView.prototype).prepareForStory.mockReturnValue('story-element' as any);
});
describe('PreviewWeb', () => {

View File

@ -31,7 +31,6 @@ import { logger } from '@storybook/client-logger';
import { addons, mockChannel as createMockChannel } from '@storybook/addons';
import type { AnyFramework } from '@storybook/csf';
import type { ModuleImportFn, WebProjectAnnotations } from '@storybook/store';
import { mocked } from 'ts-jest/utils';
import { PreviewWeb } from './PreviewWeb';
import {
@ -140,8 +139,8 @@ beforeEach(() => {
addons.setServerChannel(createMockChannel());
mockFetchResult = { status: 200, json: mockStoryIndex, text: () => 'error text' };
mocked(WebView.prototype).prepareForDocs.mockReturnValue('docs-element' as any);
mocked(WebView.prototype).prepareForStory.mockReturnValue('story-element' as any);
jest.mocked(WebView.prototype).prepareForDocs.mockReturnValue('docs-element' as any);
jest.mocked(WebView.prototype).prepareForStory.mockReturnValue('story-element' as any);
});
describe('PreviewWeb', () => {

View File

@ -74,7 +74,7 @@
},
"devDependencies": {
"@babel/core": "^7.11.5",
"@jest/globals": "^26.6.2",
"@jest/globals": "^28.0.0",
"@types/util-deprecate": "^1.0.0",
"expect-type": "^0.14.2",
"jest-specific-snapshot": "^4.0.0",

View File

@ -3128,7 +3128,7 @@ __metadata:
languageName: node
linkType: hard
"@jest/globals@npm:^28.1.3":
"@jest/globals@npm:^28.0.0, @jest/globals@npm:^28.1.3":
version: 28.1.3
resolution: "@jest/globals@npm:28.1.3"
dependencies:
@ -6880,7 +6880,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@storybook/api@workspace:lib/api"
dependencies:
"@jest/globals": ^26.6.2
"@jest/globals": ^28.0.0
"@storybook/channels": 7.0.0-alpha.42
"@storybook/client-logger": 7.0.0-alpha.42
"@storybook/core-common": 7.0.0-alpha.42
@ -7405,7 +7405,7 @@ __metadata:
slash: ^3.0.0
telejson: ^6.0.8
ts-dedent: ^2.0.0
ts-jest: ^26.4.4
ts-jest: ^28.0.0
typescript: ~4.6.3
util-deprecate: ^1.0.2
watchpack: ^2.2.0
@ -8132,7 +8132,7 @@ __metadata:
resolution: "@storybook/react@workspace:renderers/react"
dependencies:
"@babel/core": ^7.11.5
"@jest/globals": ^26.6.2
"@jest/globals": ^28.0.0
"@storybook/addons": 7.0.0-alpha.42
"@storybook/client-logger": 7.0.0-alpha.42
"@storybook/core-client": 7.0.0-alpha.42
@ -38378,7 +38378,7 @@ __metadata:
languageName: node
linkType: hard
"ts-jest@npm:26.x, ts-jest@npm:^26.4.4":
"ts-jest@npm:26.x":
version: 26.5.6
resolution: "ts-jest@npm:26.5.6"
dependencies: