-
Notifications
You must be signed in to change notification settings - Fork 22
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
test(examples): e2e test for examples #80
base: main
Are you sure you want to change the base?
Conversation
For now, there is only one test for "memory/agentMemory.ts" added. I want to know if this is in the right direction or not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- We don't want to modify the existing
examples
directory. - Testing output is not important.
Please see the Python example that I mentioned in the related Github issue.
@Tomas2D There are not changes in the |
Oh. I wanted to say that I don't want 1:1 mapping between the I would like to have one example test file, |
@Tomas2D Thanks for review and direction. I'll work on it. |
3c87777
to
d32d11c
Compare
The interactive examples and some other are failing. I'll look into the failures. |
85726e9
to
043c459
Compare
043c459
to
493ef76
Compare
493ef76
to
960e407
Compare
In the last commit:
|
ff6eed3
to
56ee5ee
Compare
The last commit adds the configuration that can exclude examples from the tests in case some examples may not be expected work successfully. |
tests/examples/examples.test.ts
Outdated
dot: false, | ||
realpath: true, | ||
}); | ||
const config = JSON.parse(fs.readFileSync("./tests/examples/example_test.cfg", "utf8")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the point of adding a next file. Declare ignored paths in this file directly.
Note: don't use a sync operation in an async environment
tests/examples/examples.test.ts
Outdated
it.concurrent(`Run ${example}`, async () => { | ||
await semaphore.acquire(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't you just use https://vitest.dev/config/#sequence-concurrent with https://vitest.dev/config/#maxconcurrency? It seems better.
tests/examples/examples.test.ts
Outdated
it.concurrent(`Run ${example}`, async () => { | ||
await semaphore.acquire(); | ||
try { | ||
execSync(`yarn start -- ${example}`).toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you call toString()
even though you don't print anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, I think you should print something.
vitest.examples.config.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this file under examples
.
vitest.examples.config.ts
Outdated
passWithNoTests: true, | ||
testTimeout: 120 * 1000, | ||
printConsoleTrace: true, | ||
setupFiles: ["./tests/setup.examples.ts"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the same setup as the E2E tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or ideally just import e2e
test config and spread it here
export define defineConfig({
...e2eConfig,
// changes
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how to do it. What necessary is undefine afterEach
function defined in the "setup.ts".
d95f4e7
to
11b92b8
Compare
11b92b8
to
c12f26d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far so good!
c12f26d
to
783bbe5
Compare
There are still 3 example errors. I added them in the exclude list for now. They are: Run examples/cache/fileCache.ts 964ms Here is the errors.
|
|
8b13f9b
to
d4b7b92
Compare
The environment variable names are now "INCLUDE_PATTERN" and "EXCLUDE_PATTERN". |
d4b7b92
to
c11d59a
Compare
if (exclude.includes(example.slice(prefixLength))) { | ||
continue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified.
if (!exclude.startsWith('examples') {
continue;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition is to exclude such as when
examples is examples/templates/objects.ts
and exclude contains templates/objects.ts
.
So the items in exclude list don't need to have examples/
.
tests/examples/examples.test.ts
Outdated
continue; | ||
} | ||
it.concurrent(`Run ${example}`, async () => { | ||
const { stdout } = await execAsync(`yarn start -- ${example} <<< "Hello world"`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should also check for stderr
being empty and return code being equal to 0
The |
It's M1 Mac. Sonoma 14.5 |
Signed-off-by: Akihiko Kuroda <akihikokuroda2020@gmail.com>
c11d59a
to
96a57d8
Compare
Which issue(s) does this pull-request address?
Closes: #62
Description
This PR changes add making examples run during e2e testing.
Checklist
yarn lint
oryarn lint:fix
yarn format
oryarn format:fix
yarn test:unit
yarn test:e2e