-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
I'm dealing with a pretty strange error, and I was finally able to isolate and reproduce it on a minimal repository: https://github.com/hugoaboud/adonis-jest-mock-issue.
The repository README contains a complete description of the problem and files involved.
I'm able to mock class methods from node_modules and use them through my application without any problem.
However, if I use AdonisJS aliases, such as App/, the mock has no effect.
In short:
import Controller from "../app/Controller"; // mock works
import Controller from "App/Controller"; // mock doesn't workI assume this has to do with concurrency between Adonis IoC and Jest mock strategies. Do you have any thoughts?
There's an even simpler scenario, where the Service class doesn't belong to a dependency, but you import Controller with alias and Service without, or vice-versa:
// Mock doesn't work
import Controller from "App/Controller";
import Service from "../app/Service";
// Mock doesn't work
import Controller from "../app/Controller";
import Service from "App/Service";
// Mock works
import Controller from "App/Controller";
import Service from "App/Service";
// Mock works
import Controller from "../app/Controller";
import Service from "../app/Service";Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels