neutrino icon indicating copy to clipboard operation
neutrino copied to clipboard

Allow specifying karma files option without removing the tests file specification neutrino use

Open elpddev opened this issue 3 years ago • 1 comments

Bug or issue?

Issue/Feature request.

Currently Neutrino use the karma file configuration to specify test files pattern to load: https://github.com/neutrinojs/neutrino/blob/master/packages/karma/index.js#L51

   files: [
            {
              pattern: tests,
              watched: false,
              included: true,
              served: true,
            },
          ],

Also, neutrino does this with the option to shallow merge options given to the preset.

use(karma({ files: [ { pattern: jqueryPath, watched: false } ] });

Problem: Specifying the files option override(not merged) the tests files pattern neutrino specify.

Please try to answer the following questions:

  • What version of Neutrino are you using? Neutrino 9.4.0

  • Are you trying to use any presets? If so, which ones, and what versions? Karma 9.4.0 Library 9.4.0 Airbnb-base 9.4.0

  • Are you using the Yarn client or the npm client? What version? Yarn 1.22.5

  • What version of Node.js are you using? v.13.7.0

  • What operating system are you using? linux

  • What did you do? Provided karma preset wtih files options

  • What did you expect to happen? Tests will run and the additional files will be loaded as scripts tag in the browser.

  • What actually happened, contrary to your expectations? Tests did not run. Additional scripts tag were loaded in the browser.

Feature request or enhancement?

Please describe your request in detail. Use the following questions as guidance:

  • What is the goal of the change? Allow more granular merging for the files karma config option.

  • What are the pros and cons of the change? Pros: Allow to add file patterns to karma config without removing the current neutrino use for speifying the test file loading pattern. Cons: More complicated merge.

  • Could this dramatically improve the experience of our users? Not sure. For me I needed to load some shared global scripts at the start of the tests.

I am willing to do a PR, but am not sure what is the correct path to do this keeping the overall design pattern used for neutrino preset config specification. If the options could have contained a hook function that would have been called at the point of the files specification that would solved it, but it complicate the code.

elpddev avatar Oct 25 '20 18:10 elpddev

Looking deeper, it seems this is the behavior of deepmerge old version 1.5.2 Which karma neutrino uses. Newer versions do array concat. https://github.com/TehShrike/deepmerge/pull/77

elpddev avatar Oct 25 '20 18:10 elpddev