1 | Tallahassee
|
2 | ===========
|
3 |
|
4 | ![Utilities](https://raw.github.com/ExpressenAB/tallahassee/master/app/assets/images/tallahassee-1.png)
|
5 |
|
6 | [![Build Status](https://travis-ci.org/ExpressenAB/tallahassee.svg?branch=master)](https://travis-ci.org/ExpressenAB/tallahassee)[![dependencies Status](https://david-dm.org/ExpressenAB/tallahassee/status.svg)](https://david-dm.org/ExpressenAB/tallahassee)
|
7 |
|
8 | Test your client scripts in a headless browser.
|
9 |
|
10 | # Introduction
|
11 |
|
12 | Supports just about everything except `querySelectorAll()` which we don´t want developers to use.
|
13 |
|
14 | - IntersectionObserver? Yes, check [here](/API.md#intersectionobserver)
|
15 |
|
16 | # Example:
|
17 |
|
18 | ```javascript
|
19 | "use strict";
|
20 |
|
21 | const app = require("../app/app");
|
22 | const Browser = require("@expressen/tallahassee");
|
23 | const Script = require("@bonniernews/wichita");
|
24 |
|
25 | describe("Tallahassee", () => {
|
26 | describe("navigateTo()", () => {
|
27 | it("navigates to url", async () => {
|
28 | await Browser(app).navigateTo("/");
|
29 | });
|
30 |
|
31 | it("throws if not 200", async () => {
|
32 | try {
|
33 | await Browser(app).navigateTo("/404");
|
34 | } catch (e) {
|
35 | var err = e; // eslint-disable-line no-var
|
36 | }
|
37 | expect(err).to.be.ok;
|
38 | });
|
39 |
|
40 | it("unless you override status code", async () => {
|
41 | const browser = await Browser(app).navigateTo("/404", null, 404);
|
42 | expect(browser.document.getElementsByTagName("h1")[0].innerText).to.equal("Apocalyptic");
|
43 | });
|
44 | });
|
45 |
|
46 | describe("run script", () => {
|
47 | it("run es6 script sources with @bonniernews/wichita", async () => {
|
48 | const browser = await Browser(app).navigateTo("/", {
|
49 | Cookie: "_ga=1"
|
50 | });
|
51 |
|
52 | await Script("../app/assets/scripts/main").run(browser.window);
|
53 |
|
54 | expect(browser.document.cookie).to.equal("_ga=1");
|
55 | expect(browser.document.getElementsByClassName("set-by-js")).to.have.length(1);
|
56 | });
|
57 |
|
58 | it("again", async () => {
|
59 | const browser = await Browser(app).navigateTo("/");
|
60 |
|
61 | await Script("../app/assets/scripts/main").run(browser.window);
|
62 |
|
63 | expect(browser.document.cookie).to.equal("");
|
64 | expect(browser.document.getElementsByClassName("set-by-js")).to.have.length(0);
|
65 | });
|
66 | });
|
67 | });
|
68 | ```
|
69 |
|
70 | # External scripts
|
71 |
|
72 | May we suggest you to use Wichita, the Tallahassee sidekick. It can be found here https://www.npmjs.com/package/@bonniernews/wichita
|