Skip to content

Commit 7fb6b86

Browse files
authored
docs(devs-infra): show content of jest-global-mocks in tip (#957)
1 parent b3e8047 commit 7fb6b86

File tree

3 files changed

+84
-3
lines changed

3 files changed

+84
-3
lines changed

website/docs/getting-started/installation.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,34 @@ import './jest-global-mocks';
8181

8282
:::tip
8383

84-
Feel free to copy the [`jest-global-mocks.ts`](https://github.com/thymikee/jest-preset-angular/blob/master/e2e/test-app-v9/jest-global-mocks.ts) file from the test app directory and save it next to the `setup-jest.ts` file.
84+
An example for `jest-global-mocks.ts`
85+
86+
```
87+
Object.defineProperty(window, 'CSS', { value: null });
88+
Object.defineProperty(document, 'doctype', {
89+
value: '<!DOCTYPE html>',
90+
});
91+
Object.defineProperty(window, 'getComputedStyle', {
92+
value: () => {
93+
return {
94+
display: 'none',
95+
appearance: ['-webkit-appearance'],
96+
};
97+
},
98+
});
99+
/**
100+
* ISSUE: https://github.com/angular/material2/issues/7101
101+
* Workaround for JSDOM missing transform property
102+
*/
103+
Object.defineProperty(document.body.style, 'transform', {
104+
value: () => {
105+
return {
106+
enumerable: true,
107+
configurable: true,
108+
};
109+
},
110+
});
111+
```
85112

86113
:::
87114

website/versioned_docs/version-8.x/getting-started/installation.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,34 @@ import './jest-global-mocks';
8181

8282
:::tip
8383

84-
Feel free to copy the [`jest-global-mocks.ts`](https://github.com/thymikee/jest-preset-angular/blob/master/e2e/test-app-v9/jest-global-mocks.ts) file from the test app directory and save it next to the `setup-jest.ts` file.
84+
An example for `jest-global-mocks.ts`
85+
86+
```
87+
Object.defineProperty(window, 'CSS', { value: null });
88+
Object.defineProperty(document, 'doctype', {
89+
value: '<!DOCTYPE html>',
90+
});
91+
Object.defineProperty(window, 'getComputedStyle', {
92+
value: () => {
93+
return {
94+
display: 'none',
95+
appearance: ['-webkit-appearance'],
96+
};
97+
},
98+
});
99+
/**
100+
* ISSUE: https://github.com/angular/material2/issues/7101
101+
* Workaround for JSDOM missing transform property
102+
*/
103+
Object.defineProperty(document.body.style, 'transform', {
104+
value: () => {
105+
return {
106+
enumerable: true,
107+
configurable: true,
108+
};
109+
},
110+
});
111+
```
85112

86113
:::
87114

website/versioned_docs/version-9.x/getting-started/installation.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,34 @@ import './jest-global-mocks';
8181

8282
:::tip
8383

84-
Feel free to copy the [`jest-global-mocks.ts`](https://github.com/thymikee/jest-preset-angular/blob/master/e2e/test-app-v9/jest-global-mocks.ts) file from the test app directory and save it next to the `setup-jest.ts` file.
84+
An example for `jest-global-mocks.ts`
85+
86+
```
87+
Object.defineProperty(window, 'CSS', { value: null });
88+
Object.defineProperty(document, 'doctype', {
89+
value: '<!DOCTYPE html>',
90+
});
91+
Object.defineProperty(window, 'getComputedStyle', {
92+
value: () => {
93+
return {
94+
display: 'none',
95+
appearance: ['-webkit-appearance'],
96+
};
97+
},
98+
});
99+
/**
100+
* ISSUE: https://github.com/angular/material2/issues/7101
101+
* Workaround for JSDOM missing transform property
102+
*/
103+
Object.defineProperty(document.body.style, 'transform', {
104+
value: () => {
105+
return {
106+
enumerable: true,
107+
configurable: true,
108+
};
109+
},
110+
});
111+
```
85112

86113
:::
87114

0 commit comments

Comments
 (0)