Configuring Captures

Add new Optic tasks and customize your Optic captures.

Optic Tasks

When you first setup Optic, a start task is added to your optic.yml file. The start task can be run using api start

name: Todo API
tasks:
start:
command: npm run server-start
baseUrl: 'http://localhost:3005'

You may also want a quick way to run your API tests, a Postman collection, etc through Optic. To make this simple, Optic lets you define as many custom tasks as you'd like:

name: Todo API
tasks:
start:
command: npm run server-start
baseUrl: 'http://localhost:3005'
test:
command: npm run testAPI
baseUrl: 'http://localhost:3005'

Each custom task is run with api run <task name> ie api run test

Ignoring API Paths

As you use Optic, you will probably realize there are some paths you'd like Optic to ignore. Examples include OPTIONS requests, .html, .js, .css files, or everything in your /public * folder. You an add ignore rules to your api.yml file:

name: Todo API
tasks:
start:
command: npm run server-start
baseUrl: 'http://localhost:3005'
ignoreRequests:
- OPTIONS * # Ignores all options requests
- GET /public/**

Rules are formatted like this: METHOD(s) path

You can add a list of methods ie GET POST PUT, use a single method ie GET and if you do not specify a method Optic will match them all.

The second part of the rule is a path following the path-to-regex expression format used by express-js. You can test you expressions here.