# How to run single unit test?

**URL:** https://discuss.elastic.co/t/how-to-run-single-unit-test/155727
**Category:** Kibana
**Created:** [November 7, 2018, 1:33pm UTC](https://discuss.elastic.co/t/how-to-run-single-unit-test/155727 "2018-11-07T13:33:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Hohol](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hohol/32/37372_2.png) [@Hohol](https://discuss.elastic.co/u/Hohol)
#### Post date: [November 7, 2018, 1:33pm UTC](https://discuss.elastic.co/t/how-to-run-single-unit-test/155727/1 "2018-11-07T13:33:14Z")

</div>

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.

```auto
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)

```

---

<div class="post-metadata">

### Author: ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)
#### Post date: [November 7, 2018, 6:30pm UTC](https://discuss.elastic.co/t/how-to-run-single-unit-test/155727/2 "2018-11-07T18:30:50Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Hohol](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hohol/32/37372_2.png) [@Hohol](https://discuss.elastic.co/u/Hohol)
#### Post date: [November 8, 2018, 9:41am UTC](https://discuss.elastic.co/t/how-to-run-single-unit-test/155727/3 "2018-11-08T09:41:32Z")

</div>

It works.  
Thank you very much!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [December 6, 2018, 9:41am UTC](https://discuss.elastic.co/t/how-to-run-single-unit-test/155727/4 "2018-12-06T09:41:33Z")

</div>

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