I'm new to Jasmine, and am getting this error:
Expected spy unknown to have been called.
What does this mean? I'm spying on a method, but am not sure what unknown means.
The answer is really simple! The spy didnt have a name, so it's called "unknown" by default.
To name it, I simply did this
var mySpy = jasmine.createSpy("JamesBond");
Then it failed with something more readable!
Expected spy JamesBond to have been called.
The "unknown" value is due to the inexistence of the name attribution for the spy.
before:
Error: Expected spy unknown.getPlans to have been called.
const mockPlansServiceEmpty: Spide<PlansService> = jasmine.createSpyObj(
['getPlans', 'separateValidFromInvalidPlans']
);
after:
Error: Expected spy mockPlansEmpty.getPlans to have been called.
const mockPlansServiceEmpty: Spide<PlansService> = jasmine.createSpyObj(
'mockPlansEmpty',
['getPlans', 'separateValidFromInvalidPlans']
);
Related
Inconsistent type in JSPB repeated field array. Got undefined expected object +AssertionError: Failure: Inconsistent type in JSPB repeated field array. Got undefined expected object
I am using fabric, and I think this is a problem with the chain code, but can't point the problem.
here is the stacktrace:
Fri, 29 Apr 2022 13:12:24 GMT + Failure: Inconsistent type in JSPB repeated field array. Got undefined expected object +AssertionError: Failure: Inconsistent type in JSPB repeated field array. Got undefined expected object
at new goog.asserts.AssertionError (/Users/user/hl-f/backend/node_modules/google-protobuf/google-protobuf.js:87:1065)
at Object.goog.asserts.fail (/Users/user/hl-f/backend/node_modules/google-protobuf/google-protobuf.js:90:89)
at /Users/user/hl-f/backend/node_modules/google-protobuf/google-protobuf.js:502:168
at Array.forEach (<anonymous>)
at Object.goog.array.forEach (/Users/user/hl-f/backend/node_modules/google-protobuf/google-protobuf.js:101:188)
at Function.jspb.Message.assertConsistentTypes_ (/Users/user/hl-f/backend/node_modules/google-protobuf/google-protobuf.js:502:114)
at Function.jspb.Message.bytesListAsU8 (/Users/user/hl-f/backend/node_modules/google-protobuf/google-protobuf.js:501:217)
at proto.protos.ChaincodeInput.getArgsList_asU8 (/Users/user/hl-f/backend/node_modules/#hyperledger/fabric-gateway/dist/protos/peer/chaincode_pb.js:557:59)
at proto.protos.ChaincodeInput.serializeBinaryToWriter (/Users/user/hl-f/backend/node_modules/#hyperledger/fabric-gateway/dist/protos/peer/chaincode_pb.js:508:15)
at jspb.BinaryWriter.writeMessage (/Users/user/hl-f/backend/node_modules/google-protobuf/google-protobuf.js:451:479)+
the code that do this is a simple AddAsset query that i modified,
#Transaction()
public async AddAsset(ctx: Context, assetid : string,email: string,phone :string,address :string): Promise<void> {
const exists = await this.AssetExists(ctx, assetid);
if (exists) {
throw new Error(`The asset ${assetid} already exists`);
}
const asset = {
AssetID: assetid,
Email: email,
Phone: phone,
Address: address,
};
await ctx.stub.putState(assetid, Buffer.from(stringify(sortKeysRecursive(asset))));
}
Always double check, triple check your app/backend, when encountering this problem.
you might have a similar problem to this:
json = {
Assetid : "123",
...
}
contract.submitTransaction("AddAsset", json.AssetID, ...);
explanation:
json.Assetid = 123
while
json.AssetID = undefined
I feel stupid, on how much time i wasted on this bug, thinking it was the chaincode,
And remember double, triple check.
And happy coding.
I am trying to build DeathStarBench (https://github.com/delimitrou/DeathStarBench), however, I am getting the following error:
In file included from /social-network-microservices/src/HomeTimelineService/HomeTimelineService.cpp:15:0:
/social-network-microservices/src/HomeTimelineService/HomeTimelineHandler.h: In member function 'virtual void social_network::HomeTimelineHandler::WriteHomeTimeline(int64_t, int64_t, int64_t, int64_t, const std::vector&, const std::mapstd::__cxx11::basic_string<char, std::__cxx11::basic_string >&)':
/social-network-microservices/src/HomeTimelineService/HomeTimelineHandler.h:129:55: error: 'class sw::redis::RedisCluster' has no member named 'get_shards_pool'
auto *shards_pool = _redis_cluster_client_pool->get_shards_pool();
I don't know anything about Redis. However, I googled the error message and couldn't find anything related to this. Any suggestions on what might be the problem?
in official documentation about handleReset from useFormik i have read that is type is:
handleReset: () => void
However, rewriting working JS code to TS I received error
Expected 1 arguments, but got 0.ts(2554)
Formik.d.ts(16, 19): An argument for 'e' was not provided.
Affter clicking onto handleReset it toook me to fromik.d.ts where it stands that:
handleReset: (e: any) => void;
Blockquote
Does it mean error in documentation? Should I call it with null? I really have no idea what to pass.
I am getting this error:
Error: Spies must be created in a before function or a spec
My Test code should be sound:
describe 'A spy', ->
foo = undefined
bar = null
beforeEach ->
foo = setBar: (value) ->
bar = value
return
spyOn foo, 'setBar'
foo.setBar 123
foo.setBar 456, 'another param'
return
it 'tracks that the spy was called', ->
expect(foo.setBar).toHaveBeenCalled()
Turnsout I had mocha and jasmine declared inside my karma.conf.js. As a result the frameworks interpreted both beforeEach differently.
Dropping mocha from my karma config file worked.
You need to create your spy inside the beforeEach block.
In my app I want to save some information for the user somewhere. I picked the Application Support Directory, which I am trying to get like so:
let savePath = NSSearchPathForDirectoriesInDomains(ApplicationSupportDirectory, UserDomainMask, true)
Im getting a compile error in XCode saying "Use of unresolved identifier", even though the function is requesting a NSSearchPathDirectory type, which according to Apple's documentation clearly exists:
enum NSSearchPathDirectory : UInt {
case ApplicationDirectory
...
case ApplicationSupportDirectory
...
}
The same problem occurs with 'UserDomainMask'
Is this a bug or am I missing something? (Also, I would prefer not to use a workaround like substituting an integer literal...)
The correct statement is:
let savePath = NSSearchPathForDirectoriesInDomains(.ApplicationSupportDirectory, .UserDomainMask, true)
println("savePath: \(savePath)")
output:
savePath: [/Users/zaph/Library/Developer/CoreSimulator/Devices/24F94BD2-9DD7-4BC6-AA66-128AC1E7555F/data/Containers/Data/Application/9FFA8987-A36B-4A4D-A607-1BC220ADBBF2/Library/Application Support]
A leading "." is needed for the enumeration values.