Skip to content
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

Plain JS config: How to load plugins? #53

Closed
dwbruhn opened this issue Dec 7, 2018 · 3 comments
Closed

Plain JS config: How to load plugins? #53

dwbruhn opened this issue Dec 7, 2018 · 3 comments

Comments

@dwbruhn
Copy link
Collaborator

dwbruhn commented Dec 7, 2018

The plain JS config example creates the plugin section as follows:

module.exports = {
    plugins: {
        view: {
            module: "nemo-view"
        }
    },

But nemo.view is undefined:

describe('@firstTest@', function () {
  it('should load a website', async function () {
    console.log('NEMO VIEW', this.nemo.view);
    await this.nemo.driver.get(this.nemo.data.baseUrl);
  });
});

Output:

NEMO VIEW undefined

I've tried both module: require.resolve("nemo-view") and module: require("nemo-view") but neither gets nemo-view to load.

Enabling DEBUG=nemo-core:log only shows snap being loaded:

nemo-core:log register plugin snap +0ms
  nemo-core:log plugin.registration fulfill with 1 plugins. +1ms
@dwbruhn
Copy link
Collaborator Author

dwbruhn commented Dec 7, 2018

So far I've tracked it down to this function:

nemo/lib/runner/mocha.js

Lines 46 to 48 in aaec89b

.then((nemoCoreConfig) => {
NemoBaseConfig.merge(nemoCoreConfig);
return NemoCore(NemoBaseConfig);

When running with a JSON config, the nemoCoreConfig has nemo-view in the plugins section:

nemoCoreConfig plugins:  { view:
   { module: 'nemo-view',

But when running with plain JS, the plugins section of nemoCoreConfig is undefined:

nemoCoreConfig plugins:  undefined

(In both cases, snap is in the NemoBaseConfig which gets merged with the nemoCoreConfig.)

@dwbruhn
Copy link
Collaborator Author

dwbruhn commented Dec 8, 2018

So here's the problem:

nemo/lib/runner/mocha.js

Lines 40 to 44 in aaec89b

// plain JS config use case
return NemoCore.Configure({
driver: driverConf,
data: dataConf
});

If there's no instanceConfig.basedir (which is the case when you're using an explicit/implicit config file), this generates a nemoCoreConfig with no plugin information.

One possible (and kinda ugly) fix is to pass program.configFile all the way down here so if instanceConfig.basedir is undefined, it will read the config from the config file instead. This like what's being done in _nemo:

nemo/bin/_nemo

Lines 87 to 99 in aaec89b

if (program.baseDirectory) {
// baseDirectory case
return NemoFactory.configure(program);
}
else if (program.configFile) {
// explicit config file case
return NemoFactory.configureJS(program);
}
try {
// implicit config file case
require(path.resolve(process.cwd(), 'nemo.config'));
program.configFile = path.resolve(process.cwd(), 'nemo.config');
return NemoFactory.configureJS(program);

@dwbruhn
Copy link
Collaborator Author

dwbruhn commented Dec 8, 2018

BTW while debugging this I noticed that the -C option is kind difficult with JSON files now. It doesn't support comments in JSON, and if you use shortstop handlers you have to back up out of the node_modules/nemo-core/etc. directory like this:

"data": "require:../../../../test/functional/data/data.json"

dwbruhn added a commit to dwbruhn/nemo that referenced this issue Dec 8, 2018
grawk added a commit that referenced this issue Dec 10, 2018
@grawk grawk mentioned this issue Dec 10, 2018
@grawk grawk closed this as completed in #55 Dec 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant