Repository: Codeception/CodeceptJS
Pull request #983 (2018-03-03 05:53:51)

[feature] Enable overriding of `config.tests` for `run-multiple`
See #978 

codacy-bot: 
![Codacy](https://app.codacy.com/assets/images/favicon.png) Here is an overview of what got changed by this pull request:


```diff

Issues
======
- Added 1
           
```


See the complete overview on [Codacy](https://app.codacy.com/app/DavertMik/CodeceptJS/pullRequest?prid=1392350&bid=6688888)
        
sveneisenschmidt: @DavertMik @reubenmiller Sempahore CI build failed, can you have a look please? 💐 
reubenmiller: @sveneisenschmidt I'm looking into this now
sveneisenschmidt: @reubenmiller Thanks for looking into it. What was the issue at the end?
(Still want me to invite to the Slack group?)
reubenmiller: @sveneisenschmidt The sephamore tests are a little flaky. The build failed before because of some issue when running `npm install`...then I just restarted the build and it was fixed :/ I think i'll have to look into sometime.

Yeah I think we can add you to the slack dev channel (and I think I have the right permissions to do so). What's your slack username?
sveneisenschmidt: @reubenmiller Thanks for the exolaination. About slack, I think you need to invite me to your workspace/channel via my mail: `sven.eisenschmidt[at]gmail[dot]com`.
reubenmiller: @sveneisenschmidt yep, finally found the link.
sveneisenschmidt: @reubenmiller Worked, I'm in. Thank you :)

Patch:
diff --git a/lib/command/run-multiple.js b/lib/command/run-multiple.js
index e3e922d3..ad18410e 100644
--- a/lib/command/run-multiple.js
+++ b/lib/command/run-multiple.js
@@ -143,6 +143,11 @@ function runSuite(suite, suiteConf, browser) {
   overriddenConfig = replaceValue(overriddenConfig, 'reportDir', path.join(config.output, outputDir));
   overriddenConfig = replaceValue(overriddenConfig, 'mochaFile', path.join(config.output, outputDir, `${browser}_report.xml`));
 
+  // override tests configuration
+  if (overriddenConfig.tests) {
+    overriddenConfig.tests = suiteConf.tests;
+  }
+
   // override grep param and collect all params
   const params = ['run',
     '--child', `${suiteId++}.${suite}:${browser}`,
diff --git a/lib/helper/Nightmare.js b/lib/helper/Nightmare.js
index e2176be4..eb20f630 100644
--- a/lib/helper/Nightmare.js
+++ b/lib/helper/Nightmare.js
@@ -865,7 +865,7 @@ class Nightmare extends Helper {
   }
 
   /**
-   * {{> ../webapi/waitForVisible }}
+   * {{> ../webapi/waitForInvisible }}
    */
   waitForInvisible(locator, sec) {
     this.browser.options.waitTimeout = sec ? sec * 1000 : this.options.waitForTimeout;


Test patch:
diff --git a/test/data/sandbox/codecept.multiple.json b/test/data/sandbox/codecept.multiple.json
index 918d9cff..5adf5841 100644
--- a/test/data/sandbox/codecept.multiple.json
+++ b/test/data/sandbox/codecept.multiple.json
@@ -25,6 +25,11 @@
       "grep": "@grep",
       "browsers": ["chrome",
         { "browser": "firefox", "windowSize": "1200x840"}]
+    },
+    "test": {
+      "tests": "./*_test_override.multiple.js",
+      "browsers": ["chrome",
+        { "browser": "firefox", "windowSize": "1200x840"}]
     }
   },
   "include": {},
diff --git a/test/data/sandbox/tests_test_override.multiple.js b/test/data/sandbox/tests_test_override.multiple.js
new file mode 100644
index 00000000..d8cb6c27
--- /dev/null
+++ b/test/data/sandbox/tests_test_override.multiple.js
@@ -0,0 +1,5 @@
+Feature('print browser size');
+
+Scenario('print browser size info', (I) => {
+  I.printWindowSize();
+});
diff --git a/test/docker-compose.yml b/test/docker-compose.yml
index 5d9399a2..4c4a71d9 100644
--- a/test/docker-compose.yml
+++ b/test/docker-compose.yml
@@ -9,6 +9,15 @@ services:
       - ..:/codecept
       - node_modules:/codecept/node_modules
 
+  test-runner:
+    build: ..
+    entrypoint: docker/entrypoint node_modules/.bin/mocha
+    command: test/runner
+    working_dir: /codecept
+    volumes:
+      - ..:/codecept
+      - node_modules:/codecept/node_modules
+
   test-helpers:
     build: ..
     entrypoint: docker/entrypoint node_modules/.bin/mocha --invert --fgrep Appium
diff --git a/test/runner/run_multiple_test.js b/test/runner/run_multiple_test.js
index 9ffe9fad..65704b99 100644
--- a/test/runner/run_multiple_test.js
+++ b/test/runner/run_multiple_test.js
@@ -101,4 +101,16 @@ describe('CodeceptJS Multiple Runner', function () {
       done();
     });
   });
+
+  it('should pass tests to configuration', (done) => {
+    exec(`${codecept_run}test`, (err, stdout, stderr) => {
+      stdout.should.include('CodeceptJS'); // feature
+      stdout.should.include('[1.test:chrome] print browser size');
+      stdout.should.include('[2.test:firefox] print browser size');
+      stdout.should.include('[1.test:chrome] print browser ');
+      stdout.should.include('[2.test:firefox] print browser ');
+      assert(!err);
+      done();
+    });
+  });
 });