Skip to content

Commit 1b82f83

Browse files
committed
import missing functions from vitest
1 parent efc6f0e commit 1b82f83

File tree

8 files changed

+19
-18
lines changed

8 files changed

+19
-18
lines changed

projects/testing-library/src/tests/bindings.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, input, output, inputBinding, outputBinding, twoWayBinding, signal, model } from '@angular/core';
2-
import { vi, describe, test } from 'vitest';
2+
import { vi, describe, test, expect } from 'vitest';
33
import { render, screen, aliasedInput } from '../public_api';
44

55
describe('Bindings API Support', () => {

projects/testing-library/src/tests/config.spec.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, InjectionToken, NgModule } from '@angular/core';
22
import { TestBed } from '@angular/core/testing';
3-
import { test } from 'vitest';
3+
import { test, afterEach, beforeEach } from 'vitest';
44
import { render, configure, Config } from '../public_api';
55

66
const TEST_TOKEN = new InjectionToken<string>('TEST_TOKEN');
@@ -23,21 +23,16 @@ beforeEach(() => {
2323
// it at the end of the test
2424
configure((existingConfig) => {
2525
originalConfig = existingConfig as Config;
26-
// Don't change the existing config
27-
return {};
26+
return {
27+
defaultImports: [TestModule],
28+
};
2829
});
2930
});
3031

3132
afterEach(() => {
3233
configure(originalConfig);
3334
});
3435

35-
beforeEach(() => {
36-
configure({
37-
defaultImports: [TestModule],
38-
});
39-
});
40-
4136
test('adds default imports to the testbed', async () => {
4237
await render(TestComponent);
4338

projects/testing-library/src/tests/integration.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, EventEmitter, inject, Injectable, Input, Output } from '@angular/core';
22
import { TestBed } from '@angular/core/testing';
3-
import { vi, test, expect } from 'vitest';
3+
import { vi, test, expect, afterEach } from 'vitest';
44
import { of, BehaviorSubject } from 'rxjs';
55
import { debounceTime, switchMap, map, startWith } from 'rxjs/operators';
66
import { render, screen, waitFor, waitForElementToBeRemoved, within } from '../lib/testing-library';
@@ -92,6 +92,10 @@ const entities = [
9292
},
9393
];
9494

95+
afterEach(() => {
96+
vi.useRealTimers();
97+
});
98+
9599
async function setup() {
96100
vi.useFakeTimers();
97101
const user = userEvent.setup();

projects/testing-library/src/tests/issues/issue-318.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, inject, OnDestroy, OnInit } from '@angular/core';
22
import { Router } from '@angular/router';
33
import { RouterTestingModule } from '@angular/router/testing';
4-
import { vi, test } from 'vitest';
4+
import { vi, test, expect } from 'vitest';
55
import { Subject, takeUntil } from 'rxjs';
66
import { render } from '../../public_api';
77

projects/testing-library/src/tests/issues/issue-386.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component } from '@angular/core';
2-
import { vi, describe, test } from 'vitest';
2+
import { vi, describe, test, afterEach, beforeEach } from 'vitest';
33
import { throwError } from 'rxjs';
44
import { render, screen, fireEvent } from '../../public_api';
55

projects/testing-library/src/tests/issues/issue-435.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { CommonModule } from '@angular/common';
22
import { BehaviorSubject } from 'rxjs';
33
import { Component, inject, Injectable } from '@angular/core';
44
import { screen, render } from '../../public_api';
5+
import { expect, test } from 'vitest';
56

67
// Service
78
@Injectable()

projects/testing-library/src/tests/issues/issue-437.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import userEvent from '@testing-library/user-event';
22
import { MatSidenavModule } from '@angular/material/sidenav';
3-
import { vi, test } from 'vitest';
3+
import { vi, test, afterEach } from 'vitest';
44
import { screen, render } from '../../public_api';
55

66
afterEach(() => {
@@ -54,4 +54,5 @@ test('issue #437 with fakeTimers', async () => {
5454
await screen.findByTestId('test-button');
5555

5656
await user.click(screen.getByTestId('test-button'));
57+
vi.useRealTimers();
5758
});

projects/testing-library/src/tests/rerender.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
2-
import { vi, test, type Mock } from 'vitest';
2+
import { vi, test, afterEach } from 'vitest';
33
import { render, screen } from '../public_api';
44

5-
let ngOnChangesSpy: Mock;
5+
const ngOnChangesSpy = vi.fn();
66
@Component({
77
selector: 'atl-fixture',
88
template: ` {{ firstName }} {{ lastName }} `,
@@ -15,8 +15,8 @@ class FixtureComponent implements OnChanges {
1515
}
1616
}
1717

18-
beforeEach(() => {
19-
ngOnChangesSpy = vi.fn();
18+
afterEach(() => {
19+
ngOnChangesSpy.mockReset();
2020
});
2121

2222
test('rerenders the component with updated props', async () => {

0 commit comments

Comments
 (0)