Comments (2)
Hmm, it's not an ESM issue either, I'm getting the same thing with CJS:
// foo.js
const { CallbackUrl, createClient } = require('@deepgram/sdk');
const deepgram = createClient('somekey');
async function transcribeUrl(url) {
console.log(deepgram);
// { listen: { prerecorded: { transcribeUrlCallback: [Function] } } }
return deepgram
.listen
.prerecorded
.transcribeUrlCallback(
{ url },
new CallbackUrl('some-url'),
{},
);
}
module.exports = { transcribeUrl };
// foo.spec.js
const { createClient } = require('@deepgram/sdk');
const { transcribeUrl } = require('./foo.js');
jest.mock('@deepgram/sdk', () => ({
CallbackUrl: jest.fn(),
createClient: () => ({
listen: {
prerecorded: {
transcribeUrlCallback: jest.fn(),
},
},
}),
}));
describe('transcribeUrl', () => {
it('returns the transcription result on success', async () => {
const mockDeepgram = createClient();
mockDeepgram
.listen
.prerecorded
.transcribeUrlCallback
.mockResolvedValue('transcription text');
const result = await transcribeUrl('http://example.com/audio');
console.log(result);
// undefined
console.log(mockDeepgram);
// { listen: { prerecorded: { transcribeUrlCallback: [Function] } } }
console.log(jest.isMockFunction(mockDeepgram.listen.prerecorded.transcribeUrlCallback));
// true
});
});
from jest.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
from jest.
Related Issues (20)
- [Feature]: Predicate matching on snapshot values
- [Bug]: `it.each` from `@jest/globals` causes typescript errors with readonly arrays HOT 2
- [Bug]: Dependency with outdated Windows executables HOT 4
- [Bug]: npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. HOT 10
- [Docs]: broken link HOT 2
- [Bug]: broken runAllTimers
- [Bug]: Jest ignores near all files on Windows with GNU find HOT 2
- [Bug]: toMatchObject doesn't work if object contains File
- [Bug]: jest.mock('package-name') does nothing HOT 1
- [Bug]: Mocking Partials (in with ES6 modules) doesn't work as per documentation HOT 5
- [Feature]: Expose all matchers as asymmetric matchers
- [Bug]: Add top level `endTime` when using --json reporter
- [Bug]: setupFiles exported function not called
- [Bug]: Console errors from jsdom when using newer css constructs like @container or @layer
- [Bug]: passWithNoTests flag ignored for empty test files
- [Bug]: Not able to access window in vm.runInContext
- [Bug]: v30-alpha.5 TestPathPatterns pattern-match regression
- ReferenceError: require is not defined HOT 1
- [Bug]: toThrow does not check error cause
- [Docs]: From v27 to v28 page is no longer accessible HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jest.