electron.spec.js 915 B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * @jest-environment node
  3. */
  4. import spectron from "spectron";
  5. import { testWithSpectron } from "vue-cli-plugin-electron-builder";
  6. jest.setTimeout(50000);
  7. test("Window Loads Properly", async () => {
  8. // Wait for dev server to start
  9. const { app, stopServe } = await testWithSpectron(spectron);
  10. const win = app.browserWindow;
  11. const client = app.client;
  12. // Window was created
  13. expect(await client.getWindowCount()).toBe(1);
  14. // It is not minimized
  15. expect(await win.isMinimized()).toBe(false);
  16. // Window is visible
  17. expect(await win.isVisible()).toBe(true);
  18. // Size is correct
  19. const { width, height } = await win.getBounds();
  20. expect(width).toBeGreaterThan(0);
  21. expect(height).toBeGreaterThan(0);
  22. // App is loaded properly
  23. expect(
  24. /Welcome to Your Vue\.js (\+ TypeScript )?App/.test(
  25. await (await app.client.$("#app")).getHTML()
  26. )
  27. ).toBe(true);
  28. await stopServe();
  29. });