{"bin":{"folio":"cli.js"},"bugs":{"url":"https://github.com/Microsoft/folio/issues"},"dist":{"shasum":"6732e1316b1fbaf3199117263f07da6224f1d8a8","tarball":"https://registry.npmjs.org/folio/-/folio-0.4.0-alpha21.tgz","fileCount":61,"integrity":"sha512-0xfSvwZStmE4nbSkeryBPRM5qen/58U/h+ca9SncPjFHFACtE7zpiCXgRlDb6UvdUD1x5fPnkfa2UKwzmwjMcA==","signatures":[{"sig":"MEUCIQCFscyTbqrISOGOyHpvR9PxVENadFBXAxUM+Q93Kk89EgIgIKsvVYhaBIMemKX6eLiuVz1LZJFLNVarTs0/TrRUpPA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":347243,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgsWO8CRA9TVsSAnZWagAAmfAP+we5Q8N4RyiZ3iX/SM21\nQ1JZ3HJaSQdhAcEKx2TdjMdUzn5p1St6Oaat9fnET+otjti40065Ydk+8LV7\nwx8eAM/IyAAHTU+XDQ5SGws6rn51m3h7sXDqypJ6QXldddJ3TImHotKGtQUi\nkkvfG/Stn+Ok7hq4nXeT3yIYOOcCJIfqsJn9tGq1aUf4v69xLhbmvyZx2xZ0\n8M2I8aKtPqcd6o5aGxOXalc6RO8UHGXRe/zmgsF5Q+bm4DGAqLtu5jh2qzgv\ntst95U1lR5VqZZl/f9/Pdy3MI/gVTgYVorvFHiIXQu2QSE/xIc473bP3w0XZ\n/X+i0/bpNt6Kct5oSFdsBBiz0ycGyGe9NKzh5sUoqiR9gWQy0jy4FdvSxfxK\nXUUGkw9ysg1S0Sc8AvWk+bN8lsp6Sja3zwaUoDANV222o2vbmDTS69rRiZY0\niMTVzeDPzRRKOV9cJUNxBLP0e38EAZdhUl7JkNxh29NBcz11lao5/EHYBnR7\njYJgo98OVcKiJvWQz3Lsgm7DudRJCEpmowY+rBynZl1a2PCop8ycv3+f6GUu\nmp+HGBx9ZbLc7ZGFUFGyFXIbq+NPA1psKBcPGIp2lJ2pTJfZtdbmVQ+9iWo1\nmjF0VmpZtd39rhnUT5ktOyomLMBrc6h8VW1h2ZP6yqtyWMIE8D4AuT6VdCWa\n71Lt\r\n=ms/h\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./out/index.js","name":"folio","author":{"name":"Microsoft Corporation"},"readme":"# Folio ![npm](https://img.shields.io/npm/v/folio)\n\nA highly customizable test framework. Foundation for the [Playwright test runner](https://github.com/microsoft/playwright-test).\n\nFolio is **available in preview** and is under active development. Breaking changes could happen. We welcome your feedback to shape this towards 1.0.\n\n## Docs\n\n- [Writing a test](#writing-a-test)\n- [Fixtures](#fixtures)\n  - [Test fixtures](#test-fixtures)\n  - [Worker fixtures](#worker-fixtures)\n- [Writing a configuration file](#writing-a-configuration-file)\n  - [Changing the timeout](#changing-the-timeout)\n- [Command line](#command-line)\n- [Snapshots](#snapshots)\n- [Annotations](#annotations)\n  - [Flaky tests](#flaky-tests)\n- [Parallelism and sharding](#parallelism-and-sharding)\n  - [Workers](#workers)\n  - [Shards](#shards)\n- [Reporters](#reporters)\n  - [Built-in reporters](#built-in-reporters)\n  - [Reporter API](#reporter-api)\n- [Advanced configuration](#advanced-configuration)\n  - [Configuration object](#configuration-object)\n  - [Projects](#projects)\n  - [workerInfo](#workerinfo)\n  - [testInfo](#testinfo)\n  - [Global setup and teardown](#global-setup-and-teardown)\n  - [Fixture options](#fixture-options)\n  - [Add custom matchers using expect.extend](#add-custom-matchers-using-expectextend)\n\n## Writing a test\n\nWriting your first test is easy.\n\n```ts\n// example.spec.ts\nimport test from 'folio';\n\ntest('let us check some basics', async () => {\n  test.expect(1 + 1).toBe(2);\n});\n```\n\nYou can now run the test.\n\n```sh\n# Assuming my.spec.ts is in the current directory.\nnpx folio -c .\n```\n\nNote: Folio uses [`expect`](https://jestjs.io/docs/expect) library for test assertions.\n\n## Fixtures\n\nFolio is based on the concept of the test fixtures. Test fixtures are used to establish environment for each test, giving the test everything it needs and nothing else. Test fixtures are isolated between tests, which gives Folio numerous advantages:\n- Folio runs tests in parallel by default, making your test suite much faster.\n- Folio can efficiently retry the flaky failures, instead of re-running the whole suite.\n- You can group tests based on their meaning, instead of their common setup.\n\nHere is how typical test environment setup differs between traditional test style and the fixture-based one:\n\n#### Without fixtures\n\n```ts\n// example.spec.ts\n\ndescribe('database', () => {\n  let table;\n\n  beforeEach(async ()=> {\n    table = await createTable();\n  });\n\n  afterEach(async () => {\n    await dropTable(table);\n  });\n\n  test('create user', () => {\n    table.insert();\n    // ...\n  });\n\n  test('update user', () => {\n    table.insert();\n    table.update();\n    // ...\n  });\n\n  test('delete user', () => {\n    table.insert();\n    table.delete();\n    // ...\n  });\n});\n```\n\n#### With fixtures\n\n```ts\n// example.spec.ts\nimport base from 'folio';\n\n// Extend basic test by providing a \"table\" fixture.\nconst test = base.extend<{ table: Table }>({\n  table: async ({}, use) => {\n    const table = await createTable();\n    await use(table);\n    await dropTable(table);\n  },\n});\n\ntest('create user', ({ table }) => {\n  table.insert();\n  // ...\n});\n\ntest('update user', ({ table }) => {\n  table.insert();\n  table.update();\n  // ...\n});\n\ntest('delete user', ({ table }) => {\n  table.insert();\n  table.delete();\n  // ...\n});\n```\n\nYou declare exact fixtures that the test needs and the runner initializes them for each test individually. Tests can use any combinations of the fixtures to tailor precise environment they need. You no longer need to wrap tests in `describe`s that set up environment, everything is declarative and typed.\n\nThere are two types of fixtures: `test` and `worker`. Test fixtures are set up for each test and worker fixtures are set up for each process that runs test files.\n\n### Test fixtures\n\nTest fixtures are set up for each test. Consider the following test file:\n\n```ts\n// hello.spec.ts\nimport test from './hello';\n\ntest('hello', ({ hello }) => {\n  test.expect(hello).toBe('Hello');\n});\n\ntest('hello world', ({ helloWorld }) => {\n  test.expect(helloWorld).toBe('Hello, world!');\n});\n```\n\nIt uses fixtures `hello` and `helloWorld` that are set up by the framework for each test run.\n\nHere is how test fixtures are declared and defined. Fixtures can use other fixtures - note how `helloWorld` uses `hello`.\n\n```ts\n// hello.ts\nimport base from 'folio';\n\n// Define test fixtures \"hello\" and \"helloWorld\".\ntype TestFixtures = {\n  hello: string;\n  helloWorld: string;\n};\n\n// Extend base test with our fixtures.\nconst test = base.extend<TestFixtures>({\n  // This fixture is a constant, so we can just provide the value.\n  hello: 'Hello',\n\n  // This fixture has some complex logic and is defined with a function.\n  helloWorld: async ({ hello }, use) => {\n    // Set up the fixture.\n    const value = hello + ', world!';\n\n    // Use the fixture value in the test.\n    await use(value);\n\n    // Clean up the fixture. Nothing to cleanup in this example.\n  },\n});\n\n// Now, this \"test\" can be used in multiple test files, and each of them will get the fixtures.\nexport default test;\n```\n\nWith fixtures, test organization becomes flexible - you can put tests that make sense next to each other based on what they test, not based on the environment they need.\n\n### Worker fixtures\n\nFolio uses worker processes to run test files. You can specify the maximum number of workers using `--workers` command line option. Similarly to how test fixtures are set up for individual test runs, worker fixtures are set up for each worker process. That's where you can set up services, run servers, etc. Folio will reuse the worker process for as many test files as it can, provided their worker fixtures match and hence environments are identical.\n\nHere is how the test looks:\n```ts\n// express.spec.ts\nimport test from './express-test';\nimport fetch from 'node-fetch';\n\ntest('fetch 1', async ({ port }) => {\n  const result = await fetch(`http://localhost:${port}/1`);\n  test.expect(await result.text()).toBe('Hello World 1!');\n});\n\ntest('fetch 2', async ({ port }) => {\n  const result = await fetch(`http://localhost:${port}/2`);\n  test.expect(await result.text()).toBe('Hello World 2!');\n});\n```\n\nAnd here is how fixtures are declared and defined:\n```ts\n// express-test.ts\nimport base from 'folio';\nimport express from 'express';\nimport type { Express } from 'express';\n\n// Declare worker fixtures.\ntype ExpressWorkerFixtures = {\n  port: number;\n  express: Express;\n};\n\n// Note that we did not provide an test-scoped fixtures, so we pass {}.\nconst test = base.extend<{}, ExpressWorkerFixtures>({\n\n  // We pass a tuple to with the fixture function and options.\n  // In this case, we mark this fixture as worker-scoped.\n  port: [ async ({}, use, workerInfo) => {\n    // \"port\" fixture uses a unique value of the worker process index.\n    await use(3000 + workerInfo.workerIndex);\n  }, { scope: 'worker' } ],\n\n  // \"express\" fixture starts automatically for every worker - we pass \"auto\" for that.\n  express: [ async ({ port }, use) => {\n    // Setup express app.\n    const app = express();\n    app.get('/1', (req, res) => {\n      res.send('Hello World 1!')\n    });\n    app.get('/2', (req, res) => {\n      res.send('Hello World 2!')\n    });\n\n    // Start the server.\n    let server;\n    console.log('Starting server...');\n    await new Promise(f => {\n      server = app.listen(port, f);\n    });\n    console.log('Server ready');\n\n    // Use the server in the tests.\n    await use(server);\n\n    // Cleanup.\n    console.log('Stopping server...');\n    await new Promise(f => server.close(f));\n    console.log('Server stopped');\n  }, { scope: 'worker', auto: true } ],\n});\n\nexport default test;\n```\n\n## Writing a configuration file\n\nFolio allows writing a configuration file that specifies how to run the tests.\n```ts\n// folio.config.ts\nimport * as folio from 'folio';\n\nconst config: folio.Config = {\n  // Look for tests in this directory.\n  testDir: __dirname,\n\n  // Give each test 20 seconds.\n  timeout: 20000,\n\n  // Give each test two retries.\n  retries: 2,\n};\n\nexport default config;\n```\n\nLook at the [configuration object](#configuration-object) for the available options.\n\nFolio will automatically pick up the `folio.config.ts` or `folio.config.js` file in the current directory:\n```sh\nnpx folio\n```\n\nAlternatively, specify the configuration file manually:\n```sh\nnpx folio --config=my.config.ts\n```\n\n### Example - changing the timeout\n\nThere are a few ways to change the test timeout - the amount of time in milliseconds per each test. Passing a zero timeout in any of these disables the timeout.\n\n- Using the configuration file.\n```ts\n// folio.config.ts\nconst config = {\n  timeout: 5000,\n};\nexport default config;\n```\n\n- Using a [command line](#command-line) option.\n```sh\n# Disable timeout for all tests, e.g. for debugging.\nnpx folio --timeout=0\n```\n\n- Calling `test.setTimeout(milliseconds)` in the test itself.\n```ts\n// example.spec.ts\nimport test from 'folio';\n\ntest('my test', async () => {\n  // Give this test 5 seconds.\n  test.setTimeout(5000);\n});\n```\n\n- Calling `test.slow()` to triple the timeout.\n```ts\n// example.spec.ts\nimport test from 'folio';\n\ntest('my test', async () => {\n  test.slow();\n});\n```\n\n## Command line\n\n```sh\n# Ask for help!\nnpx folio --help\n```\n\nArguments passed to `npx folio` are treated as a filter for test files. For example, `npx folio my-spec` will only run tests from files with `my-spec` in the name.\n\nAll the options are available in the [configuration file](#writing-a-configuration-file). However, selected options can be passed to a command line and take a priority over the configuration file:\n- `--config <file>` or `-c <file>`: Configuration file. Defaults to `folio.config.ts` or `folio.config.js` in the current directory.\n- `--forbid-only`: Whether to disallow `test.only` exclusive tests. Useful on CI. Overrides `config.forbidOnly` option from the configuration file.\n- `--grep <grep>` or `-g <grep>`: Only run tests matching this regular expression, for example `/my.*test/i` or `my-test`. Overrides `config.grep` option from the configuration file.\n- `--global-timeout <number>`: Total timeout in milliseconds for the whole test run. By default, there is no global timeout. Overrides `config.globalTimeout` option from the configuration file.\n- `--help`: Display help.\n- `--list`: List all the tests, but do not run them.\n- `--max-failures <N>` or `-x`: Stop after the first `N` test failures. Passing `-x` stops after the first failure. Overrides `config.maxFailures` option from the configuration file.\n- `--output <dir>`: Directory for artifacts produced by tests, defaults to `test-results`. Overrides `config.outputDir` option from the configuration file.\n- `--quiet`: Whether to suppress stdout and stderr from the tests. Overrides `config.quiet` option from the configuration file.\n- `--repeat-each <number>`: Specifies how many times to run each test. Defaults to one. Overrides `config.repeatEach` option from the configuration file.\n- `--reporter <reporter>`. Specify reporter to use, comma-separated, can be some combination of `dot`, `json`, `junit`, `line`, `list` and `null`. See [reporters](#reporters) for more information.\n- `--retries <number>`: The maximum number of retries for each [flaky test](#flaky-tests), defaults to zero (no retries). Overrides `config.retries` option from the configuration file.\n- `--shard <shard>`: [Shard](#shards) tests and execute only selected shard, specified in the form `current/all`, 1-based, for example `3/5`. Overrides `config.shard` option from the configuration file.\n- `--project <project...>`: Only run tests from one of the specified [projects](#projects). Defaults to running all projects defined in the configuration file.\n- `--timeout <number>`: Maximum timeout in milliseconds for each test, defaults to 10 seconds. Overrides `config.timeout` option from the configuration file.\n- `--update-snapshots` or `-u`: Whether to update snapshots with actual results instead of comparing them. Use this when snapshot expectations have changed. Overrides `config.updateSnapshots` option from the configuration file.\n- `--workers <workers>` or `-j <workers>`: The maximum number of concurrent worker processes.  Overrides `config.workers` option from the configuration file.\n\n## Annotations\n\nUnfortunately, tests do not always pass. Folio supports test annotations to deal with failures, flakiness and tests that are not yet ready.\n\n```ts\n// example.spec.ts\nimport test from 'folio';\n\ntest('basic', async ({ table }) => {\n  test.skip(version == 'v2', 'This test crashes the database in v2, better not run it.');\n  // Test goes here.\n});\n\ntest('can insert multiple rows', async ({ table }) => {\n  test.fail('Broken test, but we should fix it!');\n  // Test goes here.\n});\n```\n\nAnnotations may be conditional, in which case they only apply when the condition is truthy. Annotations may depend on test arguments. There could be multiple annotations on the same test, possibly in different configurations.\n\nPossible annotations include:\n- `skip` marks the test as irrelevant. Folio does not run such a test. Use this annotation when the test is not applicable in some configuration.\n- `fail` marks the test as failing. Folio will run this test and ensure it does indeed fail. If the test does not fail, Folio will complain.\n- `fixme` marks the test as failing. Folio will not run this test, as opposite to the `fail` annotation. Use `fixme` when running the test is slow or crashy.\n- `slow` marks the test as slow and triples the test timeout.\n\n### Flaky tests\n\nFolio deals with flaky tests with retries. Pass the maximum number of retries when running the tests, or set them in the [configuration file](#writing-a-configuration-file).\n```sh\nnpx folio --retries=3\n```\n\nFailing tests will be retried multiple times until they pass, or until the maximum number of retries is reached. Folio will report all tests that failed at least once:\n\n```sh\nRunning 1 test using 1 worker\n××±\n1 flaky\n  1) my.test.js:1:1\n```\n\n## Snapshots\n\nFolio includes the ability to produce and compare snapshots. For that, use `expect(value).toMatchSnapshot()`. Folio auto-detects the content type, and includes built-in matchers for text, png and jpeg images, and arbitrary binary data.\n\n```ts\n// example.spec.ts\nimport test from 'folio';\n\ntest('my test', async () => {\n  const image = await produceSomePNG();\n  test.expect(image).toMatchSnapshot('optional-snapshot-name.png');\n});\n```\n\nSnapshots are stored next to the test files, and you should commit them to the version control system.\n\n## Parallelism and sharding\n\nFolio runs tests in parallel by default, using multiple worker processes.\n\n### Workers\n\nEach worker process creates a new environment to run tests. Different projects always run in different workers. By default, Folio reuses the worker as much as it can to make testing faster, but it will create a new worker when retrying tests, after any test failure, to initialize a new environment, or just to speed up test execution if the worker limit is not reached.\n\nThe maximum number of worker processes is controlled via [command line](#command-line) or [configuration object](#configuration-object).\n\nEach worker process is assigned a unique sequential index that is accessible through [`workerInfo`](#workerinfo) object.\n\n### Shards\n\nFolio can shard a test suite, so that it can be executed on multiple machines. For that,  pass `--shard=x/y` to the command line. For example, to split the suite into three shards, each running one third of the tests:\n```sh\nnpx folio --shard=1/3\nnpx folio --shard=2/3\nnpx folio --shard=3/3\n```\n\n## Reporters\n\nFolio comes with a few built-in reporters for different needs and ability to provide custom reporters. The easiest way to try out built-in reporters is to pass `--reporter` [command line option](#command-line).\n\n```sh\nnpx folio --reporter=line\n```\n\nFor more control, you can specify reporters programmatically in the [configuration file](#writing-a-configuration-file).\n\n```ts\n// folio.config.ts\nimport * as folio from 'folio';\n\nconst config: folio.Config = {\n  reporter: 'dot',\n};\n\n// More complex example:\nconst config2: folio.Config = {\n  reporter: !process.env.CI\n    // A long list of tests for the terminal.\n    ? 'list'\n    // Entirely different config on CI.\n    // Use very concise \"dot\" reporter plus a comprehensive json report.\n    : ['dot', { name: 'json', outputFile: 'test-results.json' }],\n};\n\nexport default config;\n```\n\n### Built-in reporters\n\nAll built-in reporters show detailed information about failures, and mostly differ in verbosity for successful runs.\n\n#### List reporter\n\nList reporter is default. It prints a line for each test being run. Use it with `--reporter=list` or `reporter: 'list'`.\n\n```ts\n// folio.config.ts\nconst config = {\n  reporter: 'list',\n};\nexport default config;\n```\n\nHere is an example output in the middle of a test run. Failures will be listed at the end.\n```sh\nnpx folio --reporter=list\nRunning 124 tests using 6 workers\n\n  ✓ should access error in env (438ms)\n  ✓ handle long test names (515ms)\n  x 1) render expected (691ms)\n  ✓ should timeout (932ms)\n    should repeat each:\n  ✓ should respect enclosing .gitignore (569ms)\n    should teardown env after timeout:\n    should respect excluded tests:\n  ✓ should handle env beforeEach error (638ms)\n    should respect enclosing .gitignore:\n```\n\n#### Line reporter\n\nLine reporter is more concise than the list reporter. It uses a single line to report last finished test, and prints failures when they occur. Line reporter is useful for large test suites where it shows the progress but does not spam the output by listing all the tests. Use it with `--reporter=line` or `reporter: 'line'`.\n\n```ts\n// folio.config.ts\nconst config = {\n  reporter: 'line',\n};\nexport default config;\n```\n\nHere is an example output in the middle of a test run. Failures are reported inline.\n```sh\nnpx folio --reporter=line\nRunning 124 tests using 6 workers\n  1) dot-reporter.spec.ts:20:1 › render expected ===================================================\n\n    Error: expect(received).toBe(expected) // Object.is equality\n\n    Expected: 1\n    Received: 0\n\n[23/124] gitignore.spec.ts - should respect nested .gitignore\n```\n\n#### Dot reporter\n\nDot reporter is very concise - it only produces a single character per successful test run. It is useful on CI where you don't want a lot of output. Use it with `--reporter=dot` or `reporter: 'dot'`.\n\n```ts\n// folio.config.ts\nconst config = {\n  reporter: 'dot',\n};\nexport default config;\n```\n\nHere is an example output in the middle of a test run. Failures will be listed at the end.\n```sh\nnpx folio --reporter=dot\nRunning 124 tests using 6 workers\n······F·············································\n```\n\n#### JSON reporter\n\nJSON reporter produces an object with all information about the test run. It is usually used together with some terminal reporter like `dot` or `line`.\n\nMost likely you want to write the JSON to a file. When running with `--reporter=json`, use `FOLIO_JSON_OUTPUT_NAME` environment variable:\n```sh\nFOLIO_JSON_OUTPUT_NAME=results.json npx folio --reporter=json,dot\n```\n\nIn configuration file, pass options directly:\n```ts\n// folio.config.ts\nconst config = {\n  reporter: { name: 'json', outputFile: 'results.json' },\n};\nexport default config;\n```\n\n#### JUnit reporter\n\nJUnit reporter produces a JUnit-style xml report. It is usually used together with some terminal reporter like `dot` or `line`.\n\nMost likely you want to write the report to an xml file. When running with `--reporter=junit`, use `FOLIO_JUNIT_OUTPUT_NAME` environment variable:\n```sh\nFOLIO_JUNIT_OUTPUT_NAME=results.xml npx folio --reporter=junit,line\n```\n\nIn configuration file, pass options directly:\n```ts\n// folio.config.ts\nconst config = {\n  reporter: { name: 'junit', outputFile: 'results.xml' },\n};\nexport default config;\n```\n\n## Advanced configuration\n\n### Configuration object\n\nConfiguration file exports a single configuration object.\n\nTest project configuration properties:\n- `metadata: any` - Any JSON-serializable metadata that will be put directly to the test report.\n- `name: string` - Project name, useful when defining multiple [test projects](#projects).\n- `outputDir: string` - Output directory for files created during the test run.\n- `repeatEach: number` - The number of times to repeat each test, useful for debugging flaky tests. Overridden by `--repeat-each` command line option.\n- `retries: number` - The maximum number of retry attempts given to failed tests. Overridden by `--retries` command line option.\n- `testDir: string` - Directory that will be recursively scanned for test files.\n- `testIgnore: string | RegExp | (string | RegExp)[]` - Files matching one of these patterns are not considered test files.\n- `testMatch: string | RegExp | (string | RegExp)[]` - Only the files matching one of these patterns are considered test files.\n- `timeout: number` - Timeout for each test in milliseconds. Overridden by `--timeout` command line option.\n\nTest execution configuration properties:\n- `forbidOnly: boolean` - Whether to exit with an error if any tests are marked as `test.only`. Useful on CI. Overridden by `--forbid-only` command line option.\n- `globalSetup: string` - Path to the global setup file. This file will be required and run before all the tests. It must export a single function.\n- `globalTeardown: string` - Path to the global teardown file. This file will be required and run after all the tests. It must export a single function.\n- `globalTimeout: number` - Total timeout in milliseconds for the whole test run. Overridden by `--global-timeout` command line option.\n- `grep: RegExp | RegExp[]` - Patterns to filter tests based on their title. Overridden by `--grep` command line option.\n- `maxFailures: number` - The maximum number of test failures for this test run. After reaching this number, testing will stop and exit with an error. Setting to zero (default) disables this behavior. Overridden by `--max-failures` and `-x` command line options.\n- `preserveOutput: 'always' | 'never' | 'failures-only'` - Whether to preserve test output in the `outputDir`:\n  - `'always'` - preserve output for all tests;\n  - `'never'` - do not preserve output for any tests;\n  - `'failures-only'` - only preserve output for failed tests.\n- `projects: Project[]` - Multiple [projects](#projects) configuration.\n- `reporter: 'list' | 'line' | 'dot' | 'json' | 'junit'` - The reporter to use. See [reporters](#reporters) for details.\n- `quiet: boolean` - Whether to suppress stdout and stderr from the tests. Overridden by `--quiet` command line option.\n- `shard: { total: number, current: number } | null` - [Shard](#shards) information. Overridden by `--shard` command line option.\n- `updateSnapshots: boolean` - Whether to update expected snapshots with the actual results produced by the test run. Overridden by `--update-snapshots` command line option.\n- `workers: number` - The maximum number of concurrent worker processes to use for parallelizing tests. Overridden by `--workers` command line option.\n\n\n```ts\n// folio.config.ts\nimport * as folio from 'folio';\n\nconst config: folio.Config = {\n  // 20 seconds per test.\n  timeout: 20000,\n\n  // Forbid test.only on CI.\n  forbidOnly: !!process.env.CI,\n\n  // Two retries for each test.\n  retries: 2,\n});\nexport default config;\n```\n\n### Projects\n\nFolio supports running multiple test projects at the same time. This is useful for running the same tests in multiple configurations. For example, consider running tests against multiple versions of the database.\n\nTo make use of this feature, we will declare an \"option fixture\" for the database version, and use it in the tests.\n\n```ts\n// my-test.ts\nimport base from folio;\n\nconst test = base.extend<{ version: string, database: Database }>({\n  // Default value for the version.\n  version: '1.0',\n\n  // Use version when connecting to the database.\n  database: async ({ version }, use) => {\n    const db = await connectToDatabase(version);\n    await use(db);\n    await db.close();\n  },\n});\n```\n\nWe can use our fixtures in the test.\n```ts\n// example.spec.ts\nimport test from './my-test';\n\ntest('test 1', async ({ database }) => {\n  // Test code goes here.\n});\n\ntest('test 2', async ({ version, database }) => {\n  test.fixme(version === '2.0', 'This feature is not implemented in 2.0 yet');\n  // Test code goes here.\n});\n```\n\nNow, we can run test in multiple configurations by using projects.\n```ts\n// folio.config.ts\nimport * as folio from 'folio';\n\nconst config: folio.Config = {\n  timeout: 20000,\n  projects: [\n    {\n      name: 'v1',\n      use: { version: '1.0' },\n    },\n    {\n      name: 'v2',\n      use: { version: '2.0' },\n    },\n  ]\n};\nexport default config;\n```\n\nEach project can be configured separately, and run different set of tests with different parameters.\nSupported options are `name`, `outputDir`, `repeatEach`, `retries`, `testDir`, `testIgnore`, `testMatch` and `timeout`. See [configuration object](#configuration-object) for detailed description.\n\nYou can run all projects or just a single one:\n```sh\n# Run both projects - each test will be run twice\nnpx folio\n\n# Run a single project - each test will be run once\nnpx folio --project=v2\n```\n\n### workerInfo\n\nDepending on the configuration and failures, Folio might use different number of worker processes to run all the tests. For example, Folio will always start a new worker process after a failing test.\n\nWorker-scoped fixtures and `beforeAll` and `afterAll` hooks receive `workerInfo` parameter. The following information is accessible from the `workerInfo`:\n- `config` - [Configuration object](#configuration-object).\n- `project` - Specific [project](#projects) configuration for this worker. Different projects are always run in separate processes.\n- `workerIndex: number` - A unique sequential index assigned to the worker process.\n\nConsider an example where we run a new http server per worker process, and use `workerIndex` to produce a unique port number:\n\n```ts\n// my-test.ts\nimport base from 'folio';\nimport * as http from 'http';\n\n// Note how we mark the fixture as { scope: 'worker' }.\n// Also note that we pass empty {} first, since we do not declare any test fixtures.\nconst test = base.extend<{}, { server: http.Server }>({\n  server: [ async ({}, use, workerInfo) => {\n    // Start the server.\n    const server = http.createServer();\n    server.listen(9000 + workerInfo.workerIndex);\n    await new Promise(ready => server.once('listening', ready));\n\n    // Use the server in the tests.\n    await use(server);\n\n    // Cleanup.\n    await new Promise(done => server.close(done));\n  }, { scope: 'worker' } ]\n});\nexport default test;\n```\n\n### testInfo\n\nTest fixtures and `beforeEach` and `afterEach` hooks receive `testInfo` parameter. It is also available to the test function as a second parameter.\n\nIn addition to everything from the [`workerInfo`](#workerinfo), the following information is accessible before and during the test:\n- `title: string` - Test title.\n- `file: string` - Full path to the test file.\n- `line: number` - Line number of the test declaration.\n- `column: number` - Column number of the test declaration.\n- `fn: Function` - Test body function.\n- `repeatEachIndex: number` - The sequential repeat index.\n- `retry: number` - The sequential number of the test retry (zero means first run).\n- `expectedStatus: 'passed' | 'failed' | 'timedOut'` - Whether this test is expected to pass, fail or timeout.\n- `timeout: number` - Test timeout.\n- `annotations` - [Annotations](#annotations) that were added to the test.\n- `snapshotSuffix: string` - Suffix used to locate snapshots for the test.\n- `snapshotPath(snapshotName: string)` - Function that returns the full path to a particular snapshot for the test.\n- `outputDir: string` - Absolute path to the output directory for this test run.\n- `outputPath(...pathSegments: string[])` - Function that returns the full path to a particular output artifact for the test.\n\nThe following information is accessible after the test body has finished, in fixture teardown:\n- `duration: number` - test running time in milliseconds.\n- `status: 'passed' | 'failed' | 'timedOut'` - the actual test result.\n- `error` - any error thrown by the test body.\n- `stdout: (string | Buffer)[]` - array of stdout chunks collected during the test run.\n- `stderr: (string | Buffer)[]` - array of stderr chunks collected during the test run.\n\nHere is an example test that saves some information:\n```ts\n// example.spec.ts\nimport test from 'folio';\n\ntest('my test needs a file', async ({ table }, testInfo) => {\n  // Do something with the table...\n  // ... and then save contents.\n  const filePath = testInfo.outputPath('table.dat');\n  await table.saveTo(filePath);\n});\n```\n\nHere is an example fixture that automatically saves debug logs when the test fails:\n```ts\n// my-test.ts\nimport * as debug from 'debug';\nimport * as fs from 'fs';\nimport base from 'folio';\n\n// Note how we mark the fixture as { auto: true }.\n// This way it is always instantiated, even if the test does not use it explicitly.\nconst test = base.extend<{ saveLogs: void }>({\n  saveLogs: [ async ({}, use, testInfo) => {\n    const logs = [];\n    debug.log = (...args) => logs.push(args.map(String).join(''));\n    debug.enable('mycomponent');\n    await use();\n    if (testInfo.status !== testInfo.expectedStatus)\n      fs.writeFileSync(testInfo.outputPath('logs.txt'), logs.join('\\n'), 'utf8');\n  }, { auto: true } ]\n});\nexport default test;\n```\n\n### Global setup and teardown\n\nTo set something up once before running all tests, use `globalSetup` option in the [configuration file](#writing-a-configuration-file). Similarly, use `globalTeardown` to run something once after all the tests.\n\n```ts\n// global-setup.ts\nimport * as http from 'http';\n\nmodule.exports = async () => {\n  const server = http.createServer(app);\n  await new Promise(done => server.listen(done));\n  process.env.SERVER_PORT = String(server.address().port); // Expose port to the tests.\n  global.__server = server; // Save the server for the teardown.\n};\n```\n\n```ts\n// global-teardown.ts\nmodule.exports = async () => {\n  await new Promise(done => global.__server.close(done));\n};\n```\n\n```ts\n// folio.config.ts\nimport * as folio from 'folio';\n\nconst config: folio.Config = {\n  globalSetup: 'global-setup.ts',\n  globalTeardown: 'global-teardown.ts',\n};\nexport default config;\n```\n\n### Fixture options\n\nIt is common for the [fixtures](#fixtures) to be configurable, based on various test needs.\nFolio allows creating \"options\" fixture for this purpose.\n\n```ts\n// my-test.ts\nimport base from 'folio';\n\nconst test = base.extend<{ dirCount: number, dirs: string[] }>({\n  // Define an option that can be configured in tests with `test.use()`.\n  // Provide a default value.\n  dirCount: 1,\n\n  // Define a fixture that provides some useful functionality to the test.\n  // In this example, it will supply some temporary directories.\n  // Our fixture uses the \"dirCount\" option that can be configured by the test.\n  dirs: async ({ dirCount }, use, testInfo) => {\n    const dirs = [];\n    for (let i = 0; i < dirCount; i++)\n      dirs.push(testInfo.outputPath('dir-' + i));\n\n    // Use the list of directories in the test.\n    await use(dirs);\n\n    // Cleanup if needed.\n  },\n});\nexport default test;\n```\n\nWe can now pass the option value with `test.use()`.\n\n```ts\n// example.spec.ts\nimport test from './my-test';\n\n// Here we define the option value. Tests in this file need two temporary directories.\ntest.use({ dirCount: 2 });\n\ntest('my test title', async ({ dirs }) => {\n  // Test can use \"dirs\" right away - the fixture has already run and created two temporary directories.\n  test.expect(dirs.length).toBe(2);\n});\n```\n\nIn addition to `test.use()`, we can also specify options in the configuration file.\n```ts\n// folio.config.ts\nimport * as folio from 'folio';\n\nconst config: folio.Config = {\n  // All tests will get three directories by default, unless it is overridden with test.use().\n  use: { dirCount: 3 },\n};\nexport default config;\n```\n\n### Add custom matchers using expect.extend\n\nFolio uses [expect](https://jestjs.io/docs/expect) under the hood which has the functionality to extend it with [custom matchers](https://jestjs.io/docs/expect#expectextendmatchers). See the following example where a custom `toBeWithinRange` function gets added.\n\n```ts\n// folio.config.ts\nimport * as folio from 'folio';\n\nfolio.expect.extend({\n  toBeWithinRange(received: number, floor: number, ceiling: number) {\n    const pass = received >= floor && received <= ceiling;\n    if (pass) {\n      return {\n        message: () => 'passed',\n        pass: true,\n      };\n    } else {\n      return {\n        message: () => 'failed',\n        pass: false,\n      };\n    }\n  },\n});\n\nconst config = {};\nexport default config;\n```\n\n```ts\n// example.spec.ts\nimport test from 'folio';\n\ntest('numeric ranges', () => {\n  test.expect(100).toBeWithinRange(90, 110);\n  test.expect(101).not.toBeWithinRange(0, 100);\n});\n```\n\n```ts\n// global.d.ts\ndeclare namespace folio {\n  interface Matchers<R> {\n    toBeWithinRange(a: number, b: number): R;\n  }\n}\n```\n\nTo import expect matching libraries like [jest-extended](https://github.com/jest-community/jest-extended#installation) you can import it from your `globals.d.ts`:\n\n```ts\n// global.d.ts\nimport 'jest-extended';\n```\n","engines":{"node":">=10.17.0"},"gitHead":"e789635654447bc1e2231d38f332a0b2b7f975f7","license":"Apache-2.0","scripts":{"lint":"eslint . --ext js,ts","test":"folio --config=test/folio-config.ts","build":"tsc --build tsconfig.json","watch":"tsc --build tsconfig.json --watch","prepare":"npm run build","roll-dogfood":"cd dogfood && npm install","prepublishOnly":"rm -rf out && npm run build"},"_npmUser":{"name":"dgozman","email":"dgozman@gmail.com"},"homepage":"https://github.com/Microsoft/folio#readme","deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","repository":{"url":"git+https://github.com/Microsoft/folio.git","type":"git"},"_npmVersion":"6.14.5","description":"A highly customizable test framework. Foundation for the [Playwright test runner](https://github.com/microsoft/playwright-test).","directories":{},"maintainers":[{"name":"arjun27","email":"arjunattam@gmail.com"},{"name":"aslushnikov","email":"aslushnikov@gmail.com"},{"name":"joeleinbinder","email":"joel.einbinder@gmail.com"},{"name":"pavelfeldman","email":"pavel.feldman@gmail.com"},{"name":"dgozman","email":"dgozman@gmail.com"},{"name":"yurys","email":"yury.semikhatsky@gmail.com"}],"_nodeVersion":"12.18.2","dependencies":{"ms":"^2.1.2","pngjs":"^5.0.0","colors":"^1.4.0","expect":"^26.4.2","rimraf":"^3.0.2","jpeg-js":"^0.4.2","pirates":"^4.0.1","commander":"^6.1.0","minimatch":"^3.0.3","pixelmatch":"^5.2.1","@babel/core":"^7.14.0","stack-utils":"^2.0.2","@babel/code-frame":"^7.12.13","source-map-support":"^0.5.19","@babel/preset-typescript":"^7.13.0","@babel/plugin-syntax-json-strings":"^7.8.3","@babel/plugin-proposal-dynamic-import":"^7.13.8","@babel/plugin-syntax-async-generators":"^7.8.4","@babel/plugin-proposal-private-methods":"^7.13.0","@babel/plugin-proposal-class-properties":"^7.13.0","@babel/plugin-syntax-object-rest-spread":"^7.8.3","@babel/plugin-proposal-numeric-separator":"^7.12.13","@babel/plugin-proposal-optional-chaining":"^7.13.12","@babel/plugin-transform-modules-commonjs":"^7.14.0","@babel/plugin-syntax-optional-catch-binding":"^7.8.3","@babel/plugin-proposal-export-namespace-from":"^7.12.13","@babel/plugin-proposal-private-property-in-object":"^7.14.0","@babel/plugin-proposal-nullish-coalescing-operator":"^7.13.8","@babel/plugin-proposal-logical-assignment-operators":"^7.13.8"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"folio":"./dogfood/node_modules/folio","eslint":"^7.8.1","xml2js":"^0.4.23","micromatch":"^4.0.2","typescript":"=4.0.2","@types/rimraf":"^3.0.0","@types/xml2js":"^0.4.5","@types/minimatch":"^3.0.3","@types/micromatch":"^4.0.1","@types/babel__core":"^7.1.14","eslint-plugin-notice":"^0.9.10","@typescript-eslint/parser":"^4.2.0","@typescript-eslint/eslint-plugin":"^4.2.0"},"_npmOperationalInternal":{"tmp":"tmp/folio_0.4.0-alpha21_1622238139693_0.1386122497281277","host":"s3://npm-registry-packages"},"_id":"folio@0.4.0-alpha21","version":"0.4.0-alpha21"}