# TypeError: (0 , \_slug.handler) is not a function - nextjs 12/jest

**URL:** <https://community.auth0.com/t/typeerror-0-slug-handler-is-not-a-function-nextjs-12-jest/118131>\
**Category:** Get Help\
**Tags:** sdks-quickstarts, nextjs-auth0\
**Created:** [October 9, 2023, 9:10pm UTC](https://community.auth0.com/t/typeerror-0-slug-handler-is-not-a-function-nextjs-12-jest/118131 "2023-10-09T21:10:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![harris.johnny](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/harris.johnny/32/51530_2.png) [@harris.johnny](https://community.auth0.com/u/harris.johnny)\
**Post date:** [October 9, 2023, 9:10pm UTC](https://community.auth0.com/t/typeerror-0-slug-handler-is-not-a-function-nextjs-12-jest/118131/1 "2023-10-09T21:10:13Z")

</div>

1. Next.js 12.3.4 with jest 29.7.0 using /src/pages/api/some/endpoint/[slug].js The endpoint works fine when I call it when running. But as a test i get the full error:

```auto
(0 , _slug.handler) is not a function
TypeError: (0 , _slug.handler) is not a function
at Object.<anonymous> (/Users/username/git/org/my-framework-api/src/tests/api/cdol/leaders/[slug].test.js:69:30)
  at Promise.then.completed (/Users/username/git/org/my-framework-api/node_modules/jest-circus/build/utils.js:298:28)
  ...

```

=======

// /src/pages/api/cdol/leaders/[slug].js  
import { withApiAuthRequired } from “@auth0/nextjs-auth0”;  
const handler = withApiAuthRequired(async function handle(req, res) { … });

# export default handler;

// /src/tests/api/cdol/leaders/[slug].test.js import { handler ] from "../../../../pages/api/cdol/leaders/[slug]

it(“simple happy path”, async () =\> {  
… //setup mocks include req

const result = await handler(req) });

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [October 11, 2023, 7:16pm UTC](https://community.auth0.com/t/typeerror-0-slug-handler-is-not-a-function-nextjs-12-jest/118131/3 "2023-10-11T19:16:52Z")

</div>

Hi @harris.johnny,

Welcome to the Auth0 Community!

Is the line `(0 , _slug.handler)` somewhere in your code? I’m not familiar with this in the context of Auth0.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [October 26, 2023, 2:26pm UTC](https://community.auth0.com/t/typeerror-0-slug-handler-is-not-a-function-nextjs-12-jest/118131/4 "2023-10-26T14:26:30Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
