# How to execute test using newman if tests are in package

**URL:** <https://community.postman.com/t/how-to-execute-test-using-newman-if-tests-are-in-package/78409>\
**Category:** Help Hub\
**Tags:** newman-project, tests, collections, json, collection-runner\
**Created:** [April 11, 2025, 4:19pm UTC](https://community.postman.com/t/how-to-execute-test-using-newman-if-tests-are-in-package/78409 "2025-04-11T16:19:23Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![apfr1](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@apfr1](https://community.postman.com/u/apfr1)\
**Post date:** [April 11, 2025, 4:19pm UTC](https://community.postman.com/t/how-to-execute-test-using-newman-if-tests-are-in-package/78409/1 "2025-04-11T16:19:24Z")

</div>

> **Archived topic — this may be out of date.**  
> Newman has been replaced by the **[Postman CLI](https://learning.postman.com/docs/postman-cli/postman-cli-overview/)**, Postman’s official, signed command-line tool. It runs collections as Newman did, and also lints API specs, runs mocks and monitors, and syncs local files with Postman from your terminal, CI/CD pipeline or coding agent.  
> Working with an AI coding agent? The [Postman plugin](https://github.com/postmanlabs/postman-plugin) lets agents in Claude Code, Cursor, Codex and others design, mock, test and ship APIs with Postman.  
> For current help, see the [Postman docs](https://learning.postman.com/docs/), try the free [Postman tools](https://www.postman.com/tools) (no account needed), or join us on [Discord](https://discord.gg/58aNNsRBGR).

Hi! I created my collection in postman and it works correctly, but I would like to execute it using newman. In my collection the tests are in a specific package, in each call the tests are called directly from the package: const getDs = pm.require(‘get\_ds’);  
At this point:

- I proceed by exporting the collection in json format
- I open the command line and execute: newman run collection.json

But the execution fails: TypeError in test-script.

If I check the json file of the collection, I see that in the specific calls the packages are called, but they are not part of the json.

If instead of using the packages, in the individual calls I write the test in each one and then export the json, newman works.

How can I make newman read, in addition to the json of the collection, also the package?

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 14, 2025, 11:53am UTC](https://community.postman.com/t/how-to-execute-test-using-newman-if-tests-are-in-package/78409/2 "2025-04-14T11:53:59Z")

</div>

Hey @apfr1 👋

Welcome to the Postman Community! :postman:

Packages are not support in Newman, these are supported in the Postman CLI though.

> **[Explore Postman's command-line companion | Postman Docs](https://learning.postman.com/docs/postman-cli/postman-cli-overview/)**
>
> Postman is a collaboration platform for API development. Postman's features simplify each step of building an API and streamline collaboration so you can create better APIs—faster.

---

<div class="post-metadata">

**Author:** ![apfr1](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@apfr1](https://community.postman.com/u/apfr1)\
**Post date:** [April 14, 2025, 1:15pm UTC](https://community.postman.com/t/how-to-execute-test-using-newman-if-tests-are-in-package/78409/3 "2025-04-14T13:15:10Z")

</div>

Hi @danny-dainton thank you for your reply, but it doesn’t solve the problem: I used postman cli to execute my collection, but the result is always the same; if I run the collection directly from postman, it is ok:

```auto
Loading packages...[0/1] [Error]
  1⠄ Error in test-script

```

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 14, 2025, 1:51pm UTC](https://community.postman.com/t/how-to-execute-test-using-newman-if-tests-are-in-package/78409/4 "2025-04-14T13:51:57Z")

</div>

Can you provide more details about the actual script in the package and also how you’re calling this in Postman, please?

A visual example of this is always better than trying to explain it only using words. 🙏

---

<div class="post-metadata">

**Author:** ![apfr1](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@apfr1](https://community.postman.com/u/apfr1)\
**Post date:** [April 14, 2025, 1:56pm UTC](https://community.postman.com/t/how-to-execute-test-using-newman-if-tests-are-in-package/78409/5 "2025-04-14T13:56:36Z")

</div>

Hi @danny-dainton yes, of course:  
this is my script in the package:

```auto
function Status_200() {
	pm.test("Status test", function () {
	    if (pm.response.code === 200) {
        console.log("Status is OK");
    } else {
        throw new Error(`Expected status 200 but got ${pm.response.code}`);
    }
 });
}

// Call the test function
Status_200();

// Export the function to be used in other modules
module.exports = {
    Status_200
};

```

and I call it in each get as follow in the script section of each get:

```auto
const getDs = pm.require('get_ds');

```

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 14, 2025, 2:30pm UTC](https://community.postman.com/t/how-to-execute-test-using-newman-if-tests-are-in-package/78409/6 "2025-04-14T14:30:55Z")

</div>

I just ran a basic example using your script:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/1/3/13994d9305a8e572276ac896d193a9bf9e3f0284.png)

This would work with the Postman CLI, [if you were logged in](https://learning.postman.com/docs/postman-cli/postman-cli-options/#postman-login), then the `package id` in the exported JSON file, would be read and used correctly in the run.

Do you see this output in your terminal?

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/4/1/41e67c5c6874d7eefa81a4c0e561e23560e9f157.png)

---

<div class="post-metadata">

**Author:** ![apfr1](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@apfr1](https://community.postman.com/u/apfr1)\
**Post date:** [April 14, 2025, 2:33pm UTC](https://community.postman.com/t/how-to-execute-test-using-newman-if-tests-are-in-package/78409/7 "2025-04-14T14:33:12Z")

</div>

Yes, I see this output when trying to load the packages (the output about the error, but the login is done successfully) - @danny-dainton

 ![Screenshot 2025-04-14 174429](https://us1.discourse-cdn.com/getpostman/original/3X/2/0/20eb8431e649cc6d970a44940b13b72d30e99f41.png)

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 14, 2025, 3:59pm UTC](https://community.postman.com/t/how-to-execute-test-using-newman-if-tests-are-in-package/78409/8 "2025-04-14T15:59:51Z")

</div>

It’s likely that there is a different piece of information below, in the assertion summary about the results table.

The use a scripts is limited in the Postman CLI for specific plan types, I don’t know what plan you’re using but I suspect this is the case here.

---

<div class="post-metadata">

**Author:** ![apfr1](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@apfr1](https://community.postman.com/u/apfr1)\
**Post date:** [April 15, 2025, 12:55pm UTC](https://community.postman.com/t/how-to-execute-test-using-newman-if-tests-are-in-package/78409/9 "2025-04-15T12:55:20Z")

</div>

> [@danny-dainton](#):
>
> then the `package id` in the exported JSON file, would be read and used correctly in the run.

@danny-dainton  
I’m using a free plan for initial exploration in Postman. In one of your previous comments, you wrote that “then the package ID in the exported JSON file would be read and used correctly in the run,” but I’m not sure that the package ID is present in my JSON. In the JSON header, I found these parameters: postman id, name, schema, exporter\_id. Is it correct?

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 15, 2025, 1:38pm UTC](https://community.postman.com/t/how-to-execute-test-using-newman-if-tests-are-in-package/78409/10 "2025-04-15T13:38:15Z")

</div>

If you open the JSON file in an editor and then search for “packages”, you’d be able to find it.

For example:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/3/6/36b67fee1d5a76be0ab4bc6bfdc087e6afcb2a58.png)

Eitherway, if you’re on the free plan, you will only be able to use packages inside the platform and not by running the Collection via Newman or the Postman CLI.

---

<div class="post-metadata">

**Author:** ![apfr1](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@apfr1](https://community.postman.com/u/apfr1)\
**Post date:** [April 15, 2025, 1:53pm UTC](https://community.postman.com/t/how-to-execute-test-using-newman-if-tests-are-in-package/78409/11 "2025-04-15T13:53:40Z")

</div>

Thank you very much! From which subscription plan can I use the packages in Newman and Pstman CLI?

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [April 15, 2025, 2:07pm UTC](https://community.postman.com/t/how-to-execute-test-using-newman-if-tests-are-in-package/78409/12 "2025-04-15T14:07:52Z")

</div>

The package will not work for Newman as this doesn’t have the support for the feature.

Running packages with the Postman CLI is available on Professional and Enterprise accounts - These also increases the number of packages that can be created.

> **[Run a collection using the Postman CLI | Postman Docs](https://learning.postman.com/docs/postman-cli/postman-cli-run-collection/#run-a-collection-that-uses-packages)**
>
> Postman is a collaboration platform for API development. Postman's features simplify each step of building an API and streamline collaboration so you can create better APIs—faster.
