npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

test-filesystem

v1.3.7

Published

Set up and tear down a temp directory for running filesystem tests.

Downloads

253

Readme

test-fs

Set up and tear down a temp directory for running filesystem tests.

There are three options for accessing these functions:

  1. CommonJs modules: dist/*.js (default)
  2. ES6 modules: dist/*.mjs
  3. Bundles Browser file: browser/test-fs.js

Installation

In your project's root directory, run: npm install --save-dev test-filesystem (or yarn add --dev test-filesystem if you use Yarn).

Usage

To use the temporary directory in tests. Do the following in your tests:

import { setUp } from 'test-filesystem'

// Setup the name for your temporary directory
const dirName = 'test-temp/'

// Use the name
setUp.setDefaults(dirName)

// use the beforeEach and afterEach methods of jest to run the setup and teardown functions
beforeEach(
  () => setUp.beforeEach()
    .then(
      () => {
        // Put any additional setup logic here
      }
    )
)

afterEach(
  () => setUp.afterEach()
    .then(
      () => {
        // Put any additional teardown logic here
      }
    )
)

test-fs

An assortment of objects that can be used in tests and some functions to help debug and write tests.

Version: 1.0.0
Author: Joshua Heagle [email protected]

test-fs.circularObject : Object.<string, (string|Object|Array)>

Multilayered node tree-like structure with parent references

Kind: static constant of test-fs

test-fs.deepReferenceObject : Object.<string, (string|number|Object)>

Sample object with deep references.

Kind: static constant of test-fs

test-fs.domItem : Object.<string, (string|number|Array|Object)>

Sample of domItem child with nested child and optional details

Kind: static constant of test-fs

test-fs.jsonDom : Object.<string, (string|number|Array|Object)>

Sample of jsonDom object containing an empty nested array and objects

Kind: static constant of test-fs

test-fs.linkedList : Object.<string, (string|Object)>

Sample LinkedList for testing circular references.

Kind: static constant of test-fs

test-fs.multiReferenceObject : Object.<string, (string|number|Object)>

Sample of an object containing multiple references.

Kind: static constant of test-fs

test-fs.nodeTree : Object.<string, (string|Object|Array)>

Sample NodeTree for testing circular references and arrays.

Kind: static constant of test-fs

test-fs.countMatches(content, search) ⇒ number

Simple way to count string occurrences for testing.

Kind: static method of test-fs

| Param | Type | | --- | --- | | content | string | | search | string |

test-fs.fileExists(filePath) ⇒ boolean

Detect if a file exists and is usable.

Kind: static method of test-fs

| Param | Type | | --- | --- | | filePath | string |

test-fs.logObject(object, [label], [outputType]) ⇒ string | undefined

Log out an object in a nicely formatted way.

Kind: static method of test-fs

| Param | Type | Default | | --- | --- | --- | | object | Object | | | [label] | string | "logging" | | [outputType] | string | "log" |

test-fs.removeDirectory(dirPath) ⇒ Promise.<*>

Return a promise to be completed once the specified directory is deleted.

Kind: static method of test-fs

| Param | Type | | --- | --- | | dirPath | string |

test-fs.afterEach() ⇒ Promise.<*>

In the Jest.afterEach function call this one to clean up and remove the temp directory.

Kind: static method of test-fs

test-fs.exports.afterEach([exists]) ⇒ Promise.<(*|void)>

Ensure that the del has completed, recursively attempt to delete and recreate

Kind: static method of test-fs

| Param | Type | Default | | --- | --- | --- | | [exists] | boolean | true |

test-fs.exports.createTempDir() ⇒ Promise.<(*|void)>

In the Jest.beforeEach function call this one to set up the temp directory.

Kind: static method of test-fs