Skip to content

Commit c53a49d

Browse files
authored
fix: fix nightwatch template's compatibility with eslint plugin (#4622)
Fixes #4619 * fix: fix nightwatch template's compatibility with eslint plugin * test: should add eslint plugin **after** nightwatch plugin * fix: add _eslintrc.js
1 parent 5e819b5 commit c53a49d

File tree

10 files changed

+41
-27
lines changed

10 files changed

+41
-27
lines changed

packages/@vue/cli-plugin-e2e-nightwatch/__tests__/nightwatchPlugin.spec.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ describe('nightwatch e2e plugin', () => {
1212
project = await create('e2e-nightwatch', {
1313
plugins: {
1414
'@vue/cli-plugin-babel': {},
15-
'@vue/cli-plugin-e2e-nightwatch': {}
15+
'@vue/cli-plugin-e2e-nightwatch': {},
16+
'@vue/cli-plugin-eslint': {
17+
config: 'airbnb',
18+
lintOn: 'save'
19+
}
1620
}
1721
})
1822

packages/@vue/cli-plugin-e2e-nightwatch/generator/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ const { installedBrowsers } = require('@vue/cli-shared-utils')
22

33
module.exports = api => {
44
api.render('./template', {
5-
hasTS: api.hasPlugin('typescript')
5+
hasTS: api.hasPlugin('typescript'),
6+
hasESLint: api.hasPlugin('eslint')
67
})
78

89
// Use devDependencies to store latest version number so as to automate update
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<%_ if (hasESLint) { _%>
2+
module.exports = {
3+
rules: {
4+
'no-unused-expressions': 'off'
5+
}
6+
}
7+
<%_ } _%>

packages/@vue/cli-plugin-e2e-nightwatch/generator/template/tests/e2e/custom-assertions/elementCount.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
*/
1414

1515
exports.assertion = function elementCount (selectorOrObject, count) {
16-
let selector;
16+
let selector
1717

1818
// when called from a page object element or section
19-
if (typeof selectorOrObject == 'object' && selectorOrObject.selector) {
19+
if (typeof selectorOrObject === 'object' && selectorOrObject.selector) {
20+
// eslint-disable-next-line prefer-destructuring
2021
selector = selectorOrObject.selector
2122
} else {
2223
selector = selectorOrObject

packages/@vue/cli-plugin-e2e-nightwatch/generator/template/tests/e2e/custom-commands/customExecute.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
* @param {*} data
1414
*/
15-
exports.command = function(data) {
15+
exports.command = function command (data) {
1616
// Other Nightwatch commands are available via "this"
1717

1818
// .execute() inject a snippet of JavaScript into the page for execution.
@@ -22,16 +22,16 @@ exports.command = function(data) {
2222
//
2323
this.execute(
2424
// The function argument is converted to a string and sent to the browser
25-
function(argData) {return argData;},
25+
function (argData) { return argData },
2626

2727
// The arguments for the function to be sent to the browser are specified in this array
2828
[data],
2929

30-
function(result) {
31-
// The "result" object contains the result from the what we have sent back from the browser window
30+
function (result) {
31+
// The "result" object contains the result of what we have sent back from the browser window
3232
console.log('custom execute result:', result.value)
3333
}
34-
);
34+
)
3535

36-
return this;
37-
};
36+
return this
37+
}
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
2-
* A basic Nightwatch custom command which demonstrates usage of ES6 async/await instead of using callbacks.
2+
* A basic Nightwatch custom command
3+
* which demonstrates usage of ES6 async/await instead of using callbacks.
34
* The command name is the filename and the exported "command" function is the command.
45
*
56
* Example usage:
@@ -13,10 +14,10 @@ module.exports = {
1314
command: async function () {
1415
// Other Nightwatch commands are available via "this"
1516
// .init() simply calls .url() command with the value of the "launch_url" setting
16-
this.init();
17-
this.waitForElementVisible('#app');
17+
this.init()
18+
this.waitForElementVisible('#app')
1819

19-
const result = await this.elements('css selector', '#app ul');
20-
this.assert.strictEqual(result.value.length, 3);
20+
const result = await this.elements('css selector', '#app ul')
21+
this.assert.strictEqual(result.value.length, 3)
2122
}
22-
};
23+
}

packages/@vue/cli-plugin-e2e-nightwatch/generator/template/tests/e2e/custom-commands/openHomepageClass.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
*
1111
*/
1212

13-
const assert = require('assert');
13+
const assert = require('assert')
1414

1515
module.exports = class {
1616
async command () {
1717
// Other Nightwatch commands are available via "this.api"
18-
this.api.init();
19-
this.api.waitForElementVisible('#app');
18+
this.api.init()
19+
this.api.waitForElementVisible('#app')
2020

21-
const result = await this.api.elements('css selector', '#app ul');
22-
assert.strictEqual(result.value.length, 3);
21+
const result = await this.api.elements('css selector', '#app ul')
22+
assert.strictEqual(result.value.length, 3)
2323
}
24-
};
24+
}

packages/@vue/cli-plugin-e2e-nightwatch/generator/template/tests/e2e/globals.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = {
1818

1919
// default timeout value in milliseconds for waitFor commands and implicit waitFor value for
2020
// expect assertions
21-
waitForConditionTimeout : 5000,
21+
waitForConditionTimeout: 5000,
2222

2323
'default': {
2424
/*
@@ -101,4 +101,4 @@ module.exports = {
101101
cb();
102102
}
103103
*/
104-
};
104+
}

packages/@vue/cli-plugin-e2e-nightwatch/generator/template/tests/e2e/page-objects/homepage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ module.exports = {
4949
}
5050
}
5151
}
52-
};
52+
}

packages/@vue/cli-plugin-e2e-nightwatch/generator/template/tests/e2e/specs/test-with-pageobjects.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
const homepage = browser.page.homepage()
1414
homepage.waitForElementVisible('@appContainer')
1515

16-
const app = homepage.section.app;
16+
const app = homepage.section.app
1717
app.assert.elementCount('@logo', 1)
1818
app.expect.section('@welcome').to.be.visible
1919
app.expect.section('@headline').text.to.match(/^Welcome to Your Vue\.js (.*)App$/)

0 commit comments

Comments
 (0)