Hello, I'm using the `with-jest` as a starter to t...
# support-framework
w
Hello, I'm using the
with-jest
as a starter to try jest, it works fine until I import a class where i'm importing
@plasmo/storage
here is the error:
Copy code
src/tests/bg/tabs.test.ts
  ● Test suite failed to run

    Cannot find module '@plasmohq/storage' from 'src/bg/local-storage.ts'

    Require stack:
      src/bg/local-storage.ts
      src/bg/tabs.ts
      src/tests/bg/tabs.test.ts

> 1 | import { Storage } from "@plasmohq/storage"
        | ^
      2 |
      3 | /* 
      4 | Cache: chrome.storage.local

      at Resolver._throwModNotFoundError (node_modules/.pnpm/jest-resolve@28.1.3/node_modules/jest-resolve/build/resolver.js:491:11)
      at Object.<anonymous> (src/bg/local-storage.ts:1:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        8.707 s
Ran all test suites.
 ELIFECYCLE  Test failed. See above for more details.
I think jest is trying to import the package from
src
as in the config file we have :
Copy code
moduleNameMapper: pathsToModuleNameMapper(tsconfig.compilerOptions.paths, {
    prefix: "<rootDir>/"
  }),
How can I fix this ?
s
Thread automatically created by @wonderful-jewelry-41731 in #978320682985349130.
w
tabs.ts:
Copy code
import { LocalStorage } from "./local-storage"

export class Tabs {
  public static createTab(
    url: string,
    callback?: (tab: chrome.tabs.Tab) => void
  ) {
    chrome.tabs.create({ url: url }, (createdTab: chrome.tabs.Tab) => {
      callback(createdTab)
    })
  }
}
Adding import to plasmo storage package or importing a class that uses the package will throw error
Copy code
import { Storage } from "@plasmohq/storage"