How to run single unit test?

I've cloned Kibana project.
I managed to run it locally and changed some code.
Now I'd like to run unit test corresponding to code I changed.
It is 'brush_event.test.js' file.
What should I do to run this test only?
I tried running it via WebStorm context menu - 'run brush_event.test.js'.
And i tried to run from terminal - 'yarn jest brush_event.test.js'.
In both cases I get the following error.

Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    C:\...\Kibana\src\ui\public\utils\__tests__\brush_event.test.js:38
    import _ from 'lodash';
    ^^^^^^

    SyntaxError: Unexpected token import

      at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)

Hi Nikita, you can run node scripts/jest brush_event to execute just the brush_event.test.js tests. Please let me know if this helps.

CJ

It works.
Thank you very much!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.