Issue on setup test environment

I’m trying to unit test my TS files but I’m not able to setup the test environment.

Here I follow the Testing TypeScript Server Runtime Code with Jest - Heroic Labs Documentation,
But can’t found the proper solution to setup the typescript.

My tsConfig File:

 {
  "target": "ES5",
  "moduleResolution": "node",
   "outFile": "./data/modules/index.js",
    ... other options
   "files": ["./node_modules/nakama-runtime/index.d.ts"],
  "include": ["**/*.ts"],
  "exclude": ["node_modules", "data", "**/__test__", "jest-config.ts"]
}

And according to document on the test file.
import AddItemRpc from "./rpc-add-item"

and export the rpc
export default AddItemRpc;

When i try export there is issue occors like:

Cannot compile modules using option 'outFile' unless the '--module' flag is 'amd' or 'system'.ts(6131)

So, I’m not able to setup. If anyone faced that type of issue please suggest me the solution or anyone did the unit testing please guide me the how i setup the testing environment.

Hello @developerdinno, have you followed the guide verbatim or are you modifying an existing project?

Sir, I’m modifying an existing project and i want to setup the test environment. Mainly I to know how i can
Import or export the RPC function.
I have above tsConfig file and i not able to export the RPC function

Finally i can export or import RPC function for test environment.

The issue was solved by the rollup.

rollup.config.ts

import typescript from "@rollup/plugin-typescript";

export default {
  input: "app.ts",
  external: ["nakama-runtime"],
  output: {
    file: "data/modules/app.js"
  },
  plugins: [typescript()]
};

in package.json

"prod": "tsc --noEmit && rimraf data/modules && rollup -c rollup.config.js",
...
"type": "module",

And tsconfig is:

{
  "compilerOptions": {
    "target": "es5",
    "module": "ES6",
    "moduleResolution": "node",
    "removeComments": true,
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "allowSyntheticDefaultImports": true,
    "useUnknownInCatchVariables": false,
    "outDir": "build",
    "importHelpers": true
  },
  "files": ["./node_modules/nakama-runtime/index.d.ts"],
  "include": ["**/*.ts"],
  "exclude": ["node_modules", "build"]
}