How to use makeStatsFromError method in storybook-root

Best JavaScript code snippet using storybook-root

builder.ts

Source:builder.ts Github

copy

Full Screen

...50 // eslint-disable-next-line consistent-return51 return {52 bail,53 totalTime: process.hrtime(startTime),54 stats: makeStatsFromError(err),55 };56 }57 const { handler, modulesCount } = await useProgressReporting(router, startTime, options);58 new ProgressPlugin({ handler, modulesCount }).apply(compiler);59 const middlewareOptions: Parameters<typeof webpackDevMiddleware>[1] = {60 publicPath: config.output?.publicPath as string,61 writeToDisk: true,62 };63 compilation = webpackDevMiddleware(compiler, middlewareOptions);64 router.use(compilation);65 const stats = await new Promise<Stats>((ready, stop) => {66 compilation.waitUntilValid(ready);67 reject = stop;68 });69 if (!stats) {70 throw new Error('no stats after building preview');71 }72 // eslint-disable-next-line consistent-return73 return {74 bail,75 stats,76 totalTime: process.hrtime(startTime),77 };78};79export const bail: WebpackBuilder['bail'] = (e: Error) => {80 if (reject) {81 reject();82 }83 if (process) {84 try {85 compilation.close();86 logger.warn('Force closed preview build');87 } catch (err) {88 logger.warn('Unable to close preview build!');89 }90 }91 throw e;92};93export const build: WebpackBuilder['build'] = async ({ options, startTime }) => {94 logger.info('=> Compiling manager..');95 checkWebpackVersion4(executor.get);96 const config = await getConfig(options);97 const statsOptions = typeof config.stats === 'boolean' ? 'minimal' : config.stats;98 const compiler = executor.get(config);99 if (!compiler) {100 const err = `${config.name}: missing webpack compiler at runtime!`;101 logger.error(err);102 return Promise.resolve(makeStatsFromError(err));103 }104 return new Promise((succeed, fail) => {105 compiler.run((error, stats) => {106 if (error || !stats || stats.hasErrors()) {107 logger.error('=> Failed to build the manager');108 if (error) {109 logger.error(error.message);110 }111 if (stats && (stats.hasErrors() || stats.hasWarnings())) {112 const { warnings, errors } = stats.toJson(statsOptions);113 errors.forEach((e) => logger.error(e));114 warnings.forEach((e) => logger.error(e));115 }116 process.exitCode = 1;...

Full Screen

Full Screen

index.ts

Source:index.ts Github

copy

Full Screen

...49 logger.error(err);50 return {51 bail,52 totalTime: process.hrtime(startTime),53 stats: makeStatsFromError(err),54 };55 }56 const { handler, modulesCount } = await useProgressReporting(router, startTime, options);57 new ProgressPlugin({ handler, modulesCount }).apply(compiler);58 const middlewareOptions: Parameters<typeof webpackDevMiddleware>[1] = {59 publicPath: config.output?.publicPath as string,60 writeToDisk: true,61 logLevel: 'error',62 };63 compilation = webpackDevMiddleware(compiler, middlewareOptions);64 router.use(compilation);65 router.use(webpackHotMiddleware(compiler));66 const waitUntilValid = compilation.waitUntilValid.bind(compilation) as (67 callback: (stats?: Stats) => void68 ) => void;69 const stats = await new Promise<Stats>((ready, stop) => {70 waitUntilValid(ready);71 reject = stop;72 });73 if (!stats) {74 throw new Error('no stats after building preview');75 }76 if (stats.hasErrors()) {77 throw stats;78 }79 return {80 bail,81 stats,82 totalTime: process.hrtime(startTime),83 };84};85export const bail: WebpackBuilder['bail'] = (e: Error) => {86 if (reject) {87 reject();88 }89 if (process) {90 try {91 compilation.close();92 logger.warn('Force closed preview build');93 } catch (err) {94 logger.warn('Unable to close preview build!');95 }96 }97 throw e;98};99export const build: WebpackBuilder['build'] = async ({ options, startTime }) => {100 checkWebpackVersion4(executor.get);101 logger.info('=> Compiling preview..');102 const config = await getConfig(options);103 const compiler = executor.get(config);104 if (!compiler) {105 const err = `${config.name}: missing webpack compiler at runtime!`;106 logger.error(err);107 return Promise.resolve(makeStatsFromError(err));108 }109 return new Promise((succeed, fail) => {110 compiler.run((error, stats) => {111 if (error || !stats || stats.hasErrors()) {112 logger.error('=> Failed to build the preview');113 process.exitCode = 1;114 if (error) {115 logger.error(error.message);116 return fail(error);117 }118 if (stats && (stats.hasErrors() || stats.hasWarnings())) {119 const { warnings, errors } = stats.toJson(config.stats);120 errors.forEach((e: string) => logger.error(e));121 warnings.forEach((e: string) => logger.error(e));...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful