Skip to content

Commit

Permalink
test: getContext fix
Browse files Browse the repository at this point in the history
  • Loading branch information
PengYYYYY committed Jun 23, 2022
1 parent 749a730 commit 19723bb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/snap/__snapshots__/ssr.test.js.snap

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions test/snap/csr.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import glob from 'glob';
import MockDate from 'mockdate';
import { vi } from 'vitest';
import { mount } from '@vue/test-utils';

// 固定时间,当使用 new Date() 时,返回固定时间,防止“当前时间”的副作用影响,导致 snapshot 变更,mockdate 插件见 https://github.com/boblauer/MockDate
Expand All @@ -9,6 +10,8 @@ function runTest() {
const files = glob.sync('./examples/**/demos/*.vue');

describe('csr snapshot test', () => {
HTMLCanvasElement.prototype.getContext = vi.fn();

files.forEach((file) => {
it(`csr test ${file}`, async () => {
const demo = await import(`../.${file}`);
Expand Down
3 changes: 3 additions & 0 deletions test/snap/ssr.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import glob from 'glob';
import MockDate from 'mockdate';
import { vi } from 'vitest';
import { config } from '@vue/test-utils';

// 固定时间,当使用 new Date() 时,返回固定时间,防止“当前时间”的副作用影响,导致 snapshot 变更,mockdate 插件见 https://github.com/boblauer/MockDate
Expand All @@ -10,6 +11,8 @@ function runTest() {
const { createSSRApp } = config.global;

describe('ssr snapshot test', () => {
HTMLCanvasElement.prototype.getContext = vi.fn();

files.forEach((file) => {
it(`ssr test ${file}`, async () => {
const demo = await import(`../.${file}`);
Expand Down

0 comments on commit 19723bb

Please sign in to comment.