diff --git a/guide/configuration/settings.md b/guide/configuration/settings.md index 8e7a1215..f568b8af 100644 --- a/guide/configuration/settings.md +++ b/guide/configuration/settings.md @@ -73,13 +73,13 @@ Below are the default settings that will be passed to the Nightwatch instance du - `backwards_compatibility_mode`
since v1.2.2 + `backwards_compatibility_mode`
since v2.0 boolean false In Nightwatch v1.x, when used with `await` operator, API commands will return the full result object as `{value: ``}` whereas in v2, the value is return directly. If using a callback, the behaviour remains unchanged. - `disable_global_apis`
since v1.2.2 + `disable_global_apis`
since v2.0 boolean false Disable the global apis like `"browser"`, `"element()"`, `"expect()"`; this might be needed if using Nightwatch with third-party libraries. @@ -117,7 +117,7 @@ The below settings are used to control the way the built-in CLI test runner work - `enable_fail_fast`
since v1.2.2 + `enable_fail_fast`
since v2.0 boolean false Enable aborting the test run execution when the first test failure occurs; the remaining test suites will be skipped. diff --git a/guide/extending-nightwatch/plugin-api.md b/guide/extending-nightwatch/plugin-api.md index f9a28107..915bb96f 100644 --- a/guide/extending-nightwatch/plugin-api.md +++ b/guide/extending-nightwatch/plugin-api.md @@ -1,36 +1,50 @@ -## Plugin API (alpha) +## Plugin API (beta) Nightwatch `v2.0` also introduces a new interface for defining plugins and extending the base functionality of Nightwatch with your own custom commands and assertions. -Plugins are essentially wrappers over custom commands and assertions. Plugins are installed in your `node_modules` folder. +Plugins are essentially wrappers over custom commands and assertions. Plugins are installed in your `node_modules` folder. The plugin API is still in beta at the moment. -#### Authoring a New Nightwatch Plugin +#### Authoring a Nightwatch plugin +If you're new to publishing NPM packages, read the [Creating and publishing unscoped public packages](https://docs.npmjs.com/creating-and-publishing-unscoped-public-packages) guide first. -#### Using The `--reporter` command-line argument -Define your reporter in a separate file, using the below interface, and then specify the path to the file using the `--reporter` cli argument. +A Nightwatch plugin needs to be installed from NPM in the same project where Nightwatch is used (or as a global NPM package). -##### Interface: -
-

-module.exports = {
-  write : function(results, options, done) {
-    done();
-  }
-};
-
+##### Folder structure: +The folder structure is very simple and looks like this: -#### The `reporter` method in your external globals +
+nightwatch/
+  ├── custom-commands/
+  |   ├── my_new_custom_command.js
+  |   └── my_other_custom_command.js
+  ├── custom-assertions/
+  |   ├── my_new_custom_assertions.js
+  |   └── my_other_custom_command.js
+  ├── index.js
+  ├── LICENSE.md
+  ├── package.json
+  └── README.md
+
-Add your reporter in the external globals file. Read more about [external globals](/guide/using-nightwatch/external-globals.html). +The Nightwatch runner will pick up the custom commands and assertions automatically if the plugin is defined with the above structure. -See the provided [globalsModule.js](https://github.com/nightwatchjs/nightwatch/blob/main/examples/globalsModule.js) for an example. +#### Installing a new plugin +Once the plugin will is available in NPM (or another package repository), you can simply install it in your project folder and then update the Nightwatch config file by adding it to the `plugins` Array. -#### Example: -
-

-module.exports = {
-  reporter : function(results, done) {
-    console.log(results);
-    done();
-  }
-};
-
+First, install the plugin from NPM: + +
npm i my-new-plugin --save-dev
+ +Then update your `nightwatch.conf.js` (or `nightwatch.json`) and add it to the `plugins` list: + +
{
+  src_folders: [...],
+    
+  plugins: ['my-new-plugin']
+  
+  // other nightwatch config options
+
+}
+
+ +#### Example +See our new `Vite` plugin [vite-plugin-nightwatch](https://github.com/nightwatchjs/vite-plugin-nightwatch) for an example.