]> git.ipfire.org Git - thirdparty/vuejs/create-vue.git/commitdiff
feat: use type=module in nightwatch projects (#404)
authorCédric Exbrayat <cexbrayat@users.noreply.github.com>
Wed, 13 Dec 2023 08:26:20 +0000 (09:26 +0100)
committerGitHub <noreply@github.com>
Wed, 13 Dec 2023 08:26:20 +0000 (16:26 +0800)
Co-authored-by: Haoqun Jiang <haoqunjiang@gmail.com>
template/config/nightwatch/nightwatch.conf.cjs [moved from template/config/nightwatch/nightwatch.conf.js with 97% similarity]
template/config/nightwatch/nightwatch/custom-assertions/elementHasCount.js [deleted file]
template/config/nightwatch/nightwatch/custom-assertions/elementHasCount.ts [deleted file]
template/config/nightwatch/nightwatch/custom-commands/strictClick.js [deleted file]
template/config/nightwatch/nightwatch/custom-commands/strictClick.ts [deleted file]
template/config/nightwatch/nightwatch/nightwatch.d.ts
template/config/nightwatch/package.json

similarity index 97%
rename from template/config/nightwatch/nightwatch.conf.js
rename to template/config/nightwatch/nightwatch.conf.cjs
index 05889c61f6e023ce23b66ca069b629de4d29db72..542647e5e04158b947bfa4196c3bc62183e6f736 100644 (file)
@@ -21,10 +21,10 @@ module.exports = {
   page_objects_path: [],
 
   // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
-  custom_commands_path: ['nightwatch/custom-commands'],
+  custom_commands_path: [],
 
   // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
-  custom_assertions_path: ['nightwatch/custom-assertions'],
+  custom_assertions_path: [],
 
   // See https://nightwatchjs.org/guide/extending-nightwatch/adding-plugins.html
   plugins: ['@nightwatch/vue'],
diff --git a/template/config/nightwatch/nightwatch/custom-assertions/elementHasCount.js b/template/config/nightwatch/nightwatch/custom-assertions/elementHasCount.js
deleted file mode 100644 (file)
index 1ac2aa2..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * A custom Nightwatch assertion. The assertion name is the filename.
- *
- * Example usage:
- *   browser.assert.elementHasCount(selector, count)
- *
- * For more information on custom assertions see:
- *   https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
- *
- * @param {string} selector
- * @param {number} count
- */
-
-exports.assertion = function elementHasCount(selector, count) {
-  // Message to be displayed on the console while running this assertion.
-  this.message = `Testing if element <${selector}> has count: ${count}`
-
-  // Expected value of the assertion, to be displayed in case of failure.
-  this.expected = count
-
-  // Given the result value (from `this.value` below), this function will
-  // evaluate if the assertion has passed.
-  this.evaluate = function (value) {
-    return value === count
-  }
-
-  // Retrieve the value from the result object we got after running the
-  // assertion command (defined below), which is to be evaluated against
-  // the value passed into the assertion as the second argument.
-  this.value = function (result) {
-    return result.value
-  }
-
-  // Script to be executed in the browser to find the actual element count.
-  function elementCountScript(_selector) {
-    // eslint-disable-next-line
-    return document.querySelectorAll(_selector).length
-  }
-
-  // The command to be executed by the assertion runner, to find the actual
-  // result. Nightwatch API is available as `this.api`.
-  this.command = function (callback) {
-    this.api.execute(elementCountScript, [selector], callback)
-  }
-}
diff --git a/template/config/nightwatch/nightwatch/custom-assertions/elementHasCount.ts b/template/config/nightwatch/nightwatch/custom-assertions/elementHasCount.ts
deleted file mode 100644 (file)
index 1357728..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * A custom Nightwatch assertion. The assertion name is the filename.
- *
- * Example usage:
- *   browser.assert.elementHasCount(selector, count)
- *
- * For more information on custom assertions see:
- *   https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
- *
- */
-
-exports.assertion = function elementHasCount(selector: string, count: number) {
-  // Message to be displayed on the console while running this assertion.
-  this.message = `Testing if element <${selector}> has count: ${count}`
-
-  // Expected value of the assertion, to be displayed in case of failure.
-  this.expected = count
-
-  // Given the result value (from `this.value` below), this function will
-  // evaluate if the assertion has passed.
-  this.evaluate = function (value: any) {
-    return value === count
-  }
-
-  // Retrieve the value from the result object we got after running the
-  // assertion command (defined below), which is to be evaluated against
-  // the value passed into the assertion as the second argument.
-  this.value = function (result: Record<string, any>) {
-    return result.value
-  }
-
-  // Script to be executed in the browser to find the actual element count.
-  function elementCountScript(_selector: string) {
-    // eslint-disable-next-line
-    return document.querySelectorAll(_selector).length
-  }
-
-  // The command to be executed by the assertion runner, to find the actual
-  // result. Nightwatch API is available as `this.api`.
-  this.command = function (callback: () => void) {
-    this.api.execute(elementCountScript, [selector], callback)
-  }
-}
diff --git a/template/config/nightwatch/nightwatch/custom-commands/strictClick.js b/template/config/nightwatch/nightwatch/custom-commands/strictClick.js
deleted file mode 100644 (file)
index f342044..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * A non-class-based custom-command in Nightwatch. The command name is the filename.
- *
- * Usage:
- *   browser.strictClick(selector)
- *
- * This command is not used yet used in any of the examples.
- *
- * For more information on working with custom-commands see:
- *   https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
- *
- * @param {string} selector
- */
-
-module.exports = {
-  command: function (selector) {
-    return this.waitForElementVisible(selector).click(selector)
-  }
-}
diff --git a/template/config/nightwatch/nightwatch/custom-commands/strictClick.ts b/template/config/nightwatch/nightwatch/custom-commands/strictClick.ts
deleted file mode 100644 (file)
index 37b4920..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * A non-class-based custom-command in Nightwatch. The command name is the filename.
- *
- * Usage:
- *   browser.strictClick(selector)
- *
- * This command is not used yet used in any of the examples.
- *
- * For more information on working with custom-commands see:
- *   https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
- *
- */
-
-module.exports = {
-  command: function (selector: string) {
-    return this.waitForElementVisible(selector).click(selector)
-  }
-}
index ea1f60661c53013c378d8f96f6bd2dc3d9b010c5..616e63f9f9b5bf19d4d9fcf40944f3b23f20c8ba 100644 (file)
@@ -2,10 +2,12 @@ import { NightwatchCustomAssertions, NightwatchCustomCommands } from 'nightwatch
 
 declare module 'nightwatch' {
   interface NightwatchCustomAssertions {
-    elementHasCount: (selector: string, count: number) => NightwatchBrowser
+    // Add your custom assertions' types here
+    // elementHasCount: (selector: string, count: number) => NightwatchBrowser
   }
 
   interface NightwatchCustomCommands {
-    strictClick: (selector: string) => NightwatchBrowser
+    // Add your custom commands' types here
+    // strictClick: (selector: string) => NightwatchBrowser
   }
 }
index 62828e38b9cd8864684ac2d41c1a81f06cf515e8..ce5fa758bf67ba7c8833b91731944937ff814ff4 100644 (file)
@@ -1,5 +1,4 @@
 {
-  "type": "commonjs",
   "scripts": {
     "test:e2e": "nightwatch tests/e2e/*"
   },