-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not matching public properties? #30
Comments
function createS3ClientMock():S3 {
const mock: any = TypeMoq.Mock.ofType(S3);
// it's wrong way to stub. you should use mock.setup(...)
mock.endpoint = 'STUBBED_ENDPOINT';
// you should not cast mock to S3, you should return mock.object
return <S3> mock;
} Read README, it's clear enough. |
@eschwartz Here is your example modified as suggested by @dizel3d import { S3, Endpoint } from "aws-sdk";
import * as TypeMoq from "typemoq";
function createS3ClientMock(): S3 {
const mock = TypeMoq.Mock.ofType(S3);
// it's wrong way to stub. you should use mock.setup(...)
mock.setup(x => x.endpoint).returns(() => new Endpoint("STUBBED_ENDPOINT"));
// you should not cast mock to S3, you should return mock.object
return mock.object;
}
console.log(createS3ClientMock().endpoint);
//Endpoint {
// protocol: 'https:',
// host: 'stubbed_endpoint',
// port: 443,
// hostname: 'stubbed_endpoint',
// pathname: '/',
// path: '/',
// href: 'https://stubbed_endpoint/' } |
Thanks, @florinn for the example. I kind of the gave up on this, because the documentation on |
|
I'm attempting to create a mock for
AWS.S3
, but I'm getting a error:My code looks like:
The definition for
S3
looks like:I'm able to hack my way around this, by doing something like:
The text was updated successfully, but these errors were encountered: