Skip to content

fix: fix nightwatch template's compatibility with eslint plugin #4622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ describe('nightwatch e2e plugin', () => {
project = await create('e2e-nightwatch', {
plugins: {
'@vue/cli-plugin-babel': {},
'@vue/cli-plugin-e2e-nightwatch': {}
'@vue/cli-plugin-e2e-nightwatch': {},
'@vue/cli-plugin-eslint': {
config: 'airbnb',
lintOn: 'save'
}
}
})

Expand Down
3 changes: 2 additions & 1 deletion packages/@vue/cli-plugin-e2e-nightwatch/generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ const { installedBrowsers } = require('@vue/cli-shared-utils')

module.exports = api => {
api.render('./template', {
hasTS: api.hasPlugin('typescript')
hasTS: api.hasPlugin('typescript'),
hasESLint: api.hasPlugin('eslint')
})

// Use devDependencies to store latest version number so as to automate update
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<%_ if (hasESLint) { _%>
module.exports = {
rules: {
'no-unused-expressions': 'off'
}
}
<%_ } _%>
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
*/

exports.assertion = function elementCount (selectorOrObject, count) {
let selector;
let selector

// when called from a page object element or section
if (typeof selectorOrObject == 'object' && selectorOrObject.selector) {
if (typeof selectorOrObject === 'object' && selectorOrObject.selector) {
// eslint-disable-next-line prefer-destructuring
selector = selectorOrObject.selector
} else {
selector = selectorOrObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* @param {*} data
*/
exports.command = function(data) {
exports.command = function command (data) {
// Other Nightwatch commands are available via "this"

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

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

function(result) {
// The "result" object contains the result from the what we have sent back from the browser window
function (result) {
// The "result" object contains the result of what we have sent back from the browser window
console.log('custom execute result:', result.value)
}
);
)

return this;
};
return this
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* A basic Nightwatch custom command which demonstrates usage of ES6 async/await instead of using callbacks.
* A basic Nightwatch custom command
* which demonstrates usage of ES6 async/await instead of using callbacks.
* The command name is the filename and the exported "command" function is the command.
*
* Example usage:
Expand All @@ -13,10 +14,10 @@ module.exports = {
command: async function () {
// Other Nightwatch commands are available via "this"
// .init() simply calls .url() command with the value of the "launch_url" setting
this.init();
this.waitForElementVisible('#app');
this.init()
this.waitForElementVisible('#app')

const result = await this.elements('css selector', '#app ul');
this.assert.strictEqual(result.value.length, 3);
const result = await this.elements('css selector', '#app ul')
this.assert.strictEqual(result.value.length, 3)
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
*
*/

const assert = require('assert');
const assert = require('assert')

module.exports = class {
async command () {
// Other Nightwatch commands are available via "this.api"
this.api.init();
this.api.waitForElementVisible('#app');
this.api.init()
this.api.waitForElementVisible('#app')

const result = await this.api.elements('css selector', '#app ul');
assert.strictEqual(result.value.length, 3);
const result = await this.api.elements('css selector', '#app ul')
assert.strictEqual(result.value.length, 3)
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {

// default timeout value in milliseconds for waitFor commands and implicit waitFor value for
// expect assertions
waitForConditionTimeout : 5000,
waitForConditionTimeout: 5000,

'default': {
/*
Expand Down Expand Up @@ -101,4 +101,4 @@ module.exports = {
cb();
}
*/
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ module.exports = {
}
}
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
const homepage = browser.page.homepage()
homepage.waitForElementVisible('@appContainer')

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