1.9.4-tractor-to-playwright.0 • Published 3 years ago

@tractor/plugin-loader v1.9.4-tractor-to-playwright.0

Weekly downloads
166
License
MIT
Repository
github
Last release
3 years ago

@tractor/plugin-loader

Plugin loader for tractor to provide additional UI testing capabilities.

npm version

API

loadPlugins (config: TractorPluginConfig): Array<TractorPlugin>

Loads all available tractor plugins for a project.

import { loadConfig } from '@tractor/config-loader';
import { loadPlugins } from '@tractor/plugin-loader';

const config = loadConfig(process.cwd(), './path/to/tractor.conf.js');
const plugins = loadPlugins(config);

getPlugins (): Array<TractorPlugin

Retrieves the current plugins for the running Tractor instance. loadPlugins() must be called befere calling getPlugins().

import { getPlugins } from '@tractor/plugin-loader';

const plugins = getPlugins();

How it works

Whenever tractor is run, the loader looks through your installed node modules, and finds any that are called @tractor-plugin/whatever. Those plugins could provide new actions for tests, new testing styles, or entirely new bits of UI/Functionality for the @tractor/ui application, all depending on what the plugin exports.

Plugin

A tractor plugin is just a plain old node module, with a few specially named exports, and maybe some bundled UI code. If you want to see an example of a basic plugin, check out tractor-plugin-browser. A plugin looks something like this:

import { Config } from 'protractor';

export type TractorPlugin<T> = {
    description: {
        actions: Array<TractorAction>
    };

    create (): T;
    init (): Promise<void> | void;
    plugin (protractorConfig: Config): Config;
    run (): Promise<void> | void;
    serve (): Promise<void> | void;
    upgrade (): Promise<void> | void;
};

description (optional)

The description of the plugin object. Check out the type signature in more details here.

create (optional)

Defines how an instance of the plugin will be instantiated when Protractor runs. It should return a concrete implementation of each of the description.

init (optional)

Initialise anything that the plugin needs before it runs. This may be things like creating directories or getting information about the current environment, before tractor starts running.

plugin (optional)

Modify the portractorConfig before Protractor runs. This is where the plugin should set up any Protractor plugins that it needs. To see an example of how this works, check out @tractor-plugin/mocha-specs.

run (optional)

Run any extra code the need before the app server starts. At the point that this is called all other plugins have been initialised and served.

serve (optional)

Define any new endpoints that the plugin needs to attach to the @tractor/server, typically for consuming from the @tractor/ui.

UI Script (optional)

A plugin can also contain UI code. The loader looks for a file at @tractor-plugin/my-plugin/dist/client/bundle.js and injects that into the @tractor/ui when it is served. It is run before the bootstrapping of the Angular application, so it can set-up routes etc. To see an example of how this works, check out @tractor-plugin/visual-regression.

1.9.6-alpha.0

3 years ago

1.9.4

3 years ago

1.9.4-alpha.4

3 years ago

1.9.4-alpha.0

4 years ago

1.9.3-alpha.0

4 years ago

1.9.3

4 years ago

1.9.2

4 years ago

1.9.1-alpha.1

4 years ago

1.9.1

4 years ago

1.9.2-alpha.0

4 years ago

1.9.0

4 years ago

1.9.0-alpha.3

4 years ago

1.9.0-alpha.0

4 years ago

1.9.0-alpha.1

4 years ago

1.8.0

4 years ago

1.8.0-alpha.0

4 years ago

1.7.8

4 years ago

1.7.8-alpha.2

4 years ago

1.7.8-alpha.1

4 years ago

1.7.7-alpha.0

4 years ago

1.7.8-alpha.0

4 years ago

1.7.6-alpha.0

4 years ago

1.7.0

5 years ago

1.6.1

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.2

5 years ago

1.1.0

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.1

5 years ago

1.0.1-beta.10

6 years ago

1.0.1-beta.9

6 years ago

1.0.1-beta.8

6 years ago

1.0.1-beta.7

6 years ago

1.0.1-beta.3

6 years ago

1.0.1-beta.2

6 years ago

1.0.1-beta.1

6 years ago

1.0.1-beta.0

6 years ago

1.0.0-alpha.15

6 years ago

1.0.0-alpha.14

6 years ago

1.0.0-alpha.13

6 years ago

1.0.0-alpha.12

6 years ago

1.0.0-alpha.11

6 years ago

1.0.0-alpha.10

6 years ago

1.0.0-alpha.6

6 years ago

1.0.0-alpha.5

6 years ago

1.0.0-alpha.4

6 years ago

1.0.0-alpha.2

6 years ago