Skip to content

Instantly share code, notes, and snippets.

@domenkozar
Created January 28, 2021 11:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domenkozar/71135bf7aa6d50d6911fb74f4dcb4bad to your computer and use it in GitHub Desktop.
Save domenkozar/71135bf7aa6d50d6911fb74f4dcb4bad to your computer and use it in GitHub Desktop.
Automated testing for 404/500 errors
module Spec where
import Quickstrom
import Data.Foldable (any)
import Data.Maybe (maybe)
import Data.Tuple (Tuple(..))
import Data.String.CodeUnits (contains)
import Data.String.Pattern (Pattern(..))
readyWhen = "body"
actions = [
Tuple 1 (Single $ Click "a[href^='/']")
]
patterns = [ "404", "500" ]
hasErrorCode = any (\x -> contains (Pattern x) pageText) patterns
pageText :: String
pageText = maybe "" _.textContent (queryOne "body" { textContent })
proposition = always (not hasErrorCode)
name: "Test landing page for errors"
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: cachix/install-nix-action@v12
- uses: cachix/cachix-action@v8
with:
name: quickstrom
- run: nix-env -iA quickstrom -f https://github.com/quickstrom/quickstrom/tarball/main
- run: nix-env -i geckodriver -f https://github.com/NixOS/nixpkgs/tarball/nixos-20.09
- run: geckodriver&
- run: quickstrom check cachix.org.spec.purs https://cachix.org
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment