Skip to content

Commit

Permalink
fix bugs and add end to end tests
Browse files Browse the repository at this point in the history
  • Loading branch information
swrdfish committed Mar 28, 2023
1 parent add8c9b commit 8375245
Show file tree
Hide file tree
Showing 18 changed files with 3,837 additions and 122 deletions.
129 changes: 129 additions & 0 deletions nightwatch.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
const setup = require('./src/setup');
const teardown = require('./src/teardown');

//
// Refer to the online docs for more details:
// https://nightwatchjs.org/guide/configuration/nightwatch-configuration-file.html
//
// _ _ _ _ _ _ _
// | \ | |(_) | | | | | | | |
// | \| | _ __ _ | |__ | |_ __ __ __ _ | |_ ___ | |__
// | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \
// | |\ || || (_| || | | || |_ \ V V / | (_| || |_ | (__ | | | |
// \_| \_/|_| \__, ||_| |_| \__| \_/\_/ \__,_| \__| \___||_| |_|
// __/ |
// |___/
//

module.exports = {
// An array of folders (excluding subfolders) where your tests are located;
// if this is not specified, the test source must be passed as the second argument to the test runner.
src_folders: ['test/e2e'],

// See https://nightwatchjs.org/guide/concepts/page-object-model.html
page_objects_path: [],

// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
custom_commands_path: ['nightwatch/commands'],

// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
custom_assertions_path: '',

// See https://nightwatchjs.org/guide/extending-nightwatch/adding-plugins.html
plugins: [],

// See https://nightwatchjs.org/guide/concepts/test-globals.html#external-test-globals
globals_path: '',

globals: {
async before() {
await setup(this.settings);
},

async after() {
await teardown();
}
},

'@nightwatch/angular': {
projectRoot: '/Users/binayakghosh/projects/nightwatch-plugin-angular/sandbox-v15'
},

webdriver: {},

test_workers: {
enabled: true,
workers: 'auto'
},

test_settings: {
default: {
disable_error_log: false,
launch_url: 'https://nightwatchjs.org',

screenshots: {
enabled: false,
path: 'screens',
on_failure: true
},

desiredCapabilities: {
browserName: 'firefox'
},

webdriver: {
start_process: true,
server_path: ''
}
},

firefox: {
desiredCapabilities: {
browserName: 'firefox',
alwaysMatch: {
acceptInsecureCerts: true,
'moz:firefoxOptions': {
args: [
// '-headless',
// '-verbose'
]
}
}
},
webdriver: {
start_process: true,
server_path: '',
cli_args: [
// very verbose geckodriver logs
// '-vv'
]
}
},

chrome: {
desiredCapabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
// More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
//
// w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
w3c: true,
args: [
//'--no-sandbox',
//'--ignore-certificate-errors',
//'--allow-insecure-localhost',
//'--headless'
]
}
},

webdriver: {
start_process: true,
server_path: '',
cli_args: [
// --verbose
]
}
}
}
};
16 changes: 10 additions & 6 deletions nightwatch/commands/mountComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = class Command {
return this.client.settings['@nightwatch/angular'] || {};
}

getError(message) {
#getError(message) {
const err = new NightwatchMountError(message);

err.showTrace = false;
Expand All @@ -28,7 +28,11 @@ module.exports = class Command {
return err;
}

static _normaliseComponentPath(componentPath) {
#normaliseComponentPath(componentPath) {
if (!path.isAbsolute(componentPath)) {
componentPath = path.resolve(this.pluginSettings.projectRoot, componentPath);
}

const parts = path.parse(componentPath);

if (parts.ext === '.ts') {
Expand Down Expand Up @@ -57,7 +61,7 @@ module.exports = class Command {

componentPath =
await fs.writeFile(mountPointPath, `
import * as MountComponent from '${Command._normaliseComponentPath(componentPath)}'
import * as MountComponent from '${this.#normaliseComponentPath(componentPath)}'
const classes = Object.keys(MountComponent)
Expand Down Expand Up @@ -98,10 +102,10 @@ module.exports = class Command {
return document.querySelectorAll('#root0')[0].firstElementChild;
});

if (!result) {
const err = this.getError('Could not mount the component.');
if (!result || result.error) {
const err = this.#getError('Could not mount the component.');

return err;
throw err;
}

const componentInstance = this.api.createElement(result, {
Expand Down
2 changes: 1 addition & 1 deletion nightwatch/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
},

async before(settings) {
if (!settings.parallel_mode && !settings.testWorkersEnabled) {
if (settings && !settings.parallel_mode && !settings.testWorkersEnabled) {
await setup(settings);
}
},
Expand Down
Loading

0 comments on commit 8375245

Please sign in to comment.