@storybook/test 0.0.0-pr-23888-sha-032c0a61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,31 @@
1
+ import { AsymmetricMatchersContaining, MatchersObject, MatcherState, JestAssertion } from '@vitest/expect';
2
+ import * as spy from '@vitest/spy';
3
+ export * from '@vitest/spy';
4
+
5
+ type Promisify<O> = {
6
+ [K in keyof O]: O[K] extends (...args: infer A) => infer R ? O extends R ? Promisify<O[K]> : (...args: A) => Promise<R> : O[K];
7
+ };
8
+ interface Assertion<T> extends Promisify<JestAssertion<T>> {
9
+ toHaveBeenCalledOnce(): Promise<void>;
10
+ toSatisfy<E>(matcher: (value: E) => boolean, message?: string): Promise<void>;
11
+ resolves: Promisify<Assertion<T>>;
12
+ rejects: Promisify<Assertion<T>>;
13
+ }
14
+ interface Expect extends AsymmetricMatchersContaining {
15
+ <T>(actual: T, message?: string): Assertion<T>;
16
+ unreachable(message?: string): Promise<never>;
17
+ soft<T>(actual: T, message?: string): Assertion<T>;
18
+ extend(expects: MatchersObject): void;
19
+ assertions(expected: number): Promise<void>;
20
+ hasAssertions(): Promise<void>;
21
+ anything(): any;
22
+ any(constructor: unknown): any;
23
+ getState(): MatcherState;
24
+ setState(state: Partial<MatcherState>): void;
25
+ not: AsymmetricMatchersContaining;
26
+ }
27
+
28
+ declare const fn: typeof spy.fn;
29
+ declare const expect: Expect;
30
+
31
+ export { expect, fn };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__reExport=(target,mod,secondTarget)=>(__copyProps(target,mod,"default"),secondTarget&&__copyProps(secondTarget,mod,"default")),__toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var src_exports={};__export(src_exports,{expect:()=>expect3,fn:()=>fn2});module.exports=__toCommonJS(src_exports);var import_instrumenter=require("@storybook/instrumenter"),spy=__toESM(require("@vitest/spy")),import_chai=__toESM(require("chai"));var chai=__toESM(require("chai")),import_expect=require("@vitest/expect"),matchers=__toESM(require("@testing-library/jest-dom/matchers"));function createExpect(){chai.use(import_expect.JestExtend),chai.use(import_expect.JestChaiExpect),chai.use(import_expect.JestAsymmetricMatchers);let expect4=(value,message)=>{let{assertionCalls}=(0,import_expect.getState)(expect4);return(0,import_expect.setState)({assertionCalls:assertionCalls+1,soft:!1},expect4),chai.expect(value,message)};Object.assign(expect4,chai.expect),expect4.getState=()=>(0,import_expect.getState)(expect4),expect4.setState=state=>(0,import_expect.setState)(state,expect4),expect4.extend=expects=>chai.expect.extend(expect4,expects),expect4.soft=(...args)=>{let assert2=expect4(...args);return expect4.setState({soft:!0}),assert2},expect4.unreachable=message=>{chai.assert.fail(`expected${message?` "${message}" `:" "}not to be reached`)};function assertions(expected){let errorGen=()=>new Error(`expected number of assertions to be ${expected}, but got ${expect4.getState().assertionCalls}`);Error.captureStackTrace&&Error.captureStackTrace(errorGen(),assertions),expect4.setState({expectedAssertionsNumber:expected,expectedAssertionsNumberErrorGen:errorGen})}function hasAssertions(){let error=new Error("expected any number of assertion, but got none");Error.captureStackTrace&&Error.captureStackTrace(error,hasAssertions),expect4.setState({isExpectingAssertions:!0,isExpectingAssertionsError:error})}return(0,import_expect.setState)({assertionCalls:0,isExpectingAssertions:!1,isExpectingAssertionsError:null,expectedAssertionsNumber:null,expectedAssertionsNumberErrorGen:null},expect4),chai.util.addMethod(expect4,"assertions",assertions),chai.util.addMethod(expect4,"hasAssertions",hasAssertions),expect4.extend(matchers),expect4}var expect2=createExpect();Object.defineProperty(globalThis,import_expect.GLOBAL_EXPECT,{value:expect2,writable:!0,configurable:!0});__reExport(src_exports,require("@vitest/spy"),module.exports);var{fn:fn2}=(0,import_instrumenter.instrument)({fn:spy.fn},{retain:!0}),{expect:expect3}=(0,import_instrumenter.instrument)({expect:expect2},{getKeys:obj=>{let privateApi=["assert","__methods","__flags"];return obj.constructor===import_chai.default.Assertion?Object.keys(Object.getPrototypeOf(obj)).filter(it=>!privateApi.includes(it)):Object.keys(obj)},intercept:!0});0&&(module.exports={expect,fn,...require("@vitest/spy")});
package/dist/index.mjs ADDED
@@ -0,0 +1,11 @@
1
+ import { instrument } from '@storybook/instrumenter';
2
+ import * as spy from '@vitest/spy';
3
+ export * from '@vitest/spy';
4
+ import * as chai from 'chai';
5
+ import chai__default from 'chai';
6
+ import { GLOBAL_EXPECT, JestExtend, JestChaiExpect, JestAsymmetricMatchers, getState, setState } from '@vitest/expect';
7
+ import * as matchers from '@testing-library/jest-dom/matchers';
8
+
9
+ function createExpect(){chai.use(JestExtend),chai.use(JestChaiExpect),chai.use(JestAsymmetricMatchers);let expect4=(value,message)=>{let{assertionCalls}=getState(expect4);return setState({assertionCalls:assertionCalls+1,soft:!1},expect4),chai.expect(value,message)};Object.assign(expect4,chai.expect),expect4.getState=()=>getState(expect4),expect4.setState=state=>setState(state,expect4),expect4.extend=expects=>chai.expect.extend(expect4,expects),expect4.soft=(...args)=>{let assert2=expect4(...args);return expect4.setState({soft:!0}),assert2},expect4.unreachable=message=>{chai.assert.fail(`expected${message?` "${message}" `:" "}not to be reached`);};function assertions(expected){let errorGen=()=>new Error(`expected number of assertions to be ${expected}, but got ${expect4.getState().assertionCalls}`);Error.captureStackTrace&&Error.captureStackTrace(errorGen(),assertions),expect4.setState({expectedAssertionsNumber:expected,expectedAssertionsNumberErrorGen:errorGen});}function hasAssertions(){let error=new Error("expected any number of assertion, but got none");Error.captureStackTrace&&Error.captureStackTrace(error,hasAssertions),expect4.setState({isExpectingAssertions:!0,isExpectingAssertionsError:error});}return setState({assertionCalls:0,isExpectingAssertions:!1,isExpectingAssertionsError:null,expectedAssertionsNumber:null,expectedAssertionsNumberErrorGen:null},expect4),chai.util.addMethod(expect4,"assertions",assertions),chai.util.addMethod(expect4,"hasAssertions",hasAssertions),expect4.extend(matchers),expect4}var expect2=createExpect();Object.defineProperty(globalThis,GLOBAL_EXPECT,{value:expect2,writable:!0,configurable:!0});var {fn:fn2}=instrument({fn:spy.fn},{retain:!0}),{expect:expect3}=instrument({expect:expect2},{getKeys:obj=>{let privateApi=["assert","__methods","__flags"];return obj.constructor===chai__default.Assertion?Object.keys(Object.getPrototypeOf(obj)).filter(it=>!privateApi.includes(it)):Object.keys(obj)},intercept:!0});
10
+
11
+ export { expect3 as expect, fn2 as fn };
package/jest.config.js ADDED
@@ -0,0 +1,7 @@
1
+ const path = require('path');
2
+ const baseConfig = require('../../jest.config.browser');
3
+
4
+ module.exports = {
5
+ ...baseConfig,
6
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
7
+ };
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@storybook/test",
3
+ "version": "0.0.0-pr-23888-sha-032c0a61",
4
+ "description": "",
5
+ "keywords": [
6
+ "storybook"
7
+ ],
8
+ "homepage": "https://github.com/storybookjs/storybook/tree/next/code/lib/test",
9
+ "bugs": {
10
+ "url": "https://github.com/storybookjs/storybook/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/storybookjs/storybook.git",
15
+ "directory": "code/lib/test"
16
+ },
17
+ "funding": {
18
+ "type": "opencollective",
19
+ "url": "https://opencollective.com/storybook"
20
+ },
21
+ "license": "MIT",
22
+ "sideEffects": false,
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "node": "./dist/index.js",
27
+ "require": "./dist/index.js",
28
+ "import": "./dist/index.mjs"
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
32
+ "main": "dist/index.js",
33
+ "module": "dist/index.mjs",
34
+ "types": "dist/index.d.ts",
35
+ "files": [
36
+ "dist/**/*",
37
+ "README.md",
38
+ "*.js",
39
+ "*.d.ts"
40
+ ],
41
+ "scripts": {
42
+ "check": "../../../scripts/prepare/check.ts",
43
+ "prep": "../../../scripts/prepare/bundle.ts"
44
+ },
45
+ "dependencies": {
46
+ "@storybook/instrumenter": "^0.0.0-pr-23888-sha-032c0a61",
47
+ "@testing-library/jest-dom": "^6.0.0",
48
+ "@vitest/expect": "^0.34.2",
49
+ "@vitest/spy": "^0.34.1",
50
+ "chai": "^4.3.7",
51
+ "expect": "^29.6.2"
52
+ },
53
+ "devDependencies": {
54
+ "@types/chai": "^4",
55
+ "type-fest": "~2.19",
56
+ "typescript": "~4.9.3"
57
+ },
58
+ "publishConfig": {
59
+ "access": "public"
60
+ },
61
+ "bundler": {
62
+ "entries": [
63
+ "./src/index.ts"
64
+ ]
65
+ },
66
+ "gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae17"
67
+ }