{"id":25591,"library":"fixturez","title":"fixturez","description":"Easily create and maintain test fixtures in the file system. Version 1.1.0 is the latest stable release. It allows placing fixtures in any parent directory, finding them by name via upward search, copying into temporary directories, and auto-cleanup on process exit. Differentiators: supports multiple test frameworks (Jest, AVA, Mocha), fixture sharing between tests, and customizable glob patterns to locate fixture directories.","status":"active","version":"1.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/thejameskyle/fixturez","tags":["javascript","jest","ava","mocha","test","fixtures","tmp","temp"],"install":[{"cmd":"npm install fixturez","lang":"bash","label":"npm"},{"cmd":"yarn add fixturez","lang":"bash","label":"yarn"},{"cmd":"pnpm add fixturez","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export; named export is not available.","wrong":"const { fixturez } = require('fixturez')","symbol":"fixturez","correct":"import fixturez from 'fixturez'"},{"note":"CommonJS require returns the default export directly.","wrong":"const fixtures = require('fixturez').default","symbol":"fixturez","correct":"const fixtures = require('fixturez')"},{"note":"fixturez is a function, not a class; do not use 'new'.","wrong":"const f = new fixtures(__dirname)","symbol":"fixturez","correct":"const f = fixtures(__dirname)"}],"quickstart":{"code":"const test = require('ava');\nconst fixtures = require('fixturez');\nconst f = fixtures(__dirname, { root: __dirname });\n\ntest('find fixture', t => {\n  const filePath = f.find('sample.txt');\n  t.truthy(filePath);\n});\n\ntest('copy fixture', t => {\n  const tmpDir = f.copy('sample');\n  t.truthy(tmpDir);\n  f.cleanup();\n});\n\ntest('temp directory', t => {\n  const tmpDir = f.temp();\n  t.truthy(tmpDir);\n  f.cleanup();\n});","lang":"javascript","description":"Shows how to create fixture functions using require, find, copy, temp, and cleanup methods."},"warnings":[{"fix":"Ensure a 'fixtures' or '__fixtures__' directory exists in a parent directory, or set 'root' option.","message":"fixturez searches up the directory tree from __dirname; if no fixture directory is found, it will throw an error.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use the current options as documented; future API might change.","message":"Options 'glob' and 'root' may be removed in future versions.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Call f.find() if you only need the original path without copying.","message":"The 'copy' method copies the fixture into a new temporary directory each invocation; the path changes each time.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use f.find('file.txt') with the full basename including extension.","cause":"f.find('file') called but the fixture name must include the file extension.","error":"Error: Could not find fixture \"file\""},{"fix":"Use default import: const fixtures = require('fixturez'); or import fixtures from 'fixturez';","cause":"Importing fixturez incorrectly using destructuring or as a class.","error":"TypeError: fixtures is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}