0.0.8 • Published 1 year ago

play-urls v0.0.8

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
1 year ago

GitHub package.json version

Play-URLs

a simple and quick way to verify proper status/content of many urls

how to use

  1. npm i -D play-urls / yarn -D play-urls
  2. create a .play-urls.config.ts (or .js) in your project root
  3. define the config (see plain configuration)

note: if integrated into a pipeline it's recommended to use the playwright docker image and install this package with --ignore-scripts flag

plain configuration

import defineConfig from play-urls and configure everything required (it's typed, just check via intellisense ;), otherwise check the types). also this library allows a file-based url configuration via defineUrl (recognized via urlGlob-option within the config)

// .play-urls.config.ts
import { defineConfig } from 'play-urls/define';

export default defineConfig({
  browsers: ['chromium'],
  browserConfig: {
    headless: !!process.env.CI,
  },
  urlGlob: 'src/**/*.play-urls.spec.{js,ts}',
  urls: [
    {
      url: 'https://example.com',
      name: 'example-com',
    },
  ],
});
// some.play-urls.spec.ts
import { defineUrl } from 'play-urls/define';

export default defineUrl({
  url: 'https://google.com',
  name: 'example-com-from-file',
});

note: it's highly recommended to use .(test|spec).{js,ts} or any other test-file naming convention to easily exclude these files from linters (such as ESLint) and show that they're testing files and no actual source files

run via JS/TS

you can run it also via js/ts, just import run from play-urls

import { run } from 'play-urls';

// somewhere
run();

// or with inline config

run({
  browsers: ['chromium'],
  // ...
});

CLI args / envs

argenvdefaultdefinition
--configCONFIG.play-urls.configoverwrite the default filename/-path of the config
--urlglobURLGLOB- (none)overwrite the urlGlob (this one is preferred over the config one if both provided)
--errorlogERRORLOGplay-urls-errors.jsonoverwrite the errorLog (this one is preferred over the config one if both provided)
## examples ##

## config
# via env
CONFIG=my.config npx play-urls

# via arg
npx play-urls --config my.config

## urlglob
# via env
URLGLOB="src/**/*.my-url.spec.{ts,js}" npx play-urls

# via arg
npx play-urls --urlglob "src/**/*.my-url.spec.{ts,js}"

## errorLog
# via env
ERRORLOG="custom-errors.json" npx play-urls

# via arg
npx play-urls --errorlog "custom-errors.json"

note: if env and arg are passed at once (let's say CONFIG=... and --config ...) env will be preferred!

0.0.8

1 year ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago