cyclopes

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_URL = "http://localhost:3000"

Variables

This section is empty.

Functions

func CheckPath

func CheckPath(path string) error

CheckPath checks if path exists, else creates it

func ConstructServerURL

func ConstructServerURL(rawURL string) (string, error)

ConstructServerURL is cleaning server urls so: 1. To allow users even define localhost:3000 and still work

  1. Remove trailing slash from URL

func GeneratorCLI added in v0.1.3

func GeneratorCLI()

GeneratorCLI is a helper CLI function to generate a cyclopes.yml file

func SaveFile

func SaveFile(image []byte, path string, filename string) error

SaveFile save an image to local storage

func Screenshot

func Screenshot(
	ctx context.Context,
	config *Configuration,
	pageConfig *PageConfig)

Screenshot takes a screenshot for a specific PageConfig

func Server

func Server(path string) *http.Server

Server spins-up a local server on :3000 to serve the static files, if the Website is not published yet nor served from a local server

func Start

func Start(configPath string)

Start is the main starting point of the visual testing application

Types

type Configuration

type Configuration struct {
	// Directory to save/retrieve images
	ImagesDir string `yaml:"imagesDir"`
	Visual    *VisualTesting

	Adapters map[string]interface{}
	// contains filtered or unexported fields
}

Configuration struct

func (*Configuration) ExtractServerURL

func (config *Configuration) ExtractServerURL() string

ExtractServerURL is returning: 1: the default server url if the user has not defined a remoteURL 2: the user's remoteURL if it is defined

type DEVICE

type DEVICE string

DEVICE The screenshot type

const (
	DESKTOP DEVICE = "desktop"
	MOBILE  DEVICE = "mobile"
	BOTH    DEVICE = "both"
)

type PageConfig

type PageConfig struct {
	// Relative path to visit
	Path string
	// Device to screenshot
	Device DEVICE
	// Delay in ms
	Delay int
	// Code (Javascript code to execute)
	Code string
	// Selector to wait
	WaitSelector string `yaml:"waitSelector"`
	// If the screenshot should be fullpage or viewport
	Screenshot SCREENSHOTSIZE
}

PageConfig is a struct holding information about individual pages that will be screenshotted

type SCREENSHOTSIZE

type SCREENSHOTSIZE string

SCREENSHOTSIZE Fullpage or Viewport screenshot

const FULLPAGE SCREENSHOTSIZE = "fullpage"
const VIEWPORT SCREENSHOTSIZE = "viewport"

type VisualTesting

type VisualTesting struct {
	Pages []PageConfig

	// If users want to debug
	Headless *bool

	// Base url to visit in our session
	RemoteURL string `yaml:"remoteURL" head_comment:"Enable or disable."`

	// BuildDir is used only if
	// remoteURL is not defined
	// (to serve the static assets)
	// served on localhost:3000
	BuildDir string `yaml:"buildDir"`
}

VisualTesting is a struct holding information about visual testing sessions

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL