vitest-browser-angular 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ For detailed setup instructions for both Zone.js and Zoneless configurations, pl
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
21
|
```ts
|
|
22
|
-
import { test, expect } from 'vitest
|
|
22
|
+
import { test, expect } from 'vitest';
|
|
23
23
|
import { render } from 'vitest-browser-angular';
|
|
24
24
|
|
|
25
25
|
@Component({
|
|
@@ -158,6 +158,28 @@ test('render with route configuration', async () => {
|
|
|
158
158
|
});
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
+
## Component Providers
|
|
162
|
+
|
|
163
|
+
If you need to add or override [component providers](https://angular.dev/guide/di/defining-dependency-providers#component-or-directive-providers), you can use the `componentProviders` option.
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
@Component({
|
|
167
|
+
template: '<h1>{{ title }}</h1>',
|
|
168
|
+
providers: [GreetingService],
|
|
169
|
+
})
|
|
170
|
+
export class HelloWorldComponent {
|
|
171
|
+
title = 'Hello World';
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
test('renders component with service provider', async () => {
|
|
175
|
+
const { component } = await render(ServiceConsumerComponent, {
|
|
176
|
+
componentProviders: [
|
|
177
|
+
{ provide: GreetingService, useClass: FakeGreetingService },
|
|
178
|
+
],
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
```
|
|
182
|
+
|
|
161
183
|
## Contributing
|
|
162
184
|
|
|
163
185
|
Want to contribute? Yayy! 🎉
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as RenderResult, n as RenderConfig, o as cleanup, r as RenderFn, s as render, t as Inputs } from "./pure-
|
|
1
|
+
import { i as RenderResult, n as RenderConfig, o as cleanup, r as RenderFn, s as render, t as Inputs } from "./pure-WnJuXVlP.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/index.d.ts
|
|
4
4
|
declare module "vitest/browser" {
|
package/dist/index.mjs
CHANGED
|
@@ -17,6 +17,7 @@ async function render(componentClass, config) {
|
|
|
17
17
|
imports,
|
|
18
18
|
providers
|
|
19
19
|
});
|
|
20
|
+
if (config?.componentProviders) TestBed.overrideComponent(componentClass, { add: { providers: config.componentProviders } });
|
|
20
21
|
if (config?.withRouting) {
|
|
21
22
|
renderResult.routerHarness = await RouterTestingHarness.create(typeof config.withRouting === "boolean" ? void 0 : config.withRouting.initialRoute);
|
|
22
23
|
renderResult.router = TestBed.inject(Router);
|
|
@@ -14,6 +14,7 @@ interface RenderConfig<CMP_TYPE extends Type<unknown> = Type<unknown>> {
|
|
|
14
14
|
inputs?: Inputs<CMP_TYPE>;
|
|
15
15
|
withRouting?: RoutingConfig | boolean;
|
|
16
16
|
providers?: Array<Provider | EnvironmentProviders>;
|
|
17
|
+
componentProviders?: Array<Provider>;
|
|
17
18
|
imports?: unknown[];
|
|
18
19
|
}
|
|
19
20
|
interface RenderResult<T> {
|
package/dist/pure.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as RoutingConfig, i as RenderResult, n as RenderConfig, o as cleanup, r as RenderFn, s as render, t as Inputs } from "./pure-
|
|
1
|
+
import { a as RoutingConfig, i as RenderResult, n as RenderConfig, o as cleanup, r as RenderFn, s as render, t as Inputs } from "./pure-WnJuXVlP.mjs";
|
|
2
2
|
export { Inputs, RenderConfig, RenderFn, RenderResult, RoutingConfig, cleanup, render };
|
package/dist/pure.mjs
CHANGED