Repository navigation
Expand file tree
/
Copy pathvitest.config.ts
More file actions
60 lines (58 loc) · 2.74 KB
/
Copy pathvitest.config.ts
File metadata and controls
60 lines (58 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { defineConfig } from 'vitest/config';
/**
* Runner configuration merged into the one `@angular/build:unit-test` generates.
*
* The single reason this file exists: `@ionic/angular` reaches `@ionic/core/components` as a
* *directory* import, which Node's ESM resolver rejects outright. Vitest externalises the
* package by default and hands it to Node, so every Ionic-touching spec fails to load with
* "Directory import ... is not supported".
*
* Inlining the package puts resolution back in Vite's hands, where the directory import is
* understood. This is a property of how Ionic ships, not of any spec, so it belongs in the
* runner config rather than in a per-spec workaround.
*/
export default defineConfig({
test: {
/**
* Vitest's 5s default is a poor fit for Angular TestBed. The first `createComponent()` in a
* file compiles the component and everything it imports, which for the larger screens runs
* past 5s on a cold Vite cache even though the test body itself is synchronous — so a spec
* passes locally on a warm re-run and fails in CI, which is always cold. The cost is paid
* once per file, not per test, so a higher ceiling costs nothing on the passing path.
*/
testTimeout: 30_000,
/**
* The same ceiling for hooks, because that is where the cost above is usually paid: a suite
* that creates its component in `beforeEach` compiles it there, not in the test body. Vitest
* leaves `hookTimeout` at 10s, which `client-form.component.test.ts` and
* `wc-loan-product-form.component.test.ts` exceed whenever the machine is busy — a wizard
* built from several dozen Ionic components, timing out in a hook that is itself
* synchronous. The failure names an unrelated test and reads like a flake in whatever file
* the suite happened to be running.
*/
hookTimeout: 30_000,
server: {
deps: {
inline: [/@ionic\/angular/, /@ionic\/core/],
},
},
},
});