broccoli-test-helper
- Version 2.0.0
- Published
- 52.5 kB
- 6 dependencies
- MIT license
Install
npm i broccoli-test-helper
yarn add broccoli-test-helper
pnpm add broccoli-test-helper
Overview
Test helpers for BroccoliPlugins that make testing build and rebuild behavior dead simple and expect diff friendly.
Index
Functions
Interfaces
Type Aliases
Functions
function buildOutput
buildOutput: (outputNode: any) => Promise<t.Output>;
Deprecated
use
createBuilder(outputNode)
orwrapBuilder(builder)
andawait output.build()
function createBuilder
createBuilder: (outputNode: any) => t.Output;
Create a broccoli
Builder
with the specified outputNode then return theOutput
interface.Parameter outputNode
Modifiers
@public
function createReadableDir
createReadableDir: (dir: string) => t.ReadableDir;
Deprecated
use
fromDir(dir)
function createTempDir
createTempDir: () => Promise<t.TempDir>;
Create temporary directory for mutation and return the
TempDir
interface.Modifiers
@public
function fromBuilder
fromBuilder: (builder: t.Builder) => t.Output;
Returns an
Output
interface from the specifiedBuilder
.Parameter builder
a builder implementation.
Modifiers
@public
function fromDir
fromDir: (dir: string) => t.ReadableDir;
Returns an
ReadableDir
interface from the specified directory.Parameter dir
Modifiers
@public
function wrapBuilder
wrapBuilder: (builder: t.Builder) => t.Output;
Deprecated
use
fromBuilder(builder)
function wrapDir
wrapDir: (dir: string) => t.ReadableDir;
Deprecated
use
fromDir(dir)
Interfaces
interface Builder
interface Builder {}
property outputPath
outputPath: string;
Path to output of the builder.
Modifiers
@public
method build
build: () => Promise<void>;
Builds output.
Modifiers
@public
method cleanup
cleanup: () => Promise<void> | void;
Cleanup temporary build artifacts.
Current version is void return but reserves the possibility of returning a promise in the future so the test helper just always returns a promise for dispose.
Modifiers
@public
interface BuilderConstructor
interface BuilderConstructor {}
Interface expected by the output test helper for a builder.
Modifiers
@public
construct signature
new (node: Tree): Builder;
interface Changes
interface Changes {}
Map of path to change type
Modifiers
@public
index signature
[path: string]: ChangeOp;
interface Disposable
interface Disposable {}
A disposable
method dispose
dispose: () => Promise<void>;
Cleanup disposable
Modifiers
@public
interface Output
interface Output extends ReadableDir, Disposable {}
Test helper for building output and making assertions.
Modifiers
@public
property builder
builder: Builder;
The builder associated with this output test helper.
Modifiers
@public
method build
build: () => Promise<void>;
Build output.
Returns
promise of build completion.
Modifiers
@public
method changes
changes: () => Changes;
Get changes from last build.
Use to assert deep equal against expected changes.
Returns
map of paths to type of change.
Modifiers
@public
method rebuild
rebuild: () => Promise<Output>;
Build output.
Deprecated
interface ReadableDir
interface ReadableDir {}
Common methods for directory test helpers.
Modifiers
@public
method changes
changes: () => Changes;
Gets the changes since the last time changes() or starts tracking and returns empty. the changes since the last time changes() was called or an empty array.
Modifiers
@public
method path
path: (subpath?: string) => string;
Resolves and normalizes the path to the directory or the subpath if specified.
Parameter subpath
subpath within the directory.
Modifiers
@public
method read
read: { (options?: ReadOptions): Tree; (from?: string, options?: { include?: string[]; exclude?: string[] }): Tree;};
Read the content of the directory.
Parameter options
Modifiers
@public
Read the content of the directory.
Parameter from
a relative path to read from within the directory.
Parameter options
Modifiers
@public
method readBinary
readBinary: (subpath: string) => Buffer | undefined;
Reads the binary file at the specified subpath.
Returns
the
Buffer
of the file orundefined
if error is EISDIR or ENOENTModifiers
@public
method readDir
readDir: { (options?: ReadDirOptions): string[]; (subpath?: string, options?: ReadDirOptions): string[];};
Reads the directory entries recursively using the specified options.
Parameter options
the options for reading the directory.
Returns
an array containing all recursive files and directories
Reads the directory entries recursively at the specified subpath using the specified options.
Returns
an array containing all recursive files and directories or
undefined
if error is ENOTDIR or ENOENTModifiers
@public
method readText
readText: (subpath: string, encoding?: string) => string | undefined;
Reads the text file at the specified subpath.
Parameter subpath
the subpath within the directory of the file.
Parameter encoding
an optional encoding (default utf8)
Returns
the text of the file or
undefined
if error is EISDIR or ENOENTModifiers
@public
interface ReadDirOptions
interface ReadDirOptions {}
Options for
Tree.readDir
property directories
directories?: boolean;
Whether directories should be included in readDir result.
property exclude
exclude?: string[];
Array of globs to exclude
property include
include?: string[];
Array of globs to include
interface ReadOptions
interface ReadOptions {}
Options for
ReadableDir.read
interface TempDir
interface TempDir extends ReadableDir, Disposable {}
A disposable temporary directory for writing mutable fixture data to.
Modifiers
@public
method changes
changes: () => Changes;
Gets the changes since the last time changes() was called or since the temporary directory was created.
Modifiers
@public
method copy
copy: (from: string, to?: string) => void;
Copy contents of a directory to the temporary directory.
Parameter from
a directory to copy from.
Parameter to
a optional subpath within the temporary directory to write to. By default it writes to the root of the tmp dir.
Modifiers
@public
method makeDir
makeDir: (subpath: string) => void;
Make a directory at the specified subpath
Parameter subpath
the subpath to create the directory within this directory.
method write
write: (content: Tree, subpath?: string) => void;
Write to the temporary directory.
Parameter content
the content to write to the temporary directory.
Parameter subpath
a subpath to write to within the temporary directory.
Modifiers
@public
method writeBinary
writeBinary: (subpath: string, data: Buffer) => void;
Write a binary file to the temporary directory.
The
write
andcopy
only support text files.Use this method to write a binary file to the temp dir.
Parameter subpath
the subpath of the file.
Parameter data
the binary data.
Modifiers
@public
method writeText
writeText: (subpath: string, text: string, encoding?: string) => void;
Write a text file at the specified subpath with the specified encoding or
'utf8'
.Parameter subpath
the subpath within the directory of the file.
Parameter text
the text to write.
Parameter encoding
an optional encoding (default
'utf8'
)
interface Tree
interface Tree {}
Represents a directory's contents.
Modifiers
@public
index signature
[name: string]: TreeEntry | undefined;
Map directory entry to a Directory or file contents or null (delete when writing directory).
Modifiers
@public
Type Aliases
type ChangeOp
type ChangeOp = 'unlink' | 'create' | 'mkdir' | 'rmdir' | 'change';
Change operation.
Modifiers
@public
type TreeEntry
type TreeEntry = Tree | string | null;
Tree entry value type.
string
if entry is a file.Tree
if entry is a directory.null
if entry represents deletionwrite(tree)
Modifiers
@public
Package Files (2)
Dependencies (6)
Dev Dependencies (15)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/broccoli-test-helper
.
- Markdown[](https://www.jsdocs.io/package/broccoli-test-helper)
- HTML<a href="https://www.jsdocs.io/package/broccoli-test-helper"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3211 ms. - Missing or incorrect documentation? Open an issue for this package.