Open Lucas-Chain-Andela opened 8 months ago
Hello! First of all, congratulations on the amazing job. Both on the communication and the library itself - I got to learn about it yesterday and I'm loving it.
You are welcome!
I followed the main tutorial on the
README.md
file and I noticed some details that made me a little confused, but I could make it work with some limitations.The main part is that I tried following it using
eventually@5.7.x
, but it looks like some things changed after it was written.
Yep, I haven't found the time to update the documentation, it needs some work
I wrote a sample (working) project here. The
latest-eventually-version
branch runs has my tests on5.7
, themain
branch is on5.0
. I'll focus on5.7
on this Github issue.
That's good, thanks!
InMemorySnapshotStore
is now deprecatedThe tutorial recommends me to do something like this in the tests:
describe("Room", () => { const snapshotStore = InMemorySnapshotStore(); // .... });
The issue is that it was removed in this commit. I understand the motivation behind the deprecation, but I'd like to know how can we properly test on the new version.
So on the "lookup" test scenario, I wasn't able to assert that three records were created, so I tested the lookup individually, like this:
it("allows pokemon to be looked up", async () => { const pokemon = await client().load(Pokemon, "pokemon-1"); expect(pokemon.state.name).toBe("Bulbasaur"); });
Is there a way to still test the total records in the store?
Yeah, I removed the snapshot store ports in favor of snapshot events (configured in the app builder) - https://github.com/Rotorsoft/eventually-monorepo/blob/f9e928dd5971e4a5fcb8c7840976bb7adaf59b9d/libs/eventually/src/builder.ts#L64
You can either use client().load(...)
with callbacks to handle all events of the aggregate, or client().query(...)
to query all the streams.
Snapshot return typing
This is more like a "I don't know what I'm doing" than an issue with the lib, but here it goes:
This happens in a similar way, both on
5.0
abd5.7
.describe("and the pokemon is caught", () => { it("registers the pokemon as caught", async () => { // patches Math.random to force success Math.random = jest.fn().mockReturnValue(0.9); // Load bulbasaur const pokemon = await client().load(Pokemon, "pokemon-1"); // Throw a pokeball at it const result = await throwPokeball(pokemon.state.pokedexNumber, { id: 1, success: true }); expect(result.state.catchAttempts.length).toBe(1); // the value below is typed as `models.CatchAttempt`, not a Snapshot of it // typescript doesn't let me access `.data`, although it exists // the test below passes normally, but the static check doesn't, unless I cast it const attempt = result.state.catchAttempts[0] as any; expect(attempt.data.success).toBe(true); }); });
Here's a link for the full file
I'm thinking that I did something wrong, but not sure what.
Not sure what's happening here, but command handlers return snapshots... check the type inference. https://github.com/Rotorsoft/eventually-monorepo/blob/f9e928dd5971e4a5fcb8c7840976bb7adaf59b9d/libs/eventually/src/handlers/command.ts#L22
This VS extension should generate a project that's closer to the latest version: https://www.linkedin.com/posts/rogertorres_this-week-i-started-a-vscode-extension-that-activity-7077398485100081152-QkvA?utm_source=share&utm_medium=member_desktop
Live API schema documentation
I couldn't make it work based on the documentation, I'm seeing the following screen:
I didn't find in the documentation where I should set this version field, is it in
package.json
?
Check the config zod schema, package.json should have name, author, version, etc.
I intend to learn the answers to those questions and then contribute to the repository by suggesting updates on the documentation, so count on me if I can help with anything.
Thank you in advance, and again, amazing job.
👍
thanks a lot @Rotorsoft
I'll look into ESML
Hello! First of all, congratulations on the amazing job. Both on the communication and the library itself - I got to learn about it yesterday and I'm loving it.
I followed the main tutorial on the
README.md
file and I noticed some details that made me a little confused, but I could make it work with some limitations. I intend to understand what is happening so I can contribute in any way.The main part is that I tried following it using
eventually@5.7.x
, but it looks like some things changed after it was written.I wrote a sample (working) project here. The
latest-eventually-version
branch has my tests on5.7
, and themain
branch is on5.0
. I'll focus on5.7
on this Github issue.InMemorySnapshotStore
is now deprecatedThe tutorial recommends me to do something like this in the tests:
The issue is that it was removed in this commit. I understand the motivation behind the deprecation, but I'd like to know how can we properly test on the new version.
So on the "lookup" test scenario, I wasn't able to assert that three records were created, so I tested the lookup individually, like this:
Is there a way to still test the total records in the store?
Snapshot return typing
This is more like an "I don't know what I'm doing" than an issue with the lib, but here it goes:
This happens similarly, both on
5.0
and5.7
.Here's a link for the full file
I'm thinking that I did something wrong, but not sure what.
Live API schema documentation
I couldn't make it work based on the documentation, I'm seeing the following screen:
I didn't find in the documentation where I should set this version field, is it in
package.json
?I intend to learn the answers to those questions and then contribute to the repository by suggesting updates on the documentation, so count on me if I can help with anything.
Thank you in advance, and again, amazing job.