question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mocking aws-sdk fails with moduleName.split is not a function

See original GitHub issue

Do you want to request a feature or report a bug? bug What is the current behavior? The following code

test("aws fail", () => {
  const awsMock = jest.genMockFromModule("aws-sdk");
  jest.mock(awsMock);
});

throws

TypeError: moduleName.split is not a function

** steps to reproduce ** The presented code is all that is needed

What is the expected behavior? That the mock actually works and the call does not crash

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.

jest 22.4.2 aws-sdk 2.202.0 yarn 1.5.1 node 9.6.1

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
johncolcommented, May 7, 2019

@dfrkp could you please share your solution?

1reaction
kelliott-idplanscommented, May 8, 2018

jest.mock('aws-sdk')

Read more comments on GitHub >

github_iconTop Results From Across the Web

jestjs - jest.mock(..) not working in 'describe' (TypeError
The error you're getting TypeError: moduleName.split is not a function is because resolveModuleFromDirIfExists tries to split the module ...
Read more >
mocking aws-sdk fails with moduleName.split is not a function
Coming soon: A brand new website interface for an even better experience!
Read more >
Testing Firebase function with Jest – error : moduleName.split ...
I am trying to test a Firebase Cloud function using the firebase-functions-test SDK… The documentation ( as often) is based on mocha/sinon, ...
Read more >
Mocking modular AWS SDK for JavaScript (v3) in Unit Tests
Example code to be tested. We have a function that takes an array of user IDs, finds the user information for each user...
Read more >
Developing on AWS with C# - Awsstatic
Amazon S3 can do this not only because it contains near ... machine may cost more money than an event-driven AWS Lambda function...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found