Prettify codebase
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
module.exports = {
|
||||
rules: {
|
||||
"no-unused-expressions": "off"
|
||||
'no-unused-expressions': 'off'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -13,22 +13,22 @@
|
||||
*/
|
||||
|
||||
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;
|
||||
selector = selectorOrObject.selector
|
||||
} else {
|
||||
selector = selectorOrObject;
|
||||
selector = selectorOrObject
|
||||
}
|
||||
|
||||
this.message = `Testing if element <${selector}> has count: ${count}`;
|
||||
this.expected = count;
|
||||
this.pass = val => val === count;
|
||||
this.value = res => res.value;
|
||||
this.message = `Testing if element <${selector}> has count: ${count}`
|
||||
this.expected = count
|
||||
this.pass = (val) => val === count
|
||||
this.value = (res) => res.value
|
||||
function evaluator(_selector) {
|
||||
return document.querySelectorAll(_selector).length;
|
||||
return document.querySelectorAll(_selector).length
|
||||
}
|
||||
this.command = cb => this.api.execute(evaluator, [selector], cb);
|
||||
};
|
||||
this.command = (cb) => this.api.execute(evaluator, [selector], cb)
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ exports.command = function command(data) {
|
||||
this.execute(
|
||||
// The function argument is converted to a string and sent to the browser
|
||||
function(argData) {
|
||||
return argData;
|
||||
return argData
|
||||
},
|
||||
|
||||
// The arguments for the function to be sent to the browser are specified in this array
|
||||
@ -31,9 +31,9 @@ exports.command = function command(data) {
|
||||
|
||||
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);
|
||||
console.log('custom execute result:', result.value)
|
||||
}
|
||||
);
|
||||
)
|
||||
|
||||
return this;
|
||||
};
|
||||
return this
|
||||
}
|
||||
|
@ -14,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)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -100,4 +100,4 @@ module.exports = {
|
||||
cb();
|
||||
}
|
||||
*/
|
||||
};
|
||||
}
|
||||
|
@ -10,38 +10,38 @@
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
url: "/",
|
||||
url: '/',
|
||||
commands: [],
|
||||
|
||||
// A page object can have elements
|
||||
elements: {
|
||||
appContainer: "#app"
|
||||
appContainer: '#app'
|
||||
},
|
||||
|
||||
// Or a page objects can also have sections
|
||||
sections: {
|
||||
app: {
|
||||
selector: "#app",
|
||||
selector: '#app',
|
||||
|
||||
elements: {
|
||||
logo: "img"
|
||||
logo: 'img'
|
||||
},
|
||||
|
||||
// - a page object section can also have sub-sections
|
||||
// - elements or sub-sections located here are retrieved using the "app" section as the base
|
||||
sections: {
|
||||
headline: {
|
||||
selector: "h1"
|
||||
selector: 'h1'
|
||||
},
|
||||
|
||||
welcome: {
|
||||
// the equivalent css selector for the "welcome" sub-section would be:
|
||||
// '#app div.hello'
|
||||
selector: "div.hello",
|
||||
selector: 'div.hello',
|
||||
|
||||
elements: {
|
||||
cliPluginLinks: {
|
||||
selector: "ul",
|
||||
selector: 'ul',
|
||||
index: 0
|
||||
}
|
||||
}
|
||||
@ -49,4 +49,4 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -7,28 +7,30 @@
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
module.exports = {
|
||||
beforeEach: browser => browser.init(),
|
||||
beforeEach: (browser) => browser.init(),
|
||||
|
||||
"e2e tests using page objects": browser => {
|
||||
const homepage = browser.page.homepage();
|
||||
homepage.waitForElementVisible("@appContainer");
|
||||
'e2e tests using page objects': (browser) => {
|
||||
const homepage = browser.page.homepage()
|
||||
homepage.waitForElementVisible('@appContainer')
|
||||
|
||||
const app = homepage.section.app;
|
||||
app.assert.elementCount("@logo", 1);
|
||||
app.expect.section("@welcome").to.be.visible;
|
||||
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$/);
|
||||
.section('@headline')
|
||||
.text.to.match(/^Welcome to Your Vue\.js (.*)App$/)
|
||||
|
||||
browser.end();
|
||||
browser.end()
|
||||
},
|
||||
|
||||
'verify if string "e2e-nightwatch" is within the cli plugin links': browser => {
|
||||
const homepage = browser.page.homepage();
|
||||
const welcomeSection = homepage.section.app.section.welcome;
|
||||
'verify if string "e2e-nightwatch" is within the cli plugin links': (
|
||||
browser
|
||||
) => {
|
||||
const homepage = browser.page.homepage()
|
||||
const welcomeSection = homepage.section.app.section.welcome
|
||||
|
||||
welcomeSection.expect
|
||||
.element("@cliPluginLinks")
|
||||
.text.to.contain("e2e-nightwatch");
|
||||
.element('@cliPluginLinks')
|
||||
.text.to.contain('e2e-nightwatch')
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -2,20 +2,20 @@
|
||||
// https://nightwatchjs.org/guide
|
||||
|
||||
module.exports = {
|
||||
"default e2e tests": browser => {
|
||||
'default e2e tests': (browser) => {
|
||||
browser
|
||||
.init()
|
||||
.waitForElementVisible("#app")
|
||||
.assert.elementPresent(".hello")
|
||||
.assert.containsText("h1", "Welcome to Your Vue.js App")
|
||||
.assert.elementCount("img", 1)
|
||||
.end();
|
||||
.waitForElementVisible('#app')
|
||||
.assert.elementPresent('.hello')
|
||||
.assert.containsText('h1', 'Welcome to Your Vue.js App')
|
||||
.assert.elementCount('img', 1)
|
||||
.end()
|
||||
},
|
||||
|
||||
"example e2e test using a custom command": browser => {
|
||||
'example e2e test using a custom command': (browser) => {
|
||||
browser
|
||||
.openHomepage()
|
||||
.assert.elementPresent(".hello")
|
||||
.end();
|
||||
.assert.elementPresent('.hello')
|
||||
.end()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { shallowMount } from "@vue/test-utils";
|
||||
import HelloWorld from "@/components/HelloWorld.vue";
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import HelloWorld from '@/components/HelloWorld.vue'
|
||||
|
||||
describe("HelloWorld.vue", () => {
|
||||
it("renders props.msg when passed", () => {
|
||||
const msg = "new message";
|
||||
describe('HelloWorld.vue', () => {
|
||||
it('renders props.msg when passed', () => {
|
||||
const msg = 'new message'
|
||||
const wrapper = shallowMount(HelloWorld, {
|
||||
propsData: { msg }
|
||||
});
|
||||
expect(wrapper.text()).toMatch(msg);
|
||||
});
|
||||
});
|
||||
})
|
||||
expect(wrapper.text()).toMatch(msg)
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user