# Issue on setup test environment

**URL:** <https://forum.heroiclabs.com/t/issue-on-setup-test-environment/5116>\
**Category:** Runtime Framework\
**Tags:** server-framework, typescript\
**Created:** [April 2, 2024, 7:25am UTC](https://forum.heroiclabs.com/t/issue-on-setup-test-environment/5116 "2024-04-02T07:25:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![developerdinno](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/developerdinno/32/2100_2.png) [@developerdinno](https://forum.heroiclabs.com/u/developerdinno)\
**Post date:** [April 2, 2024, 7:25am UTC](https://forum.heroiclabs.com/t/issue-on-setup-test-environment/5116/1 "2024-04-02T07:25:24Z")

</div>

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](https://heroiclabs.com/docs/nakama/guides/server-framework/typescript-testing/#full-example),  
But can’t found the proper solution to setup the typescript.

My tsConfig File:

```auto
 {
  "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.

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [April 2, 2024, 11:21am UTC](https://forum.heroiclabs.com/t/issue-on-setup-test-environment/5116/2 "2024-04-02T11:21:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![developerdinno](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/developerdinno/32/2100_2.png) [@developerdinno](https://forum.heroiclabs.com/u/developerdinno)\
**Post date:** [April 3, 2024, 3:39am UTC](https://forum.heroiclabs.com/t/issue-on-setup-test-environment/5116/3 "2024-04-03T03:39:41Z")

</div>

> [@sesposito](#):
>
> verbatim

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

---

<div class="post-metadata">

**Author:** ![developerdinno](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/developerdinno/32/2100_2.png) [@developerdinno](https://forum.heroiclabs.com/u/developerdinno)\
**Post date:** [April 4, 2024, 9:09am UTC](https://forum.heroiclabs.com/t/issue-on-setup-test-environment/5116/4 "2024-04-04T09:09:02Z")

</div>

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

The issue was solved by the rollup.

rollup.config.ts

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

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

```

And tsconfig is:

```auto
{
  "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"]
}

```
