Home Manual Reference Source Test

tests/integration/mzn.test.js

  1. import { describe, it, expect, beforeAll } from "vitest";
  2. import { initSolvers, solveModel } from "../../src/controller/solving.js";
  3. const SIMPLE_MZN = `
  4. var 1..5: x;
  5. constraint x > 3;
  6. solve satisfy;
  7. `;
  8. describe("integration: minizinc", () => {
  9. beforeAll(async () => {
  10. await initSolvers();
  11. }, 30000);
  12. /** @test {solveModel} */
  13. it("solves a trivial satisfy model and returns a solution", async () => {
  14. const result = await solveModel("test.mzn", SIMPLE_MZN, "gecode");
  15. expect(["SATISFIED", "OPTIMAL_SOLUTION"]).toContain(result.status);
  16. expect(result.solution).toBeDefined();
  17. const x = result.solution.output.json.x;
  18. expect(x).toBeGreaterThan(3);
  19. expect(x).toBeLessThanOrEqual(5);
  20. }, 30000);
  21. });