You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@expressen/tallahassee

Package Overview
Dependencies
Maintainers
0
Versions
205
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@expressen/tallahassee

Lightweight client testing framework


Version published
Weekly downloads
405
increased by28.16%
Maintainers
0
Created
Weekly downloads
 

Changelog

Source

16.0.0

  • Breaking: Drop support for node <18
  • Bugfix: Assertion message on failed fetches now include error code and fetch uri

Readme

Source

Tallahassee

Utilities

Built latest

Test your client scripts in a headless browser.

Introduction

Supports just about everything.

Example:

"use strict";

const Browser = require("@expressen/tallahassee");
const Script = require("@bonniernews/wichita");
const { app } = require("../app/app.js");

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

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

    it("unless you override status code", async () => {
      const browser = await new Browser(app).navigateTo("/404", null, 404);
      expect(browser.document.getElementsByTagName("h1")[0].innerText).to.equal("Apocalyptic");
    });
  });

  describe("run script", () => {
    it("run es6 script sources with @bonniernews/wichita", async () => {
      const browser = await new Browser(app).navigateTo("/", { cookie: "_ga=1" });

      await new Script("./app/assets/scripts/main.js").run(browser.window);

      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 new Browser(app).navigateTo("/");

      await new Script("./app/assets/scripts/main.js").run(browser.window);

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

External scripts

May we suggest you to use Wichita, the Tallahassee sidekick. It can be found here https://www.npmjs.com/package/@bonniernews/wichita

Timers

If overriding timers on window, e.g. setTimeout it can be a good idea to make them asynchronous since they tend to be recurring.

Example:

browser.window.setTimeout = function mySetTimeout(fn, ms, ...args) {
  process.nextTick(fn, ...args);
};

Keywords

FAQs

Package last updated on 24 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc