Codeception: Is it possible to enable extensions per environment?

Created on 10 Jun 2015  路  14Comments  路  Source: Codeception/Codeception

Phantoman is a cool extension that turns on and off PhantomJS when tests begin and finish running.

Would be cool, tho, to enable it only on a given environment, so if we have different envs for different browsers, PhantomJS would only run on its own environment.

BUG

All 14 comments

I thought you can enable it per environment...
You can list it in environment config. Or not?

It seems it ignores extensions entry on suite settings; it only works if you add the entry to the main settings file. This makes no difference:

class_name: AcceptanceTester
modules:
  enabled:
    - WebDriver
    - AcceptanceHelper
  config:
    WebDriver:
      url: http://localhost
      browser: 'phantomjs'
extensions:
  enabled:
    - Codeception\Extension\Phantoman

Based on issue #1370, I'll be adding support shortly to Phantoman so that it only starts for configured suites. This will be dependant on Codeception 2.1+ however. I just haven't had the chance to get to coding it up yet :smile:

I believe once I add support for the new MODULE_INIT event I should be able to determine if Phantoman is enabled for the current suite and act accordingly.

I believe for environment support, though I haven't tried it yet, you would just need to enable Phantoman for a specific environment instead of the whole suite.

class_name: AcceptanceTester
modules:
  enabled:
    - WebDriver
    - AcceptanceHelper
  config:
    WebDriver:
      url: http://localhost
      browser: 'firefox'
env:
    phantom:
        modules:
            config:
                WebDriver:
                    browser: 'phantomjs'
        extensions:
            enabled:
                - Codeception\Extension\Phantoman

@DavertMik Does ^that make sense?

As I said, I'm not sure that would work. It seems extension settings are ignored from suite settings - it only works from the main settings file.

Ahh, I see what you mean. I'll have to look into that. I have Phantoman enabled in my main config but I'll need to get it working in suite specific configs as well

The extensions - enabled ... branch surely doesnt work in env-files or below the env: keyword in main config file. This seems to be a bug.

I'm experiencing the same problem. I need to change behavior depending on environment.
I can achieve this by enabling module in env, but setting 'modules: enabled: ...' in env config overwrites whole 'enabled:' array in global config, so I have to duplicate the modules list in every env.
'extensions: enable:' simply does not work from env config.

I know we're talking about environments here but suite specific extensions working would be a great option to have

Anything going forward here...i want to enable the recorder extension in env because it costs a lot of performance

Anything going forward here...i want to enable the recorder extension in env because it costs a lot of performance

As a workaround you can create separate config with recorder enabled and run tests using it:

codecept run -c codeception_recorder.yml

Ok this is working fine. I try do a best practice repo for trainings and start it here https://github.com/rogoit/rolandgolla

This should be available since 2.2.7 if you enable extension in suite config.
If you do so you can probably override them in environments:

https://github.com/Codeception/Codeception/pull/3805

Do you have any example? For me i need 2 config files and must have a build when i switch.

Im working on release which will enable this functionality. I will try to add small example into changelog

Was this page helpful?
0 / 5 - 0 ratings