Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

spring-media/ava-browser-fixture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ava-browser-fixtures

A module which adds a Browser Environment to your Ava Test.

When your Code modifies the DOM or needs some HTML to run, you can setup these HTML-File as a Fixture can access them by the usual Browser-API (i.e.: document.querySelector()) with this module.

Install

Install this module with npm or yarn.

NPM:

npm install --save-dev ava-browser-fixture

Yarn:

yarn add --dev ava-browser-fixture

Setup

Add ava-browser-fixture to the require block for ava in your package.json:

Example:

{
  "ava": {
    "files": [
      "src/*.spec.js"
    ],
    "require": [
      "babel-register",
      "ava-browser-fixture"
    ],
    "babel": "inherit"
  }
}

usage

Setup your fixture in the beforeEach block:

import test from "ava";
import {fixture} from "../index";

test.beforeEach('setup fixture', fixture("./test/test.html"));

test("test example", t => {
  t.is(t.context.document.documentElement.querySelector("h1").textContent, "Hello Test");
});

About

A module which adds a Browser Environment to your Ava Test.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published