{"name":"@tapjs/fixture","version":"4.0.1","description":"Tap plugin to provide t.testdir() and t.fixture()","tshy":{"main":true,"exports":{"./package.json":"./package.json",".":"./src/index.ts"}},"type":"module","main":"./dist/commonjs/index.js","types":"./dist/commonjs/index.d.ts","exports":{"./package.json":"./package.json",".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}}},"scripts":{"prepare":"tshy","pretest":"npm run prepare","presnap":"npm run prepare","test":"tap","snap":"tap","format":"prettier --write . --loglevel warn --ignore-path ../../.prettierignore --cache","typedoc":"typedoc --tsconfig tsconfig/esm.json ./src/*.ts"},"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"https://blog.izs.me"},"license":"BlueOak-1.0.0","dependencies":{"mkdirp":"^3.0.0","rimraf":"^6.0.0"},"peerDependencies":{"@tapjs/core":"4.0.1"},"tap":{"typecheck":false,"coverage-map":"map.js"},"keywords":["tapjs plugin"],"funding":{"url":"https://github.com/sponsors/isaacs"},"repository":{"type":"git","url":"git+https://github.com/tapjs/tapjs.git"},"module":"./dist/esm/index.js","engines":{"node":"20 || >=22"},"_id":"@tapjs/fixture@4.0.1","gitHead":"532287f65d814c7cb7872bf84b3d86b17d900e43","bugs":{"url":"https://github.com/tapjs/tapjs/issues"},"homepage":"https://github.com/tapjs/tapjs#readme","_nodeVersion":"22.10.0","_npmVersion":"11.0.0","dist":{"integrity":"sha512-ToCBArTQJ08DJrIUDTSGmzVmBtgTY6ppVhWrGdT/r0hC3dYsl8vLYKX1qJTGJmE88kNkwpjeDXh3QB0A/x03PQ==","shasum":"d3cb42107654d4919fe1d0ed68057021e3e295cb","tarball":"http://registry-npm.ywwl.com/@tapjs/fixture/download/@tapjs/fixture-4.0.1.tgz","fileCount":21,"unpackedSize":68334,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBlV1oQ1MiOWukNf+eTeawrYtLSawr3P4s/NaZEGjAJQAiEA8iWMgZay1irQ8dtrDdqVqu7b1XjQ6IKy38NAThSEisQ="}],"size":12027,"noattachment":false,"key":"/@tapjs/fixture/-/@tapjs/fixture-4.0.1.tgz"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/fixture_4.0.1_1740007002234_0.011351696098728992"},"_hasShrinkwrap":false,"readme":"# `@tapjs/fixture`\n\nA default tap plugin providing `t.testdir()` and `t.fixture()`\nmethods, for creating temporary directories with stuff for tests\nto operate on.\n\nFixtures created with this plugin live folders under\n`./.tap/fixtures`, in the root of the project. The folder name is\nbased on the name of the test file, and the name of the test.\n\nFor example, if a file at `./src/foo.test.mjs` had this:\n\n```js\nimport t from 'tap'\nt.test('child test', async t => {\n  t.testdir({ file: 'contents' })\n})\n```\n\nThen a file would be created at\n`.tap/fixtures/src-foo.test.mjs-child-test/file` containing\n`'contents'`.\n\n## USAGE\n\nThis plugin is installed with tap by default. If you had\npreviously removed it, you can `tap plugin add @tapjs/fixture` to\nbring it back.\n\n### `t.testdir(contents?: FixtureDirContent): string`\n\nCreate a directory with some stuff in it.\n\nIf no contents provided, just creates an empty directory.\n\n```ts\nimport t from 'tap'\nimport { lstatSync } from 'node:fs'\n\nt.test('subtest that has a test directory', t => {\n  const dir = t.testdir({\n    // objects are subdirectories\n    subdir: {\n      // strings or buffers are files\n      'file.txt': 'some contents',\n      // to create links or symlinks, use the t.fixture() method\n      symlink: t.fixture('symlink', 'file.txt'),\n      hardlink: t.fixture('link', 'file.txt'),\n    },\n  })\n  t.equal(lstatSync(dir + '/subdir/symlink').isSymbolicLink(), true)\n  t.end()\n})\n// dir removed when test ends\n```\n\nIf you do not provide a contents argument, then it will create an\nempty directory.\n\nThough it's called `t.testdir()` you can actually use it to\ncreate files or links as well.\n\n```ts\nimport t from 'tap'\nimport { readFileSync } from 'node:fs'\nt.test('test \"dir\" is actually file', t => {\n  const file = t.testdir('file contents')\n  t.equal(readFileSync(file, 'utf8'), 'file contents')\n  t.end()\n})\n```\n\n### `t.testdirName: string`\n\nThis is a string that gives you the string path that\n`t.testdir()` will write to.\n\n### `saveFixture` test option, `t.saveFixture: boolean`\n\nIf set to `true`, then the test will not delete its fixtures when\nit finishes.\n\nIf set on the test object, this must be set _before_ calling\n`t.testdir()`, or it won't have any effect, since the deletion is\nscheduled at the moment it's created.\n","publish_time":1740007002491,"maintainers":[{"name":"ljharb","email":"ljharb@gmail.com"},{"name":"isaacs","email":"i@izs.me"}],"_cnpm_publish_time":1740007002491,"dist-tags":{"latest":"4.3.12","pre":"1.0.0"}}