Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#2602·winston

[Bug]: exitWithError not failing Playwright test

Author: SWederellCreated Jan 16, 2026Updated Aug 5, 2026
LabelsNeeds InvestigationBug

Search Terms

exitwitherror, playwright, error

The problem

When using Winston with Playwright, I want the test to fail if an Error occurs. Setting 'exitOnError' to true, or a function that fails the test, does not work, nor writes to the log.

What version of Winston presents the issue?

v3.19.0

What version of Node are you using?

v22.13.0

If this worked in a previous version of Winston, which was it?

No response

Minimum Working Example

playwright.config.ts

typescript
import { defineConfig } from "@playwright/test";

export default defineConfig({
	timeout: 600_000,
	testDir: ".",
	fullyParallel: false,
	workers: 1,
	reporter: [],
	use: {
		trace: "on",
		headless: true,
	},
	projects: [
		{
			name: "chromium",
			use: {
				viewport: { height: 1080, width: 1920 },
			},
		},
	],
});

winston.spec.ts

typescript
import { test } from '@playwright/test'
import { createLogger, format, transports } from 'winston'

test('temp test', () => {
  const { combine, timestamp, json, errors } = format

  const logger = createLogger({
    level: process.env.LOGGER_LEVEL || 'info',
    format: combine(timestamp(), json(), errors({ stack: true })),
    transports: [new transports.File({ filename: './temp.log', zippedArchive: false })],
    exitOnError: function () {
      console.log('exitonerror')
      throw new Error('Something failed, view logs')
    },
  })

  logger.error('Demo Error')
})

or

typescript
import { test } from '@playwright/test'
import { createLogger, format, transports } from 'winston'

test('temp test', () => {
  const { combine, timestamp, json, errors } = format

  const logger = createLogger({
    level: process.env.LOGGER_LEVEL || 'info',
    format: combine(timestamp(), json(), errors({ stack: true })),
    transports: [new transports.File({ filename: './temp.log', zippedArchive: false })],
    exitOnError: true,
  })

  logger.error('Demo Error')
})

Additional information

No response

Source: winstonjs/winston

View original on GitHubView discussion on GitHub