Skip to main content

Config

XBell provides some configuration options to help you test better. You can write configuration options through the xbell.config.ts file in the root directory, and "xbell" will read it when it starts.

xbell.config.ts
import type { XBellConfig } from 'xbell';

const config: XBellConfig = {
browser: {
headless: false,
},
include: ['**/*.{test,spec}.{js,ts,jsx,tsx}'],
};

export default config;

setup​

teardown​

maxThreads​

  • Type: <number>
  • Default: Number of CPU

include​

  • Type: <string[]>
  • Default: ['**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']

exclude​

  • Type: <string[]>
  • default ['**/node_modules/**', '**/dist/**']

browser​

Browser Configuration

browser.headless​

  • Type: <boolean>
  • Default: true

Whether to use headless mode

browser.devtools​

browser.viewport​

browser.storageState​

  • Type: <{ width: number; height: number; }>
  • Default: { width: 1280, height: 700 }

coverage​

coverage.enable​

  • Type: <boolean>
  • Default: false

Whether to enable coverage

coverage.include​

  • Type: <string[]>

coverage.exclude​

  • Type: <string[]>
  • Default: [ '**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}', '**/node_modules/**', '**/dist/**', '**/cypress/**', '**/.{idea,git,cache,output,temp}/**', '**/{xbell,playwright,karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.*' ]

projects​

XBell supports running multiple test projects. You can use projects for different testing purposes.

For example, different projects correspond to different data environments, or different projects correspond to different browser viewport, or even different projects correspond to different test directories.

project.name​

Project Name

xbell.config.ts
export default = {
projects: [
{ name: 'project1' },
],
};
import { test } from 'xbell';

test.browser('project1', ({ project, expect }) => {
expect(project.name).toBe('project1');
});
$ xbell --projects project1

project.data​

project.config​

Type: <XBellConfig>

Each project is allowed to have an independent test configuration, inheriting the root configuration by default.

export default {
projects: [
{
name: 'e2e-project',
config: {
include: ['**/*.e2e.ts']
}
}
]
}