@storybook/addon-vitest 9.2.0-alpha.3 → 10.0.0-beta.0
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.
- package/README.md +2 -0
- package/dist/_browser-chunks/chunk-JK72E6FR.js +6 -0
- package/dist/_browser-chunks/chunk-PMYV6BH2.js +76 -0
- package/dist/_node-chunks/chunk-2LKDLHP2.js +91 -0
- package/dist/_node-chunks/chunk-75PF53UG.js +103 -0
- package/dist/_node-chunks/chunk-EZERIZC2.js +481 -0
- package/dist/_node-chunks/chunk-FJO43W6J.js +37 -0
- package/dist/_node-chunks/chunk-HIDBMPI3.js +247 -0
- package/dist/_node-chunks/chunk-MHHQUJAV.js +50 -0
- package/dist/_node-chunks/chunk-MJKNSUFZ.js +295 -0
- package/dist/_node-chunks/chunk-T7EST64K.js +2264 -0
- package/dist/index.js +9 -6
- package/dist/manager.js +955 -8
- package/dist/node/coverage-reporter.js +1898 -4
- package/dist/node/vitest.js +871 -17
- package/dist/postinstall.js +2076 -88
- package/dist/preset.js +615 -35
- package/dist/vitest-plugin/global-setup.js +200 -6
- package/dist/vitest-plugin/index.js +3823 -43
- package/dist/vitest-plugin/setup-file.js +30 -8
- package/dist/vitest-plugin/test-utils.js +102 -8
- package/manager.js +1 -1
- package/package.json +27 -93
- package/preset.js +1 -1
- package/dist/chunk-55WZLVGN.mjs +0 -11
- package/dist/chunk-JKRQGT2U.mjs +0 -10
- package/dist/index.mjs +0 -5
- package/dist/node/coverage-reporter.d.ts +0 -184
- package/dist/node/coverage-reporter.mjs +0 -12
- package/dist/node/vitest.d.ts +0 -2
- package/dist/node/vitest.mjs +0 -19
- package/dist/vitest-plugin/global-setup.d.ts +0 -6
- package/dist/vitest-plugin/global-setup.mjs +0 -13
- package/dist/vitest-plugin/index.mjs +0 -28
- package/dist/vitest-plugin/setup-file.d.ts +0 -14
- package/dist/vitest-plugin/setup-file.mjs +0 -9
- package/dist/vitest-plugin/test-utils.d.ts +0 -20
- package/dist/vitest-plugin/test-utils.mjs +0 -8
- package/manager.mjs +0 -1
- package/postinstall.js +0 -1
- package/postinstall.mjs +0 -1
- package/preset.mjs +0 -1
package/dist/node/vitest.js
CHANGED
|
@@ -1,22 +1,876 @@
|
|
|
1
|
-
|
|
1
|
+
import CJS_COMPAT_NODE_URL_nt0sybtpwl from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_nt0sybtpwl from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_nt0sybtpwl from "node:module";
|
|
2
4
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var fs = require('fs');
|
|
7
|
-
var common = require('storybook/internal/common');
|
|
8
|
-
var path2 = require('path');
|
|
9
|
-
var url = require('url');
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_nt0sybtpwl.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_nt0sybtpwl.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_nt0sybtpwl.createRequire(import.meta.url);
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
log
|
|
14
|
+
} from "../_node-chunks/chunk-FJO43W6J.js";
|
|
15
|
+
import {
|
|
16
|
+
errorToErrorLike,
|
|
17
|
+
findUp
|
|
18
|
+
} from "../_node-chunks/chunk-MJKNSUFZ.js";
|
|
19
|
+
import {
|
|
20
|
+
ADDON_ID,
|
|
21
|
+
COVERAGE_DIRECTORY,
|
|
22
|
+
STATUS_TYPE_ID_A11Y,
|
|
23
|
+
STATUS_TYPE_ID_COMPONENT_TEST,
|
|
24
|
+
storeOptions
|
|
25
|
+
} from "../_node-chunks/chunk-75PF53UG.js";
|
|
26
|
+
import "../_node-chunks/chunk-2LKDLHP2.js";
|
|
27
|
+
import {
|
|
28
|
+
dirname,
|
|
29
|
+
join,
|
|
30
|
+
normalize,
|
|
31
|
+
path
|
|
32
|
+
} from "../_node-chunks/chunk-HIDBMPI3.js";
|
|
33
|
+
import {
|
|
34
|
+
__name
|
|
35
|
+
} from "../_node-chunks/chunk-MHHQUJAV.js";
|
|
13
36
|
|
|
14
|
-
|
|
15
|
-
|
|
37
|
+
// src/node/vitest.ts
|
|
38
|
+
import process2 from "node:process";
|
|
39
|
+
import { Channel } from "storybook/internal/channels";
|
|
40
|
+
import {
|
|
41
|
+
experimental_UniversalStore,
|
|
42
|
+
experimental_getStatusStore,
|
|
43
|
+
experimental_getTestProviderStore
|
|
44
|
+
} from "storybook/internal/core-server";
|
|
16
45
|
|
|
17
|
-
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 __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(a,b)=>(typeof require<"u"?require:a)[b]}):x)(function(x){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+x+'" is not supported')});var __commonJS=(cb,mod)=>function(){return mod||(0, cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};var __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};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod));var require_picocolors=__commonJS({"../../node_modules/picocolors/picocolors.js"(exports,module){var p=process||{},argv=p.argv||[],env=p.env||{},isColorSupported=!(env.NO_COLOR||argv.includes("--no-color"))&&(!!env.FORCE_COLOR||argv.includes("--color")||p.platform==="win32"||(p.stdout||{}).isTTY&&env.TERM!=="dumb"||!!env.CI),formatter=(open,close,replace=open)=>input=>{let string=""+input,index=string.indexOf(close,open.length);return ~index?open+replaceClose(string,close,replace,index)+close:open+string+close},replaceClose=(string,close,replace,index)=>{let result="",cursor=0;do result+=string.substring(cursor,index)+replace,cursor=index+close.length,index=string.indexOf(close,cursor);while(~index);return result+string.substring(cursor)},createColors=(enabled=isColorSupported)=>{let f=enabled?formatter:()=>String;return {isColorSupported:enabled,reset:f("\x1B[0m","\x1B[0m"),bold:f("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:f("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:f("\x1B[3m","\x1B[23m"),underline:f("\x1B[4m","\x1B[24m"),inverse:f("\x1B[7m","\x1B[27m"),hidden:f("\x1B[8m","\x1B[28m"),strikethrough:f("\x1B[9m","\x1B[29m"),black:f("\x1B[30m","\x1B[39m"),red:f("\x1B[31m","\x1B[39m"),green:f("\x1B[32m","\x1B[39m"),yellow:f("\x1B[33m","\x1B[39m"),blue:f("\x1B[34m","\x1B[39m"),magenta:f("\x1B[35m","\x1B[39m"),cyan:f("\x1B[36m","\x1B[39m"),white:f("\x1B[37m","\x1B[39m"),gray:f("\x1B[90m","\x1B[39m"),bgBlack:f("\x1B[40m","\x1B[49m"),bgRed:f("\x1B[41m","\x1B[49m"),bgGreen:f("\x1B[42m","\x1B[49m"),bgYellow:f("\x1B[43m","\x1B[49m"),bgBlue:f("\x1B[44m","\x1B[49m"),bgMagenta:f("\x1B[45m","\x1B[49m"),bgCyan:f("\x1B[46m","\x1B[49m"),bgWhite:f("\x1B[47m","\x1B[49m"),blackBright:f("\x1B[90m","\x1B[39m"),redBright:f("\x1B[91m","\x1B[39m"),greenBright:f("\x1B[92m","\x1B[39m"),yellowBright:f("\x1B[93m","\x1B[39m"),blueBright:f("\x1B[94m","\x1B[39m"),magentaBright:f("\x1B[95m","\x1B[39m"),cyanBright:f("\x1B[96m","\x1B[39m"),whiteBright:f("\x1B[97m","\x1B[39m"),bgBlackBright:f("\x1B[100m","\x1B[49m"),bgRedBright:f("\x1B[101m","\x1B[49m"),bgGreenBright:f("\x1B[102m","\x1B[49m"),bgYellowBright:f("\x1B[103m","\x1B[49m"),bgBlueBright:f("\x1B[104m","\x1B[49m"),bgMagentaBright:f("\x1B[105m","\x1B[49m"),bgCyanBright:f("\x1B[106m","\x1B[49m"),bgWhiteBright:f("\x1B[107m","\x1B[49m")}};module.exports=createColors();module.exports.createColors=createColors;}});var ADDON_ID2="storybook/test";var COVERAGE_DIRECTORY="coverage";var storeOptions={id:ADDON_ID2,initialState:{config:{coverage:!1,a11y:!1},watching:!1,cancelling:!1,fatalError:void 0,indexUrl:void 0,previewAnnotations:[],currentRun:{triggeredBy:void 0,config:{coverage:!1,a11y:!1},componentTestCount:{success:0,error:0},a11yCount:{success:0,warning:0,error:0},storyIds:void 0,totalTestCount:void 0,startedAt:void 0,finishedAt:void 0,unhandledErrors:[],coverageSummary:void 0}}};`UNIVERSAL_STORE:${storeOptions.id}`;var STATUS_TYPE_ID_COMPONENT_TEST="storybook/component-test",STATUS_TYPE_ID_A11Y="storybook/a11y";function debounce(func,debounceMs,{signal,edges}={}){let pendingThis,pendingArgs=null,leading=edges!=null&&edges.includes("leading"),trailing=edges==null||edges.includes("trailing"),invoke=()=>{pendingArgs!==null&&(func.apply(pendingThis,pendingArgs),pendingThis=void 0,pendingArgs=null);},onTimerEnd=()=>{trailing&&invoke(),cancel();},timeoutId=null,schedule=()=>{timeoutId!=null&&clearTimeout(timeoutId),timeoutId=setTimeout(()=>{timeoutId=null,onTimerEnd();},debounceMs);},cancelTimer=()=>{timeoutId!==null&&(clearTimeout(timeoutId),timeoutId=null);},cancel=()=>{cancelTimer(),pendingThis=void 0,pendingArgs=null;},flush=()=>{cancelTimer(),invoke();},debounced=function(...args){if(signal?.aborted)return;pendingThis=this,pendingArgs=args;let isFirstCall=timeoutId==null;schedule(),leading&&isFirstCall&&invoke();};return debounced.schedule=schedule,debounced.cancel=cancel,debounced.flush=flush,signal?.addEventListener("abort",cancel,{once:!0}),debounced}function throttle(func,throttleMs,{signal,edges=["leading","trailing"]}={}){let pendingAt=null,debounced=debounce(func,throttleMs,{signal,edges}),throttled=function(...args){pendingAt==null?pendingAt=Date.now():Date.now()-pendingAt>=throttleMs&&(pendingAt=Date.now(),debounced.cancel()),debounced(...args);};return throttled.cancel=debounced.cancel,throttled.flush=debounced.flush,throttled}function errorToErrorLike(error){return {message:error.message,name:error.name,stack:error.stack?.replace(error.message,""),cause:error.cause&&error.cause instanceof Error?errorToErrorLike(error.cause):void 0}}var Node=class{value;next;constructor(value){this.value=value;}},Queue=class{#head;#tail;#size;constructor(){this.clear();}enqueue(value){let node=new Node(value);this.#head?(this.#tail.next=node,this.#tail=node):(this.#head=node,this.#tail=node),this.#size++;}dequeue(){let current=this.#head;if(current)return this.#head=this.#head.next,this.#size--,current.value}peek(){if(this.#head)return this.#head.value}clear(){this.#head=void 0,this.#tail=void 0,this.#size=0;}get size(){return this.#size}*[Symbol.iterator](){let current=this.#head;for(;current;)yield current.value,current=current.next;}*drain(){for(;this.#head;)yield this.dequeue();}};function pLimit(concurrency){if(!((Number.isInteger(concurrency)||concurrency===Number.POSITIVE_INFINITY)&&concurrency>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let queue=new Queue,activeCount=0,next=()=>{activeCount--,queue.size>0&&queue.dequeue()();},run=async(fn,resolve2,args)=>{activeCount++;let result=(async()=>fn(...args))();resolve2(result);try{await result;}catch{}next();},enqueue=(fn,resolve2,args)=>{queue.enqueue(run.bind(void 0,fn,resolve2,args)),(async()=>(await Promise.resolve(),activeCount<concurrency&&queue.size>0&&queue.dequeue()()))();},generator=(fn,...args)=>new Promise(resolve2=>{enqueue(fn,resolve2,args);});return Object.defineProperties(generator,{activeCount:{get:()=>activeCount},pendingCount:{get:()=>queue.size},clearQueue:{value:()=>{queue.clear();}}}),generator}var EndError=class extends Error{constructor(value){super(),this.value=value;}},testElement=async(element,tester)=>tester(await element),finder=async element=>{let values=await Promise.all(element);if(values[1]===!0)throw new EndError(values[0]);return !1};async function pLocate(iterable,tester,{concurrency=Number.POSITIVE_INFINITY,preserveOrder=!0}={}){let limit=pLimit(concurrency),items=[...iterable].map(element=>[element,limit(testElement,element,tester)]),checkLimit=pLimit(preserveOrder?1:Number.POSITIVE_INFINITY);try{await Promise.all(items.map(element=>checkLimit(finder,element)));}catch(error){if(error instanceof EndError)return error.value;throw error}}var typeMappings={directory:"isDirectory",file:"isFile"};function checkType(type){if(!Object.hasOwnProperty.call(typeMappings,type))throw new Error(`Invalid type specified: ${type}`)}var matchType=(type,stat)=>stat[typeMappings[type]](),toPath=urlOrPath=>urlOrPath instanceof URL?url.fileURLToPath(urlOrPath):urlOrPath;async function locatePath(paths,{cwd:cwd2=process3__default.default.cwd(),type="file",allowSymlinks=!0,concurrency,preserveOrder}={}){checkType(type),cwd2=toPath(cwd2);let statFunction=allowSymlinks?fs.promises.stat:fs.promises.lstat;return pLocate(paths,async path_=>{try{let stat=await statFunction(path2__default.default.resolve(cwd2,path_));return matchType(type,stat)}catch{return !1}},{concurrency,preserveOrder})}function toPath2(urlOrPath){return urlOrPath instanceof URL?url.fileURLToPath(urlOrPath):urlOrPath}var findUpStop=Symbol("findUpStop");async function findUpMultiple(name,options={}){let directory=path2__default.default.resolve(toPath2(options.cwd)??""),{root}=path2__default.default.parse(directory),stopAt=path2__default.default.resolve(directory,toPath2(options.stopAt??root)),limit=options.limit??Number.POSITIVE_INFINITY,paths=[name].flat(),runMatcher=async locateOptions=>{if(typeof name!="function")return locatePath(paths,locateOptions);let foundPath=await name(locateOptions.cwd);return typeof foundPath=="string"?locatePath([foundPath],locateOptions):foundPath},matches=[];for(;;){let foundPath=await runMatcher({...options,cwd:directory});if(foundPath===findUpStop||(foundPath&&matches.push(path2__default.default.resolve(directory,foundPath)),directory===stopAt||matches.length>=limit))break;directory=path2__default.default.dirname(directory);}return matches}async function findUp(name,options={}){return (await findUpMultiple(name,{...options,limit:1}))[0]}var _DRIVE_LETTER_START_RE=/^[A-Za-z]:\//;function normalizeWindowsPath(input=""){return input&&input.replace(/\\/g,"/").replace(_DRIVE_LETTER_START_RE,r=>r.toUpperCase())}var _UNC_REGEX=/^[/\\]{2}/,_IS_ABSOLUTE_RE=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,_DRIVE_LETTER_RE=/^[A-Za-z]:$/,_ROOT_FOLDER_RE=/^\/([A-Za-z]:)?$/,sep="/",delimiter=":",normalize=function(path4){if(path4.length===0)return ".";path4=normalizeWindowsPath(path4);let isUNCPath=path4.match(_UNC_REGEX),isPathAbsolute=isAbsolute(path4),trailingSeparator=path4[path4.length-1]==="/";return path4=normalizeString(path4,!isPathAbsolute),path4.length===0?isPathAbsolute?"/":trailingSeparator?"./":".":(trailingSeparator&&(path4+="/"),_DRIVE_LETTER_RE.test(path4)&&(path4+="/"),isUNCPath?isPathAbsolute?`//${path4}`:`//./${path4}`:isPathAbsolute&&!isAbsolute(path4)?`/${path4}`:path4)},join=function(...arguments_){if(arguments_.length===0)return ".";let joined;for(let argument of arguments_)argument&&argument.length>0&&(joined===void 0?joined=argument:joined+=`/${argument}`);return joined===void 0?".":normalize(joined.replace(/\/\/+/g,"/"))};function cwd(){return typeof process<"u"&&typeof process.cwd=="function"?process.cwd().replace(/\\/g,"/"):"/"}var resolve=function(...arguments_){arguments_=arguments_.map(argument=>normalizeWindowsPath(argument));let resolvedPath="",resolvedAbsolute=!1;for(let index=arguments_.length-1;index>=-1&&!resolvedAbsolute;index--){let path4=index>=0?arguments_[index]:cwd();!path4||path4.length===0||(resolvedPath=`${path4}/${resolvedPath}`,resolvedAbsolute=isAbsolute(path4));}return resolvedPath=normalizeString(resolvedPath,!resolvedAbsolute),resolvedAbsolute&&!isAbsolute(resolvedPath)?`/${resolvedPath}`:resolvedPath.length>0?resolvedPath:"."};function normalizeString(path4,allowAboveRoot){let res="",lastSegmentLength=0,lastSlash=-1,dots=0,char=null;for(let index=0;index<=path4.length;++index){if(index<path4.length)char=path4[index];else {if(char==="/")break;char="/";}if(char==="/"){if(!(lastSlash===index-1||dots===1))if(dots===2){if(res.length<2||lastSegmentLength!==2||res[res.length-1]!=="."||res[res.length-2]!=="."){if(res.length>2){let lastSlashIndex=res.lastIndexOf("/");lastSlashIndex===-1?(res="",lastSegmentLength=0):(res=res.slice(0,lastSlashIndex),lastSegmentLength=res.length-1-res.lastIndexOf("/")),lastSlash=index,dots=0;continue}else if(res.length>0){res="",lastSegmentLength=0,lastSlash=index,dots=0;continue}}allowAboveRoot&&(res+=res.length>0?"/..":"..",lastSegmentLength=2);}else res.length>0?res+=`/${path4.slice(lastSlash+1,index)}`:res=path4.slice(lastSlash+1,index),lastSegmentLength=index-lastSlash-1;lastSlash=index,dots=0;}else char==="."&&dots!==-1?++dots:dots=-1;}return res}var isAbsolute=function(p){return _IS_ABSOLUTE_RE.test(p)},toNamespacedPath=function(p){return normalizeWindowsPath(p)},_EXTNAME_RE=/.(\.[^./]+)$/,extname=function(p){let match=_EXTNAME_RE.exec(normalizeWindowsPath(p));return match&&match[1]||""},relative=function(from,to){let _from=resolve(from).replace(_ROOT_FOLDER_RE,"$1").split("/"),_to=resolve(to).replace(_ROOT_FOLDER_RE,"$1").split("/");if(_to[0][1]===":"&&_from[0][1]===":"&&_from[0]!==_to[0])return _to.join("/");let _fromCopy=[..._from];for(let segment of _fromCopy){if(_to[0]!==segment)break;_from.shift(),_to.shift();}return [..._from.map(()=>".."),..._to].join("/")},dirname=function(p){let segments=normalizeWindowsPath(p).replace(/\/$/,"").split("/").slice(0,-1);return segments.length===1&&_DRIVE_LETTER_RE.test(segments[0])&&(segments[0]+="/"),segments.join("/")||(isAbsolute(p)?"/":".")},format=function(p){let segments=[p.root,p.dir,p.base??p.name+p.ext].filter(Boolean);return normalizeWindowsPath(p.root?resolve(...segments):segments.join("/"))},basename=function(p,extension){let lastSegment=normalizeWindowsPath(p).split("/").pop();return extension&&lastSegment.endsWith(extension)?lastSegment.slice(0,-extension.length):lastSegment},parse=function(p){let root=normalizeWindowsPath(p).split("/").shift()||"/",base=basename(p),extension=extname(base);return {root,dir:dirname(p),base,ext:extension,name:base.slice(0,base.length-extension.length)}},path3={__proto__:null,basename,delimiter,dirname,extname,format,isAbsolute,join,normalize,normalizeString,parse,relative,resolve,sep,toNamespacedPath};function slash(path4){return path4.startsWith("\\\\?\\")?path4:path4.replace(/\\/g,"/")}var import_picocolors=__toESM(require_picocolors());var log=message=>{console.log(`${import_picocolors.default.magenta(ADDON_ID2)}: ${message.toString().trim()}`);};var StorybookReporter=class{constructor(testManager){this.testManager=testManager;}onInit(ctx){this.ctx=ctx;}onTestCaseResult(testCase){let{storyId,reports}=testCase.meta(),testResult=testCase.result();this.testManager.onTestCaseResult({storyId,testResult,reports});}async onTestRunEnd(testModules,unhandledErrors){let totalTestCount=testModules.flatMap(t=>Array.from(t.children.allTests("passed")).concat(Array.from(t.children.allTests("failed")))).length,testModulesErrors=testModules.flatMap(t=>t.errors()),serializedErrors=unhandledErrors.concat(testModulesErrors).map(e=>({...e,name:e.name,message:e.message,stack:e.stack?.replace(e.message,""),cause:e.cause}));this.testManager.onTestRunEnd({totalTestCount,unhandledErrors:serializedErrors}),this.clearVitestState();}async clearVitestState(){this.ctx.state.filesMap.clear(),this.ctx.state.pathsSet.clear(),this.ctx.state.idMap.clear(),this.ctx.state.errorsSet.clear(),this.ctx.state.processTimeoutCauses.clear();}};var VITEST_CONFIG_FILE_EXTENSIONS=["mts","mjs","cts","cjs","ts","tsx","js","jsx"],VITEST_WORKSPACE_FILE_EXTENSION=["ts","js","json"],packageDir=dirname(__require.resolve("@storybook/addon-vitest/package.json"));process.env.VITEST_STORYBOOK="true";var VitestManager=class{constructor(testManager){this.testManager=testManager;this.vitest=null;this.vitestStartupCounter=0;this.vitestRestartPromise=null;this.runningPromise=null;}async startVitest({coverage}){let{createVitest}=await import('vitest/node'),storybookCoverageReporter=[join(packageDir,"dist/node/coverage-reporter.js"),{testManager:this.testManager,coverageOptions:this.vitest?.config?.coverage}],coverageOptions=coverage?{enabled:!0,clean:!0,cleanOnRerun:!0,reportOnFailure:!0,reporter:[["html",{}],storybookCoverageReporter],reportsDirectory:common.resolvePathInStorybookCache(COVERAGE_DIRECTORY)}:{enabled:!1},vitestWorkspaceConfig=await findUp([...VITEST_WORKSPACE_FILE_EXTENSION.map(ext=>`vitest.workspace.${ext}`),...VITEST_CONFIG_FILE_EXTENSIONS.map(ext=>`vitest.config.${ext}`)],{stopAt:common.getProjectRoot()}),projectName="storybook:"+process.env.STORYBOOK_CONFIG_DIR;try{this.vitest=await createVitest("test",{root:vitestWorkspaceConfig?dirname(vitestWorkspaceConfig):process.cwd(),watch:!0,passWithNoTests:!1,project:[projectName],reporters:["default",new StorybookReporter(this.testManager)],coverage:coverageOptions});}catch(err){let originalMessage=String(err.message);if(originalMessage.includes("Found multiple projects")){let custom=["Storybook was unable to start the test run because you have multiple Vitest projects (or browsers) in headed mode.","Please set `headless: true` in your Storybook vitest config.\n\n"].join(`
|
|
18
|
-
|
|
46
|
+
// ../../node_modules/es-toolkit/dist/function/debounce.mjs
|
|
47
|
+
function debounce(func, debounceMs, { signal, edges } = {}) {
|
|
48
|
+
let pendingThis = void 0;
|
|
49
|
+
let pendingArgs = null;
|
|
50
|
+
const leading = edges != null && edges.includes("leading");
|
|
51
|
+
const trailing = edges == null || edges.includes("trailing");
|
|
52
|
+
const invoke = /* @__PURE__ */ __name(() => {
|
|
53
|
+
if (pendingArgs !== null) {
|
|
54
|
+
func.apply(pendingThis, pendingArgs);
|
|
55
|
+
pendingThis = void 0;
|
|
56
|
+
pendingArgs = null;
|
|
57
|
+
}
|
|
58
|
+
}, "invoke");
|
|
59
|
+
const onTimerEnd = /* @__PURE__ */ __name(() => {
|
|
60
|
+
if (trailing) {
|
|
61
|
+
invoke();
|
|
62
|
+
}
|
|
63
|
+
cancel();
|
|
64
|
+
}, "onTimerEnd");
|
|
65
|
+
let timeoutId = null;
|
|
66
|
+
const schedule = /* @__PURE__ */ __name(() => {
|
|
67
|
+
if (timeoutId != null) {
|
|
68
|
+
clearTimeout(timeoutId);
|
|
69
|
+
}
|
|
70
|
+
timeoutId = setTimeout(() => {
|
|
71
|
+
timeoutId = null;
|
|
72
|
+
onTimerEnd();
|
|
73
|
+
}, debounceMs);
|
|
74
|
+
}, "schedule");
|
|
75
|
+
const cancelTimer = /* @__PURE__ */ __name(() => {
|
|
76
|
+
if (timeoutId !== null) {
|
|
77
|
+
clearTimeout(timeoutId);
|
|
78
|
+
timeoutId = null;
|
|
79
|
+
}
|
|
80
|
+
}, "cancelTimer");
|
|
81
|
+
const cancel = /* @__PURE__ */ __name(() => {
|
|
82
|
+
cancelTimer();
|
|
83
|
+
pendingThis = void 0;
|
|
84
|
+
pendingArgs = null;
|
|
85
|
+
}, "cancel");
|
|
86
|
+
const flush = /* @__PURE__ */ __name(() => {
|
|
87
|
+
cancelTimer();
|
|
88
|
+
invoke();
|
|
89
|
+
}, "flush");
|
|
90
|
+
const debounced = /* @__PURE__ */ __name(function(...args) {
|
|
91
|
+
if (signal?.aborted) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
pendingThis = this;
|
|
95
|
+
pendingArgs = args;
|
|
96
|
+
const isFirstCall = timeoutId == null;
|
|
97
|
+
schedule();
|
|
98
|
+
if (leading && isFirstCall) {
|
|
99
|
+
invoke();
|
|
100
|
+
}
|
|
101
|
+
}, "debounced");
|
|
102
|
+
debounced.schedule = schedule;
|
|
103
|
+
debounced.cancel = cancel;
|
|
104
|
+
debounced.flush = flush;
|
|
105
|
+
signal?.addEventListener("abort", cancel, { once: true });
|
|
106
|
+
return debounced;
|
|
107
|
+
}
|
|
108
|
+
__name(debounce, "debounce");
|
|
19
109
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
110
|
+
// ../../node_modules/es-toolkit/dist/function/partial.mjs
|
|
111
|
+
function partial(func, ...partialArgs) {
|
|
112
|
+
return partialImpl(func, placeholderSymbol, ...partialArgs);
|
|
113
|
+
}
|
|
114
|
+
__name(partial, "partial");
|
|
115
|
+
function partialImpl(func, placeholder, ...partialArgs) {
|
|
116
|
+
const partialed = /* @__PURE__ */ __name(function(...providedArgs) {
|
|
117
|
+
let providedArgsIndex = 0;
|
|
118
|
+
const substitutedArgs = partialArgs.slice().map((arg) => arg === placeholder ? providedArgs[providedArgsIndex++] : arg);
|
|
119
|
+
const remainingArgs = providedArgs.slice(providedArgsIndex);
|
|
120
|
+
return func.apply(this, substitutedArgs.concat(remainingArgs));
|
|
121
|
+
}, "partialed");
|
|
122
|
+
if (func.prototype) {
|
|
123
|
+
partialed.prototype = Object.create(func.prototype);
|
|
124
|
+
}
|
|
125
|
+
return partialed;
|
|
126
|
+
}
|
|
127
|
+
__name(partialImpl, "partialImpl");
|
|
128
|
+
var placeholderSymbol = Symbol("partial.placeholder");
|
|
129
|
+
partial.placeholder = placeholderSymbol;
|
|
130
|
+
|
|
131
|
+
// ../../node_modules/es-toolkit/dist/function/partialRight.mjs
|
|
132
|
+
function partialRight(func, ...partialArgs) {
|
|
133
|
+
return partialRightImpl(func, placeholderSymbol2, ...partialArgs);
|
|
134
|
+
}
|
|
135
|
+
__name(partialRight, "partialRight");
|
|
136
|
+
function partialRightImpl(func, placeholder, ...partialArgs) {
|
|
137
|
+
const partialedRight = /* @__PURE__ */ __name(function(...providedArgs) {
|
|
138
|
+
const placeholderLength = partialArgs.filter((arg) => arg === placeholder).length;
|
|
139
|
+
const rangeLength = Math.max(providedArgs.length - placeholderLength, 0);
|
|
140
|
+
const remainingArgs = providedArgs.slice(0, rangeLength);
|
|
141
|
+
let providedArgsIndex = rangeLength;
|
|
142
|
+
const substitutedArgs = partialArgs.slice().map((arg) => arg === placeholder ? providedArgs[providedArgsIndex++] : arg);
|
|
143
|
+
return func.apply(this, remainingArgs.concat(substitutedArgs));
|
|
144
|
+
}, "partialedRight");
|
|
145
|
+
if (func.prototype) {
|
|
146
|
+
partialedRight.prototype = Object.create(func.prototype);
|
|
147
|
+
}
|
|
148
|
+
return partialedRight;
|
|
149
|
+
}
|
|
150
|
+
__name(partialRightImpl, "partialRightImpl");
|
|
151
|
+
var placeholderSymbol2 = Symbol("partialRight.placeholder");
|
|
152
|
+
partialRight.placeholder = placeholderSymbol2;
|
|
153
|
+
|
|
154
|
+
// ../../node_modules/es-toolkit/dist/function/retry.mjs
|
|
155
|
+
var DEFAULT_RETRIES = Number.POSITIVE_INFINITY;
|
|
156
|
+
|
|
157
|
+
// ../../node_modules/es-toolkit/dist/function/throttle.mjs
|
|
158
|
+
function throttle(func, throttleMs, { signal, edges = ["leading", "trailing"] } = {}) {
|
|
159
|
+
let pendingAt = null;
|
|
160
|
+
const debounced = debounce(func, throttleMs, { signal, edges });
|
|
161
|
+
const throttled = /* @__PURE__ */ __name(function(...args) {
|
|
162
|
+
if (pendingAt == null) {
|
|
163
|
+
pendingAt = Date.now();
|
|
164
|
+
} else {
|
|
165
|
+
if (Date.now() - pendingAt >= throttleMs) {
|
|
166
|
+
pendingAt = Date.now();
|
|
167
|
+
debounced.cancel();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
debounced(...args);
|
|
171
|
+
}, "throttled");
|
|
172
|
+
throttled.cancel = debounced.cancel;
|
|
173
|
+
throttled.flush = debounced.flush;
|
|
174
|
+
return throttled;
|
|
175
|
+
}
|
|
176
|
+
__name(throttle, "throttle");
|
|
177
|
+
|
|
178
|
+
// src/node/vitest-manager.ts
|
|
179
|
+
import { existsSync } from "node:fs";
|
|
180
|
+
import { getProjectRoot, resolvePathInStorybookCache } from "storybook/internal/common";
|
|
181
|
+
|
|
182
|
+
// ../../node_modules/slash/index.js
|
|
183
|
+
function slash(path2) {
|
|
184
|
+
const isExtendedLengthPath = path2.startsWith("\\\\?\\");
|
|
185
|
+
if (isExtendedLengthPath) {
|
|
186
|
+
return path2;
|
|
187
|
+
}
|
|
188
|
+
return path2.replace(/\\/g, "/");
|
|
189
|
+
}
|
|
190
|
+
__name(slash, "slash");
|
|
191
|
+
|
|
192
|
+
// src/node/reporter.ts
|
|
193
|
+
var StorybookReporter = class {
|
|
194
|
+
constructor(testManager) {
|
|
195
|
+
this.testManager = testManager;
|
|
196
|
+
}
|
|
197
|
+
static {
|
|
198
|
+
__name(this, "StorybookReporter");
|
|
199
|
+
}
|
|
200
|
+
onInit(ctx) {
|
|
201
|
+
this.ctx = ctx;
|
|
202
|
+
}
|
|
203
|
+
onTestCaseResult(testCase) {
|
|
204
|
+
const { storyId, reports } = testCase.meta();
|
|
205
|
+
const testResult = testCase.result();
|
|
206
|
+
this.testManager.onTestCaseResult({
|
|
207
|
+
storyId,
|
|
208
|
+
testResult,
|
|
209
|
+
reports
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
async onTestRunEnd(testModules, unhandledErrors) {
|
|
213
|
+
const totalTestCount = testModules.flatMap(
|
|
214
|
+
(t) => Array.from(t.children.allTests("passed")).concat(Array.from(t.children.allTests("failed")))
|
|
215
|
+
).length;
|
|
216
|
+
const testModulesErrors = testModules.flatMap((t) => t.errors());
|
|
217
|
+
const serializedErrors = unhandledErrors.concat(testModulesErrors).map((e) => {
|
|
218
|
+
return {
|
|
219
|
+
...e,
|
|
220
|
+
name: e.name,
|
|
221
|
+
message: e.message,
|
|
222
|
+
stack: e.stack?.replace(e.message, ""),
|
|
223
|
+
cause: e.cause
|
|
224
|
+
};
|
|
225
|
+
});
|
|
226
|
+
this.testManager.onTestRunEnd({
|
|
227
|
+
totalTestCount,
|
|
228
|
+
unhandledErrors: serializedErrors
|
|
229
|
+
});
|
|
230
|
+
this.clearVitestState();
|
|
231
|
+
}
|
|
232
|
+
// TODO: Clearing the whole internal state of Vitest might be too aggressive
|
|
233
|
+
async clearVitestState() {
|
|
234
|
+
this.ctx.state.filesMap.clear();
|
|
235
|
+
this.ctx.state.pathsSet.clear();
|
|
236
|
+
this.ctx.state.idMap.clear();
|
|
237
|
+
this.ctx.state.errorsSet.clear();
|
|
238
|
+
this.ctx.state.processTimeoutCauses.clear();
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// src/node/vitest-manager.ts
|
|
243
|
+
var VITEST_CONFIG_FILE_EXTENSIONS = ["mts", "mjs", "cts", "cjs", "ts", "tsx", "js", "jsx"];
|
|
244
|
+
var VITEST_WORKSPACE_FILE_EXTENSION = ["ts", "js", "json"];
|
|
245
|
+
process.env.VITEST_STORYBOOK = "true";
|
|
246
|
+
var VitestManager = class {
|
|
247
|
+
constructor(testManager) {
|
|
248
|
+
this.testManager = testManager;
|
|
249
|
+
this.vitest = null;
|
|
250
|
+
this.vitestStartupCounter = 0;
|
|
251
|
+
this.vitestRestartPromise = null;
|
|
252
|
+
this.runningPromise = null;
|
|
253
|
+
}
|
|
254
|
+
static {
|
|
255
|
+
__name(this, "VitestManager");
|
|
256
|
+
}
|
|
257
|
+
async startVitest({ coverage }) {
|
|
258
|
+
const { createVitest } = await import("vitest/node");
|
|
259
|
+
const storybookCoverageReporter = [
|
|
260
|
+
"@storybook/addon-vitest/internal/coverage-reporter",
|
|
261
|
+
{
|
|
262
|
+
testManager: this.testManager,
|
|
263
|
+
coverageOptions: this.vitest?.config?.coverage
|
|
264
|
+
}
|
|
265
|
+
];
|
|
266
|
+
const coverageOptions = coverage ? {
|
|
267
|
+
enabled: true,
|
|
268
|
+
clean: true,
|
|
269
|
+
cleanOnRerun: true,
|
|
270
|
+
reportOnFailure: true,
|
|
271
|
+
reporter: [["html", {}], storybookCoverageReporter],
|
|
272
|
+
reportsDirectory: resolvePathInStorybookCache(COVERAGE_DIRECTORY)
|
|
273
|
+
} : { enabled: false };
|
|
274
|
+
const vitestWorkspaceConfig = await findUp(
|
|
275
|
+
[
|
|
276
|
+
...VITEST_WORKSPACE_FILE_EXTENSION.map((ext) => `vitest.workspace.${ext}`),
|
|
277
|
+
...VITEST_CONFIG_FILE_EXTENSIONS.map((ext) => `vitest.config.${ext}`)
|
|
278
|
+
],
|
|
279
|
+
{ stopAt: getProjectRoot() }
|
|
280
|
+
);
|
|
281
|
+
const projectName = "storybook:" + process.env.STORYBOOK_CONFIG_DIR;
|
|
282
|
+
try {
|
|
283
|
+
this.vitest = await createVitest("test", {
|
|
284
|
+
root: vitestWorkspaceConfig ? dirname(vitestWorkspaceConfig) : process.cwd(),
|
|
285
|
+
watch: true,
|
|
286
|
+
passWithNoTests: false,
|
|
287
|
+
project: [projectName],
|
|
288
|
+
// TODO:
|
|
289
|
+
// Do we want to enable Vite's default reporter?
|
|
290
|
+
// The output in the terminal might be too spamy and it might be better to
|
|
291
|
+
// find a way to just show errors and warnings for example
|
|
292
|
+
// Otherwise it might be hard for the user to discover Storybook related logs
|
|
293
|
+
reporters: ["default", new StorybookReporter(this.testManager)],
|
|
294
|
+
coverage: coverageOptions
|
|
295
|
+
});
|
|
296
|
+
} catch (err) {
|
|
297
|
+
const originalMessage = String(err.message);
|
|
298
|
+
if (originalMessage.includes("Found multiple projects")) {
|
|
299
|
+
const custom = [
|
|
300
|
+
"Storybook was unable to start the test run because you have multiple Vitest projects (or browsers) in headed mode.",
|
|
301
|
+
"Please set `headless: true` in your Storybook vitest config.\n\n"
|
|
302
|
+
].join("\n");
|
|
303
|
+
if (!originalMessage.startsWith(custom)) {
|
|
304
|
+
err.message = `${custom}${originalMessage}`;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
throw err;
|
|
308
|
+
}
|
|
309
|
+
if (this.vitest) {
|
|
310
|
+
this.vitest.onCancel(() => {
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
try {
|
|
314
|
+
await this.vitest.init();
|
|
315
|
+
} catch (e) {
|
|
316
|
+
let message = "Failed to initialize Vitest";
|
|
317
|
+
const isV8 = e.message?.includes("@vitest/coverage-v8");
|
|
318
|
+
const isIstanbul = e.message?.includes("@vitest/coverage-istanbul");
|
|
319
|
+
if (e.message?.includes("Failed to load url") && (isIstanbul || isV8) || // Vitest will sometimes not throw the correct missing-package-detection error, so we have to check for this as well
|
|
320
|
+
e instanceof TypeError && e?.message === "Cannot read properties of undefined (reading 'name')") {
|
|
321
|
+
const coveragePackage = isIstanbul ? "coverage-istanbul" : "coverage-v8";
|
|
322
|
+
message += `
|
|
323
|
+
|
|
324
|
+
Please install the @vitest/${coveragePackage} package to collect coverage
|
|
325
|
+
`;
|
|
326
|
+
}
|
|
327
|
+
this.testManager.reportFatalError(message, e);
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
await this.setupWatchers();
|
|
331
|
+
}
|
|
332
|
+
async restartVitest({ coverage }) {
|
|
333
|
+
await this.vitestRestartPromise;
|
|
334
|
+
this.vitestRestartPromise = new Promise(async (resolve, reject) => {
|
|
335
|
+
try {
|
|
336
|
+
await this.runningPromise;
|
|
337
|
+
await this.vitest?.close();
|
|
338
|
+
await this.startVitest({ coverage });
|
|
339
|
+
resolve();
|
|
340
|
+
} catch (e) {
|
|
341
|
+
reject(e);
|
|
342
|
+
} finally {
|
|
343
|
+
this.vitestRestartPromise = null;
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
return this.vitestRestartPromise;
|
|
347
|
+
}
|
|
348
|
+
resetGlobalTestNamePattern() {
|
|
349
|
+
this.vitest?.setGlobalTestNamePattern("");
|
|
350
|
+
}
|
|
351
|
+
updateLastChanged(filepath) {
|
|
352
|
+
const projects = this.vitest.getModuleProjects(filepath);
|
|
353
|
+
projects.forEach(({ server, browser }) => {
|
|
354
|
+
if (server) {
|
|
355
|
+
const serverMods = server.moduleGraph.getModulesByFile(filepath);
|
|
356
|
+
serverMods?.forEach((mod) => server.moduleGraph.invalidateModule(mod));
|
|
357
|
+
}
|
|
358
|
+
if (browser) {
|
|
359
|
+
const browserMods = browser.vite.moduleGraph.getModulesByFile(filepath);
|
|
360
|
+
browserMods?.forEach((mod) => browser.vite.moduleGraph.invalidateModule(mod));
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
async fetchStories(requestStoryIds) {
|
|
365
|
+
const indexUrl = this.testManager.store.getState().indexUrl;
|
|
366
|
+
if (!indexUrl) {
|
|
367
|
+
throw new Error(
|
|
368
|
+
"Tried to fetch stories to test, but the index URL was not set in the store yet."
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
try {
|
|
372
|
+
const index = await Promise.race([
|
|
373
|
+
fetch(indexUrl).then((res) => res.json()),
|
|
374
|
+
new Promise((_, reject) => setTimeout(reject, 3e3, new Error("Request took too long")))
|
|
375
|
+
]);
|
|
376
|
+
const storyIds = requestStoryIds || Object.keys(index.entries);
|
|
377
|
+
return storyIds.map((id) => index.entries[id]).filter((story) => story.type === "story");
|
|
378
|
+
} catch (e) {
|
|
379
|
+
log("Failed to fetch story index: " + e.message);
|
|
380
|
+
return [];
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
filterTestSpecifications(testSpecifications, stories) {
|
|
384
|
+
const filteredTestSpecifications = [];
|
|
385
|
+
const filteredStoryIds = [];
|
|
386
|
+
const storiesByImportPath = {};
|
|
387
|
+
for (const story of stories) {
|
|
388
|
+
const absoluteImportPath = path.join(process.cwd(), story.importPath);
|
|
389
|
+
if (!storiesByImportPath[absoluteImportPath]) {
|
|
390
|
+
storiesByImportPath[absoluteImportPath] = [];
|
|
391
|
+
}
|
|
392
|
+
storiesByImportPath[absoluteImportPath].push(story);
|
|
393
|
+
}
|
|
394
|
+
for (const testSpecification of testSpecifications) {
|
|
395
|
+
const { env = {} } = testSpecification.project.config;
|
|
396
|
+
const include = env.__VITEST_INCLUDE_TAGS__?.split(",").filter(Boolean) ?? ["test"];
|
|
397
|
+
const exclude = env.__VITEST_EXCLUDE_TAGS__?.split(",").filter(Boolean) ?? [];
|
|
398
|
+
const skip = env.__VITEST_SKIP_TAGS__?.split(",").filter(Boolean) ?? [];
|
|
399
|
+
const storiesInTestSpecification = storiesByImportPath[testSpecification.moduleId] ?? [];
|
|
400
|
+
const filteredStories = storiesInTestSpecification.filter((story) => {
|
|
401
|
+
if (include.length && !include.some((tag) => story.tags?.includes(tag))) {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
if (exclude.some((tag) => story.tags?.includes(tag))) {
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
return true;
|
|
408
|
+
});
|
|
409
|
+
if (!filteredStories.length) {
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
if (!this.testManager.store.getState().watching) {
|
|
413
|
+
this.updateLastChanged(testSpecification.moduleId);
|
|
414
|
+
}
|
|
415
|
+
filteredTestSpecifications.push(testSpecification);
|
|
416
|
+
filteredStoryIds.push(
|
|
417
|
+
...filteredStories.filter((story) => !skip.some((tag) => story.tags?.includes(tag))).map((story) => story.id)
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
return { filteredTestSpecifications, filteredStoryIds };
|
|
421
|
+
}
|
|
422
|
+
async runTests(runPayload) {
|
|
423
|
+
const { watching, config } = this.testManager.store.getState();
|
|
424
|
+
const coverageShouldBeEnabled = config.coverage && !watching && (runPayload?.storyIds?.length ?? 0) === 0;
|
|
425
|
+
const currentCoverage = this.vitest?.config.coverage?.enabled;
|
|
426
|
+
if (!this.vitest) {
|
|
427
|
+
await this.startVitest({ coverage: coverageShouldBeEnabled });
|
|
428
|
+
} else if (currentCoverage !== coverageShouldBeEnabled) {
|
|
429
|
+
await this.restartVitest({ coverage: coverageShouldBeEnabled });
|
|
430
|
+
} else {
|
|
431
|
+
await this.vitestRestartPromise;
|
|
432
|
+
}
|
|
433
|
+
this.resetGlobalTestNamePattern();
|
|
434
|
+
await this.cancelCurrentRun();
|
|
435
|
+
const testSpecifications = await this.getStorybookTestSpecifications();
|
|
436
|
+
const stories = await this.fetchStories(runPayload?.storyIds);
|
|
437
|
+
const isSingleStoryRun = runPayload.storyIds?.length === 1;
|
|
438
|
+
if (isSingleStoryRun) {
|
|
439
|
+
const storyName = stories[0].name;
|
|
440
|
+
const regex = new RegExp(`^${storyName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`);
|
|
441
|
+
this.vitest.setGlobalTestNamePattern(regex);
|
|
442
|
+
}
|
|
443
|
+
const { filteredTestSpecifications, filteredStoryIds } = this.filterTestSpecifications(
|
|
444
|
+
testSpecifications,
|
|
445
|
+
stories
|
|
446
|
+
);
|
|
447
|
+
this.testManager.store.setState((s) => ({
|
|
448
|
+
...s,
|
|
449
|
+
currentRun: {
|
|
450
|
+
...s.currentRun,
|
|
451
|
+
totalTestCount: filteredStoryIds.length
|
|
452
|
+
}
|
|
453
|
+
}));
|
|
454
|
+
await this.vitest.runTestSpecifications(filteredTestSpecifications, true);
|
|
455
|
+
this.resetGlobalTestNamePattern();
|
|
456
|
+
}
|
|
457
|
+
async cancelCurrentRun() {
|
|
458
|
+
await this.vitest?.cancelCurrentRun("keyboard-input");
|
|
459
|
+
await this.runningPromise;
|
|
460
|
+
}
|
|
461
|
+
async getStorybookTestSpecifications() {
|
|
462
|
+
const globTestSpecifications = await this.vitest?.globTestSpecifications() ?? [];
|
|
463
|
+
return globTestSpecifications.filter(
|
|
464
|
+
(workspaceSpec) => this.isStorybookProject(workspaceSpec.project)
|
|
465
|
+
) ?? [];
|
|
466
|
+
}
|
|
467
|
+
async runAffectedTestsAfterChange(changedFilePath, event) {
|
|
468
|
+
const id = slash(changedFilePath);
|
|
469
|
+
this.vitest?.logger.clearHighlightCache(id);
|
|
470
|
+
this.updateLastChanged(id);
|
|
471
|
+
if (event === "add") {
|
|
472
|
+
const project = this.vitest?.projects.find(this.isStorybookProject.bind(this));
|
|
473
|
+
project?.matchesTestGlob(id);
|
|
474
|
+
}
|
|
475
|
+
if (!this.testManager.store.getState().watching) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
if (!this.vitest) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
this.resetGlobalTestNamePattern();
|
|
482
|
+
const storybookProject = this.vitest.projects.find((p) => this.isStorybookProject(p));
|
|
483
|
+
const previewAnnotationSpecifications = this.testManager.store.getState().previewAnnotations.map((previewAnnotation) => {
|
|
484
|
+
return {
|
|
485
|
+
project: storybookProject ?? this.vitest.projects[0],
|
|
486
|
+
moduleId: typeof previewAnnotation === "string" ? previewAnnotation : previewAnnotation.absolute
|
|
487
|
+
};
|
|
488
|
+
});
|
|
489
|
+
const setupFilesSpecifications = this.vitest.projects.flatMap(
|
|
490
|
+
(project) => project.config.setupFiles.map((setupFile) => ({
|
|
491
|
+
project,
|
|
492
|
+
moduleId: setupFile
|
|
493
|
+
}))
|
|
494
|
+
);
|
|
495
|
+
const syntheticGlobalTestSpecifications = previewAnnotationSpecifications.concat(setupFilesSpecifications);
|
|
496
|
+
const testSpecifications = await this.getStorybookTestSpecifications();
|
|
497
|
+
const allStories = await this.fetchStories();
|
|
498
|
+
let affectsGlobalFiles = false;
|
|
499
|
+
const affectedTestSpecifications = (await Promise.all(
|
|
500
|
+
syntheticGlobalTestSpecifications.concat(testSpecifications).map(async (testSpecification) => {
|
|
501
|
+
const dependencies = await this.getTestDependencies(testSpecification);
|
|
502
|
+
if (changedFilePath === testSpecification.moduleId || dependencies.has(changedFilePath)) {
|
|
503
|
+
if (syntheticGlobalTestSpecifications.includes(testSpecification)) {
|
|
504
|
+
affectsGlobalFiles = true;
|
|
505
|
+
}
|
|
506
|
+
return testSpecification;
|
|
507
|
+
}
|
|
508
|
+
})
|
|
509
|
+
)).filter(Boolean);
|
|
510
|
+
const testSpecificationsToRun = affectsGlobalFiles ? testSpecifications : affectedTestSpecifications;
|
|
511
|
+
if (!testSpecificationsToRun.length) {
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
const { filteredTestSpecifications, filteredStoryIds } = this.filterTestSpecifications(
|
|
515
|
+
testSpecificationsToRun,
|
|
516
|
+
allStories
|
|
517
|
+
);
|
|
518
|
+
await this.testManager.runTestsWithState({
|
|
519
|
+
storyIds: filteredStoryIds,
|
|
520
|
+
triggeredBy: "watch",
|
|
521
|
+
callback: /* @__PURE__ */ __name(async () => {
|
|
522
|
+
this.testManager.store.setState((s) => ({
|
|
523
|
+
...s,
|
|
524
|
+
currentRun: {
|
|
525
|
+
...s.currentRun,
|
|
526
|
+
totalTestCount: filteredStoryIds.length
|
|
527
|
+
}
|
|
528
|
+
}));
|
|
529
|
+
await this.vitest.cancelCurrentRun("keyboard-input");
|
|
530
|
+
await this.runningPromise;
|
|
531
|
+
await this.vitest.runTestSpecifications(filteredTestSpecifications, false);
|
|
532
|
+
}, "callback")
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
// This is an adaptation of Vitest's own implementation
|
|
536
|
+
// see https://github.com/vitest-dev/vitest/blob/14409088166152c920ce7fa4ad4c0ba57149b869/packages/vitest/src/node/specifications.ts#L171-L198
|
|
537
|
+
async getTestDependencies(spec) {
|
|
538
|
+
const deps = /* @__PURE__ */ new Set();
|
|
539
|
+
const addImports = /* @__PURE__ */ __name(async (project, filepath) => {
|
|
540
|
+
if (deps.has(filepath)) {
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
deps.add(filepath);
|
|
544
|
+
const mod = project.vite.moduleGraph.getModuleById(filepath);
|
|
545
|
+
const transformed = mod?.ssrTransformResult || await project.vite.transformRequest(filepath, { ssr: true });
|
|
546
|
+
if (!transformed) {
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
const dependencies = [...transformed.deps ?? [], ...transformed.dynamicDeps ?? []];
|
|
550
|
+
await Promise.all(
|
|
551
|
+
dependencies.map(async (dep) => {
|
|
552
|
+
const fsPath = dep.startsWith("/@fs/") ? dep.slice(process.platform === "win32" ? 5 : 4) : join(project.config.root, dep);
|
|
553
|
+
if (!fsPath.includes("node_modules") && !deps.has(fsPath) && existsSync(fsPath)) {
|
|
554
|
+
await addImports(project, fsPath);
|
|
555
|
+
}
|
|
556
|
+
})
|
|
557
|
+
);
|
|
558
|
+
}, "addImports");
|
|
559
|
+
await addImports(spec.project, spec.moduleId);
|
|
560
|
+
deps.delete(spec.moduleId);
|
|
561
|
+
return deps;
|
|
562
|
+
}
|
|
563
|
+
async registerVitestConfigListener() {
|
|
564
|
+
this.vitest.vite.watcher.on("change", async (file) => {
|
|
565
|
+
const isConfig = normalize(file) === this.vitest?.vite?.config.configFile;
|
|
566
|
+
if (isConfig) {
|
|
567
|
+
log("Restarting Vitest due to config change");
|
|
568
|
+
const { watching, config } = this.testManager.store.getState();
|
|
569
|
+
await this.restartVitest({ coverage: config.coverage && !watching });
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
async setupWatchers() {
|
|
574
|
+
this.resetGlobalTestNamePattern();
|
|
575
|
+
this.vitest.vite.watcher.removeAllListeners("change");
|
|
576
|
+
this.vitest.vite.watcher.removeAllListeners("add");
|
|
577
|
+
this.vitest.vite.watcher.on(
|
|
578
|
+
"change",
|
|
579
|
+
(file) => this.runAffectedTestsAfterChange(file, "change")
|
|
580
|
+
);
|
|
581
|
+
this.vitest.vite.watcher.on("add", (file) => {
|
|
582
|
+
this.runAffectedTestsAfterChange(file, "add");
|
|
583
|
+
});
|
|
584
|
+
this.registerVitestConfigListener();
|
|
585
|
+
}
|
|
586
|
+
isStorybookProject(project) {
|
|
587
|
+
return !!project.config.env?.__STORYBOOK_URL__;
|
|
588
|
+
}
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
// src/node/test-manager.ts
|
|
592
|
+
var testStateToStatusValueMap = {
|
|
593
|
+
pending: "status-value:pending",
|
|
594
|
+
passed: "status-value:success",
|
|
595
|
+
warning: "status-value:warning",
|
|
596
|
+
failed: "status-value:error",
|
|
597
|
+
skipped: "status-value:unknown"
|
|
598
|
+
};
|
|
599
|
+
var TestManager = class _TestManager {
|
|
600
|
+
constructor(options) {
|
|
601
|
+
this.batchedTestCaseResults = [];
|
|
602
|
+
/**
|
|
603
|
+
* Throttled function to process batched test case results.
|
|
604
|
+
*
|
|
605
|
+
* This function:
|
|
606
|
+
*
|
|
607
|
+
* 1. Takes all batched test case results and clears the batch
|
|
608
|
+
* 2. Updates the store state with new test counts (component tests and a11y tests)
|
|
609
|
+
* 3. Adjusts the totalTestCount if more tests were run than initially anticipated
|
|
610
|
+
* 4. Creates status objects for component tests and updates the component test status store
|
|
611
|
+
* 5. Creates status objects for a11y tests (if any) and updates the a11y status store
|
|
612
|
+
*
|
|
613
|
+
* The throttling (500ms) is necessary as the channel would otherwise get overwhelmed with events,
|
|
614
|
+
* eventually causing the manager and dev server to lose connection.
|
|
615
|
+
*/
|
|
616
|
+
this.throttledFlushTestCaseResults = throttle(() => {
|
|
617
|
+
const testCaseResultsToFlush = this.batchedTestCaseResults;
|
|
618
|
+
this.batchedTestCaseResults = [];
|
|
619
|
+
this.store.setState((s) => {
|
|
620
|
+
let { success: ctSuccess, error: ctError } = s.currentRun.componentTestCount;
|
|
621
|
+
let { success: a11ySuccess, warning: a11yWarning, error: a11yError } = s.currentRun.a11yCount;
|
|
622
|
+
testCaseResultsToFlush.forEach(({ testResult, reports }) => {
|
|
623
|
+
if (testResult.state === "passed") {
|
|
624
|
+
ctSuccess++;
|
|
625
|
+
} else if (testResult.state === "failed") {
|
|
626
|
+
ctError++;
|
|
627
|
+
}
|
|
628
|
+
reports?.filter((r) => r.type === "a11y").forEach((report) => {
|
|
629
|
+
if (report.status === "passed") {
|
|
630
|
+
a11ySuccess++;
|
|
631
|
+
} else if (report.status === "warning") {
|
|
632
|
+
a11yWarning++;
|
|
633
|
+
} else if (report.status === "failed") {
|
|
634
|
+
a11yError++;
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
});
|
|
638
|
+
const finishedTestCount = ctSuccess + ctError;
|
|
639
|
+
return {
|
|
640
|
+
...s,
|
|
641
|
+
currentRun: {
|
|
642
|
+
...s.currentRun,
|
|
643
|
+
componentTestCount: { success: ctSuccess, error: ctError },
|
|
644
|
+
a11yCount: { success: a11ySuccess, warning: a11yWarning, error: a11yError },
|
|
645
|
+
// in some cases successes and errors can exceed the anticipated totalTestCount
|
|
646
|
+
// e.g. when testing more tests than the stories we know about upfront
|
|
647
|
+
// in those cases, we set the totalTestCount to the sum of successes and errors
|
|
648
|
+
totalTestCount: finishedTestCount > (s.currentRun.totalTestCount ?? 0) ? finishedTestCount : s.currentRun.totalTestCount
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
});
|
|
652
|
+
const componentTestStatuses = testCaseResultsToFlush.map(({ storyId, testResult }) => ({
|
|
653
|
+
storyId,
|
|
654
|
+
typeId: STATUS_TYPE_ID_COMPONENT_TEST,
|
|
655
|
+
value: testStateToStatusValueMap[testResult.state],
|
|
656
|
+
title: "Component tests",
|
|
657
|
+
description: testResult.errors?.map((error) => error.stack || error.message).join("\n") ?? "",
|
|
658
|
+
sidebarContextMenu: false
|
|
659
|
+
}));
|
|
660
|
+
this.componentTestStatusStore.set(componentTestStatuses);
|
|
661
|
+
const a11yStatuses = testCaseResultsToFlush.flatMap(
|
|
662
|
+
({ storyId, reports }) => reports?.filter((r) => r.type === "a11y").map((a11yReport) => ({
|
|
663
|
+
storyId,
|
|
664
|
+
typeId: STATUS_TYPE_ID_A11Y,
|
|
665
|
+
value: testStateToStatusValueMap[a11yReport.status],
|
|
666
|
+
title: "Accessibility tests",
|
|
667
|
+
description: "",
|
|
668
|
+
sidebarContextMenu: false
|
|
669
|
+
}))
|
|
670
|
+
).filter((a11yStatus) => a11yStatus !== void 0);
|
|
671
|
+
if (a11yStatuses.length > 0) {
|
|
672
|
+
this.a11yStatusStore.set(a11yStatuses);
|
|
673
|
+
}
|
|
674
|
+
}, 500);
|
|
675
|
+
this.store = options.store;
|
|
676
|
+
this.componentTestStatusStore = options.componentTestStatusStore;
|
|
677
|
+
this.a11yStatusStore = options.a11yStatusStore;
|
|
678
|
+
this.testProviderStore = options.testProviderStore;
|
|
679
|
+
this.onReady = options.onReady;
|
|
680
|
+
this.storybookOptions = options.storybookOptions;
|
|
681
|
+
this.vitestManager = new VitestManager(this);
|
|
682
|
+
this.store.subscribe("TRIGGER_RUN", this.handleTriggerRunEvent.bind(this));
|
|
683
|
+
this.store.subscribe("CANCEL_RUN", this.handleCancelEvent.bind(this));
|
|
684
|
+
this.store.untilReady().then(() => {
|
|
685
|
+
return this.vitestManager.startVitest({ coverage: this.store.getState().config.coverage });
|
|
686
|
+
}).then(() => this.onReady?.()).catch((e) => {
|
|
687
|
+
this.reportFatalError("Failed to start Vitest", e);
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
static {
|
|
691
|
+
__name(this, "TestManager");
|
|
692
|
+
}
|
|
693
|
+
async handleTriggerRunEvent(event) {
|
|
694
|
+
await this.runTestsWithState({
|
|
695
|
+
storyIds: event.payload.storyIds,
|
|
696
|
+
triggeredBy: event.payload.triggeredBy,
|
|
697
|
+
callback: /* @__PURE__ */ __name(async () => {
|
|
698
|
+
try {
|
|
699
|
+
await this.vitestManager.vitestRestartPromise;
|
|
700
|
+
await this.vitestManager.runTests(event.payload);
|
|
701
|
+
} catch (err) {
|
|
702
|
+
this.reportFatalError("Failed to run tests", err);
|
|
703
|
+
throw err;
|
|
704
|
+
}
|
|
705
|
+
}, "callback")
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
async handleCancelEvent() {
|
|
709
|
+
try {
|
|
710
|
+
this.store.setState((s) => ({
|
|
711
|
+
...s,
|
|
712
|
+
cancelling: true
|
|
713
|
+
}));
|
|
714
|
+
await this.vitestManager.cancelCurrentRun();
|
|
715
|
+
} catch (err) {
|
|
716
|
+
this.reportFatalError("Failed to cancel tests", err);
|
|
717
|
+
} finally {
|
|
718
|
+
this.store.setState((s) => ({
|
|
719
|
+
...s,
|
|
720
|
+
cancelling: false
|
|
721
|
+
}));
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
async runTestsWithState({
|
|
725
|
+
storyIds,
|
|
726
|
+
triggeredBy,
|
|
727
|
+
callback
|
|
728
|
+
}) {
|
|
729
|
+
this.componentTestStatusStore.unset(storyIds);
|
|
730
|
+
this.a11yStatusStore.unset(storyIds);
|
|
731
|
+
this.store.setState((s) => ({
|
|
732
|
+
...s,
|
|
733
|
+
currentRun: {
|
|
734
|
+
...storeOptions.initialState.currentRun,
|
|
735
|
+
triggeredBy,
|
|
736
|
+
startedAt: Date.now(),
|
|
737
|
+
storyIds,
|
|
738
|
+
config: s.config
|
|
739
|
+
}
|
|
740
|
+
}));
|
|
741
|
+
process.env.VITEST_STORYBOOK_CONFIG = JSON.stringify(this.store.getState().config);
|
|
742
|
+
await this.testProviderStore.runWithState(async () => {
|
|
743
|
+
await callback();
|
|
744
|
+
this.store.send({
|
|
745
|
+
type: "TEST_RUN_COMPLETED",
|
|
746
|
+
payload: this.store.getState().currentRun
|
|
747
|
+
});
|
|
748
|
+
if (this.store.getState().currentRun.unhandledErrors.length > 0) {
|
|
749
|
+
throw new Error("Tests completed but there are unhandled errors");
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
onTestModuleCollected(collectedTestCount) {
|
|
754
|
+
this.store.setState((s) => ({
|
|
755
|
+
...s,
|
|
756
|
+
currentRun: {
|
|
757
|
+
...s.currentRun,
|
|
758
|
+
totalTestCount: (s.currentRun.totalTestCount ?? 0) + collectedTestCount
|
|
759
|
+
}
|
|
760
|
+
}));
|
|
761
|
+
}
|
|
762
|
+
onTestCaseResult(result) {
|
|
763
|
+
const { storyId, testResult, reports } = result;
|
|
764
|
+
if (!storyId) {
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
this.batchedTestCaseResults.push({ storyId, testResult, reports });
|
|
768
|
+
this.throttledFlushTestCaseResults();
|
|
769
|
+
}
|
|
770
|
+
onTestRunEnd(endResult) {
|
|
771
|
+
this.throttledFlushTestCaseResults.flush();
|
|
772
|
+
this.store.setState((s) => ({
|
|
773
|
+
...s,
|
|
774
|
+
currentRun: {
|
|
775
|
+
...s.currentRun,
|
|
776
|
+
// when the test run is finished, we can set the totalTestCount to the actual number of tests run
|
|
777
|
+
// this number can be lower than the total number of tests we anticipated upfront
|
|
778
|
+
// e.g. when some tests where skipped without us knowing about it upfront
|
|
779
|
+
totalTestCount: endResult.totalTestCount,
|
|
780
|
+
unhandledErrors: endResult.unhandledErrors,
|
|
781
|
+
finishedAt: Date.now()
|
|
782
|
+
}
|
|
783
|
+
}));
|
|
784
|
+
}
|
|
785
|
+
onCoverageCollected(coverageSummary) {
|
|
786
|
+
this.store.setState((s) => ({
|
|
787
|
+
...s,
|
|
788
|
+
currentRun: { ...s.currentRun, coverageSummary }
|
|
789
|
+
}));
|
|
790
|
+
}
|
|
791
|
+
async reportFatalError(message, error) {
|
|
792
|
+
await this.store.untilReady();
|
|
793
|
+
this.store.send({
|
|
794
|
+
type: "FATAL_ERROR",
|
|
795
|
+
payload: {
|
|
796
|
+
message,
|
|
797
|
+
error: errorToErrorLike(error)
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
static async start(options) {
|
|
802
|
+
return new Promise((resolve) => {
|
|
803
|
+
const testManager = new _TestManager({
|
|
804
|
+
...options,
|
|
805
|
+
onReady: /* @__PURE__ */ __name(() => {
|
|
806
|
+
resolve(testManager);
|
|
807
|
+
options.onReady?.();
|
|
808
|
+
}, "onReady")
|
|
809
|
+
});
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
// src/node/vitest.ts
|
|
815
|
+
var UniversalStore = experimental_UniversalStore;
|
|
816
|
+
var getStatusStore = experimental_getStatusStore;
|
|
817
|
+
var getTestProviderStore = experimental_getTestProviderStore;
|
|
818
|
+
var channel = new Channel({
|
|
819
|
+
async: true,
|
|
820
|
+
transport: {
|
|
821
|
+
send: /* @__PURE__ */ __name((event) => {
|
|
822
|
+
process2.send?.(event);
|
|
823
|
+
}, "send"),
|
|
824
|
+
setHandler: /* @__PURE__ */ __name((handler) => {
|
|
825
|
+
process2.on("message", handler);
|
|
826
|
+
}, "setHandler")
|
|
827
|
+
}
|
|
828
|
+
});
|
|
829
|
+
UniversalStore.__prepare(channel, UniversalStore.Environment.SERVER);
|
|
830
|
+
var store = UniversalStore.create(storeOptions);
|
|
831
|
+
new TestManager({
|
|
832
|
+
store,
|
|
833
|
+
componentTestStatusStore: getStatusStore(STATUS_TYPE_ID_COMPONENT_TEST),
|
|
834
|
+
a11yStatusStore: getStatusStore(STATUS_TYPE_ID_A11Y),
|
|
835
|
+
testProviderStore: getTestProviderStore(ADDON_ID),
|
|
836
|
+
onReady: /* @__PURE__ */ __name(() => {
|
|
837
|
+
process2.send?.({ type: "ready" });
|
|
838
|
+
}, "onReady"),
|
|
839
|
+
storybookOptions: {
|
|
840
|
+
configDir: process2.env.STORYBOOK_CONFIG_DIR || ""
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
var exit = /* @__PURE__ */ __name((code = 0) => {
|
|
844
|
+
channel?.removeAllListeners();
|
|
845
|
+
process2.exit(code);
|
|
846
|
+
}, "exit");
|
|
847
|
+
var createUnhandledErrorHandler = /* @__PURE__ */ __name((message) => async (error) => {
|
|
848
|
+
try {
|
|
849
|
+
const payload = {
|
|
850
|
+
message,
|
|
851
|
+
error: {
|
|
852
|
+
message: error.message,
|
|
853
|
+
name: error.name,
|
|
854
|
+
stack: error.stack,
|
|
855
|
+
cause: error.cause
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
process2.send?.({
|
|
859
|
+
type: "uncaught-error",
|
|
860
|
+
payload
|
|
861
|
+
});
|
|
862
|
+
} finally {
|
|
863
|
+
exit(1);
|
|
864
|
+
}
|
|
865
|
+
}, "createUnhandledErrorHandler");
|
|
866
|
+
process2.on(
|
|
867
|
+
"uncaughtException",
|
|
868
|
+
createUnhandledErrorHandler("Uncaught exception in the test runner process")
|
|
869
|
+
);
|
|
870
|
+
process2.on(
|
|
871
|
+
"unhandledRejection",
|
|
872
|
+
createUnhandledErrorHandler("Unhandled rejection in the test runner process")
|
|
873
|
+
);
|
|
874
|
+
process2.on("exit", exit);
|
|
875
|
+
process2.on("SIGINT", () => exit(0));
|
|
876
|
+
process2.on("SIGTERM", () => exit(0));
|