Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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