zenvoich / test Goto Github PK
View Code? Open in Web Editor NEWMotoko testing library to run tests with mops
License: MIT License
Motoko testing library to run tests with mops
License: MIT License
Is there a way I can run some code that will set a timer without an error?
I have some code that kicks off a timer (dont care about it for the test) and i get this error
FAIL internals:604:11: execution error, Value.prim: global_timer_set
Maybe some sort of mock, or just ignore the timer? what are my options
Is there way to run a test and have it print out details?
If i use Debug.trap, i get a message but its stop execution of the other tests
Do I just do and if statement, then Debug.print, then assert false?
Is there a way to test private functions of my actor class?
Sorry to keep pestering
I need to test the functions of an actor class but have no idea
I've noticed a small typo in the readme.md file, specifically in the code snippet provided for expect.option. The typo is in the variable name used in the example for an optional custom type. The variable is declared as "val", but later referenced as "v". This might cause confusion for users trying to understand or run the example code.
expect.option
// ... previous code ...
let val = ?{x = 1; y = 2};
expect.option(v, showMyType, equalMyType).notEqual(null);
expect.option(v, showMyType, equalMyType).isSome(); // != null
expect.option(v, showMyType, equalMyType).equal(?{x = 1; y = 2});
I have an actor class which looks like this
actor class Orchestrator() = this {
let { phash } = Map;
private stable var pool = Map.new<Principal, Types.CanisterInfo>();
let management = Management.service(Constants.ManagementCanisterId);
// Auth so that only server and admin can talk to this canister
let admin = Principal.fromText("qcjer-cl7l3-dae");
let game_controller = Principal.fromText("7k7-lqlgk-x56ep");
private stable var admins = Vector.fromArray<Principal>([admin, game_controller]);
I then have some tests which look like this
var orchestrator = await Orchestrator();
let caller : Principal = Principal.fromText("wo5qg-ysjiq-5da");
let user1 : Principal = Principal.fromText("kufey-x4r");
let user2 : Principal = Principal.fromText("mm6ly-2yowe");
let user3 : Principal = Principal.fromText("wkvns-5prta");
var admins : Vector<Principal> = Vector.fromArray([caller, user1, user2]);
func resetMocks() : () {
admins := Vector.fromArray([caller, user1, user2]);
};
await suite(
"createEvent",
func() : async () {
await test(
"setEventWasm works correctly",
func() : async () {
resetMocks();
let oldEventWasm = await orchestrator.getEventWasm();
The getEventWasm function requires admin verification so i need to change the admins in my Orchestrator actor class to include this principal wo5qg-ysjiq-5da. have you got a good way of suggesting how I do this? I could pass it as an argument to my actor orchestrator class when i create it i suppose but i was wondering if there might be a better way to do it
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.