Skip to content
Myr

fixtures-directory.js

This file

Path

test/helpers/fixtures-directory.js

27 lines · 1.0 KiB · JavaScript

Last changed by

Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454

History of this file

Take it

The walk stopped after 200 commits: lines older than 9f65b86 point at it.

Upgrade dependencies (#1138)ehmickybefore adoptionabd9fd0

line 1why, one step back
1import path from 'node:path';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 2–3why, one step back
2import process from 'node:process';
3import {fileURLToPath} from 'node:url';

Fix Node 24-specific deprecation warning (#1199)ehmickybefore adoption1ac5b91

line 4why, one step back
4import logProcessErrors from 'log-process-errors';

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 5why, one step back
5import pathKey from 'path-key';

Fix Node 24-specific deprecation warning (#1199)ehmickybefore adoption1ac5b91

lines 6–7why, one step back
6
7// Make tests fail if any warning (such as a deprecation warning) is emitted

Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454

line 8why, one step back
8// eslint-disable-next-line unicorn/no-top-level-side-effects -- must run as soon as this helper is imported

Fix Node 24-specific deprecation warning (#1199)ehmickybefore adoption1ac5b91

lines 9–15why, one step back
9logProcessErrors({
10 onError(error, event) {11 if (event === 'warning') {12 throw error;13 }14 },15});

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 16–19why, one step back
16
17export const PATH_KEY = pathKey();18export const FIXTURES_DIRECTORY_URL = new URL('../fixtures/', import.meta.url);19// @todo: use import.meta.dirname after dropping support for Node <20.11.0

Upgrade dependencies (#1138)ehmickybefore adoptionabd9fd0

line 20why, one step back
20export const FIXTURES_DIRECTORY = path.resolve(fileURLToPath(FIXTURES_DIRECTORY_URL));

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 21–24why, one step back
21
22// Add the fixtures directory to PATH so fixtures can be executed without adding23// `node`. This is only meant to make writing tests simpler.24export const setFixtureDirectory = () => {

Upgrade dependencies (#1138)ehmickybefore adoptionabd9fd0

line 25why, one step back
25 process.env[PATH_KEY] = FIXTURES_DIRECTORY + path.delimiter + process.env[PATH_KEY];

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 26–27why, one step back
26};
27