Typescript - Testing with Jest outside of __tests__ directory

I want to be able to execute my tests outside of __tests__ directory. Currently, I have my test files alongside the src code. Inside somefile.test.ts I have tests A, B and C. If try to run the C test from the gutter icon, I get the following error:

back-end is the root directory.

Also, the option to create a test file from the context menu is missing when right click somefile.ts:

Environment

WebStorm 2020.3.3
Build #WS-203.7717.59, built on March 15, 2021
Runtime version: 11.0.10+8-b1145.96 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.4.0-70-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 947M
Cores: 4
Non-Bundled Plugins: mobi.hsz.idea.gitignore, com.intellij.database, ru.adelf.idea.dotenv
Current Desktop: ubuntu:GNOME

0
3 comments

I just needed to add @types/jest to the javascript libraries.

Source: https://blog.jetbrains.com/webstorm/2018/10/testing-with-jest-in-webstorm/

0

Hmm... Not sure what the JavaScript libraries have to do with your initial problem; they only affect code completion/types resolving in the editor but aren't required for the tests to run

0

Please sign in to leave a comment.