simple-file-operations.test.ts 990 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { beforeEach, afterEach, it, expect } from "vitest"
  2. import { describe } from "vitest"
  3. import { poll, TestRig } from "./test-helper"
  4. import { onTestFailed } from "vitest"
  5. describe("Simple File Operations", () => {
  6. let rig: TestRig
  7. beforeEach(({ task }) => {
  8. rig = new TestRig(task.name)
  9. })
  10. afterEach(async () => {
  11. await rig.cleanup()
  12. })
  13. it("should increase a file number in an existing file", async () => {
  14. rig.createFile("text.json", JSON.stringify({ version: 1 }))
  15. const run = await rig.runInteractive(["--mode", "code"])
  16. onTestFailed(() => {
  17. console.log(run.getStrippedOutput())
  18. })
  19. await run.type("Increase the version number in text.json with 1")
  20. await run.pressEnter()
  21. await poll(
  22. () => {
  23. return (
  24. run.getStrippedOutput().includes("✓ Task Completed") || run.getStrippedOutput().includes("✖ Error")
  25. )
  26. },
  27. 60_000,
  28. 1_000,
  29. )
  30. expect(rig.readFile("text.json")).toEqual(JSON.stringify({ version: 2 }))
  31. }, 120_000)
  32. })