JSPM

  • Created
  • Published
  • Downloads 617
  • Score
    100M100P100Q109593F
  • License BSD-3-Clause

Expressen client testing framework

Package Exports

  • @expressen/tallahassee

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@expressen/tallahassee) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Tallahassee

Utilities

Build Statusdependencies Status

Test your client scripts in a headless browser.

Introduction

Supports just about everything except querySelectorAll() which we don´t want developers to use.

  • IntersectionObserver? Yes, check here

Example:

"use strict";

const app = require("../app/app");
const Browser = require("@expressen/tallahassee");
const {Compiler} = require("@expressen/tallahassee/lib/Compiler");

describe("Tallahassee", () => {
  before(() => {
    Compiler([/assets\/scripts/]);
  });

  describe("navigateTo()", () => {
    it("navigates to url", async () => {
      await Browser(app).navigateTo("/");
    });

    it("throws if not 200", async () => {
      try {
        await Browser(app).navigateTo("/404");
      } catch (e) {
        var err = e; // eslint-disable-line no-var
      }
      expect(err).to.be.ok;
    });
  });

  describe("run script", () => {
    it("transpiles and runs es6 script", async () => {
      const browser = await Browser(app).navigateTo("/", {
        Cookie: "_ga=1"
      });

      require("../app/assets/scripts/main");

      expect(browser.document.cookie).to.equal("_ga=1;");
      expect(browser.document.getElementsByClassName("set-by-js")).to.have.length(1);
    });

    it("again", async () => {
      const browser = await Browser(app).navigateTo("/");

      require("../app/assets/scripts/main");

      expect(browser.document.cookie).to.equal("");
      expect(browser.document.getElementsByClassName("set-by-js")).to.have.length(0);
    });
  });
});