@@ -48,6 +48,32 @@ Build the TypeScript source to JavaScript:
4848npm run build
4949```
5050
51+ ### Local testing of stub functions using another project
52+
53+ Ensure package is not already installed in the project testing the changes.
54+
55+ ``` bash
56+ npm uninstall @sourceallies/vue-testing-library-stubs
57+ ```
58+
59+ Ensure Vue Testing Library Stubs project is using the same node version as the project testing the changes.
60+
61+ ``` bash
62+ node -v
63+ ```
64+
65+ Create a symlink for the project testing the changes to connect to.
66+
67+ ``` bash
68+ npm link
69+ ```
70+
71+ In project testing the changes link the package
72+
73+ ``` bash
74+ npm link @sourceallies/vue-testing-library-stubs
75+ ```
76+
5177The compiled output will be in the ` dist/ ` directory.
5278
5379### Project Structure
@@ -70,7 +96,7 @@ Create a simple stub component for testing:
7096
7197``` typescript
7298import { mount } from ' @vue/test-utils' ;
73- import { getStub } from ' vue-testing-library-stubs' ;
99+ import { getStub } from ' @sourceallies/ vue-testing-library-stubs' ;
74100
75101const wrapper = mount (MyParentComponent , {
76102 global: {
@@ -88,7 +114,7 @@ expect(wrapper.text()).toContain('ChildComponent-stub');
88114
89115``` typescript
90116import { render , screen } from ' @testing-library/vue' ;
91- import { getStub } from ' vue-testing-library-stubs' ;
117+ import { getStub } from ' @sourceallies/ vue-testing-library-stubs' ;
92118
93119render (MyParentComponent , {
94120 global: {
@@ -110,7 +136,7 @@ Test components that pass props to child components:
110136
111137``` typescript
112138import { mount } from ' @vue/test-utils' ;
113- import { getStubWithProps } from ' vue-testing-library-stubs' ;
139+ import { getStubWithProps } from ' @sourceallies/ vue-testing-library-stubs' ;
114140
115141const wrapper = mount (MyParentComponent , {
116142 global: {
@@ -129,7 +155,7 @@ expect(wrapper.text()).toContain('count-42');
129155
130156``` typescript
131157import { render , screen } from ' @testing-library/vue' ;
132- import { getStubWithProps } from ' vue-testing-library-stubs' ;
158+ import { getStubWithProps } from ' @sourceallies/ vue-testing-library-stubs' ;
133159
134160render (MyParentComponent , {
135161 global: {
@@ -152,7 +178,7 @@ Test components that listen to child component events:
152178
153179``` typescript
154180import { mount } from ' @vue/test-utils' ;
155- import { getEmittingStub } from ' vue-testing-library-stubs' ;
181+ import { getEmittingStub } from ' @sourceallies/ vue-testing-library-stubs' ;
156182
157183const wrapper = mount (MyParentComponent , {
158184 global: {
@@ -176,7 +202,7 @@ expect(wrapper.emitted('save')?.[0]).toEqual([{ id: 123 }]);
176202``` typescript
177203import { render , screen } from ' @testing-library/vue' ;
178204import userEvent from ' @testing-library/user-event' ;
179- import { getEmittingStub } from ' vue-testing-library-stubs' ;
205+ import { getEmittingStub } from ' @sourceallies/ vue-testing-library-stubs' ;
180206
181207const { emitted } = render (MyParentComponent , {
182208 global: {
@@ -203,7 +229,7 @@ Combine props and event emission:
203229
204230``` typescript
205231import { mount } from ' @vue/test-utils' ;
206- import { getEmittingStubWithProps } from ' vue-testing-library-stubs' ;
232+ import { getEmittingStubWithProps } from ' @sourceallies/ vue-testing-library-stubs' ;
207233
208234const wrapper = mount (MyParentComponent , {
209235 global: {
@@ -233,7 +259,7 @@ expect(wrapper.emitted('update')?.[0]).toEqual([{ newValue: 'test' }]);
233259``` typescript
234260import { render , screen } from ' @testing-library/vue' ;
235261import userEvent from ' @testing-library/user-event' ;
236- import { getEmittingStubWithProps } from ' vue-testing-library-stubs' ;
262+ import { getEmittingStubWithProps } from ' @sourceallies/ vue-testing-library-stubs' ;
237263
238264const { emitted } = render (MyParentComponent , {
239265 global: {
@@ -269,7 +295,7 @@ Test components with multiple event handlers:
269295
270296``` typescript
271297import { mount } from ' @vue/test-utils' ;
272- import { getMultiEmittingStubWithProps , type EmittedEvent } from ' vue-testing-library-stubs' ;
298+ import { getMultiEmittingStubWithProps , type EmittedEvent } from ' @sourceallies/ vue-testing-library-stubs' ;
273299
274300const events: EmittedEvent [] = [
275301 { name: ' save' , value: { id: 1 } },
@@ -302,7 +328,7 @@ expect(wrapper.emitted('cancel')?.[0]).toEqual([undefined]);
302328``` typescript
303329import { render , screen } from ' @testing-library/vue' ;
304330import userEvent from ' @testing-library/user-event' ;
305- import { getMultiEmittingStubWithProps , type EmittedEvent } from ' vue-testing-library-stubs' ;
331+ import { getMultiEmittingStubWithProps , type EmittedEvent } from ' @sourceallies/ vue-testing-library-stubs' ;
306332
307333const events: EmittedEvent [] = [
308334 { name: ' save' , value: { id: 1 } },
@@ -339,7 +365,7 @@ Test parent components that call child validation methods:
339365
340366``` typescript
341367import { mount } from ' @vue/test-utils' ;
342- import { getExposedValidateStub } from ' vue-testing-library-stubs' ;
368+ import { getExposedValidateStub } from ' @sourceallies/ vue-testing-library-stubs' ;
343369
344370const wrapper = mount (MyFormComponent , {
345371 global: {
@@ -357,7 +383,7 @@ expect(wrapper.text()).toContain('InputComponent-stub-validated-true');
357383
358384``` typescript
359385import { render , screen } from ' @testing-library/vue' ;
360- import { getExposedValidateStub } from ' vue-testing-library-stubs' ;
386+ import { getExposedValidateStub } from ' @sourceallies/ vue-testing-library-stubs' ;
361387
362388render (MyFormComponent , {
363389 global: {
@@ -379,7 +405,7 @@ Test components that use child component's exposed functions:
379405
380406``` typescript
381407import { mount } from ' @vue/test-utils' ;
382- import { getTemplateComponentForExposedFunction } from ' vue-testing-library-stubs' ;
408+ import { getTemplateComponentForExposedFunction } from ' @sourceallies/ vue-testing-library-stubs' ;
383409
384410const props = { value: ' test' , enabled: true };
385411
@@ -402,7 +428,7 @@ await wrapper.find('button').trigger('click');
402428``` typescript
403429import { render , screen } from ' @testing-library/vue' ;
404430import userEvent from ' @testing-library/user-event' ;
405- import { getTemplateComponentForExposedFunction } from ' vue-testing-library-stubs' ;
431+ import { getTemplateComponentForExposedFunction } from ' @sourceallies/ vue-testing-library-stubs' ;
406432
407433const props = { value: ' test' , enabled: true };
408434
0 commit comments