/
index.js
executable file
·599 lines (580 loc) · 19.2 KB
/
index.js
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, {useEffect} from 'react';
import Layout from '@theme/Layout';
import Head from '@docusaurus/Head';
import Link from '@docusaurus/Link';
import backers from '@site/backers.json';
import Translate from '@docusaurus/Translate';
import {setupLandingAnimation} from '@site/src/pages/animations/_landingAnimation';
// TODO legacy Docusaurus v1 components
import Container from '@site/src/components/v1/Container';
import GridBlock from '@site/src/components/v1/GridBlock';
import MarkdownBlock from '@site/src/components/v1/MarkdownBlock';
import UsersJSON from '@site/users.json';
import styles from './index.module.scss';
import GitHubButton from 'react-github-btn';
function TwitterButton() {
return (
<a
href="https://twitter.com/intent/follow?screen_name=fbjest®ion=follow_link"
target="_blank"
className={styles['twitter-follow-button']}
>
<div className={styles['twitter-follow-button--icon']} />
Follow @fbjest
</a>
);
}
function GitHubStarButton() {
return (
<div className="github-button">
<GitHubButton
href="https://github.com/facebook/jest"
data-icon="octicon-star"
data-size="large"
aria-label="Star facebook/jest on GitHub"
>
Star
</GitHubButton>
</div>
);
}
class Button extends React.Component {
render() {
return (
<Link
className="jest-button"
to={this.props.href}
target={this.props.target}
>
{this.props.children}
</Link>
);
}
}
const Sponsor = ({
fromAccount: {name, slug, website, imageUrl},
totalDonations,
}) => (
<a
key={slug}
className="sponsor-item"
title={`$${totalDonations.value} by ${name || slug}`}
target="_blank"
rel="nofollow noopener"
href={website || `https://opencollective.com/${slug}`}
>
{
<img
className="sponsor-avatar"
src={imageUrl}
alt={name || slug ? `${name || slug}'s avatar` : 'avatar'}
/>
}
</a>
);
const Backer = ({
fromAccount: {name, slug, website, imageUrl},
totalDonations,
}) => (
<a
key={slug}
className="backer-item"
title={`$${totalDonations.value} by ${name || slug}`}
target="_blank"
rel="nofollow noopener"
href={website || `https://opencollective.com/${slug}`}
>
{
<img
className="backer-avatar"
src={imageUrl}
alt={name || slug ? `${name || slug}'s avatar` : 'avatar'}
/>
}
</a>
);
class Contributors extends React.Component {
render() {
return (
<div className="opencollective">
<h3>
<Translate>Sponsors</Translate>
</h3>
<p>
<Translate>
Sponsors are those who contribute $100 or more per month to Jest
</Translate>
</p>
<div className="opencollective-avatars">
{backers
.filter(b => b.tier && b.tier.slug === 'sponsor')
.map(Sponsor)}
</div>
<h3>
<Translate>Backers</Translate>
</h3>
<p>
<Translate>
Backers are those who contribute $2 or more per month to Jest
</Translate>
</p>
<div className="opencollective-avatars">
{backers
.filter(
b =>
b.tier &&
b.tier.slug === 'backer' &&
!b.fromAccount.slug.includes('adult')
)
.map(Backer)}
</div>
</div>
);
}
}
class Card extends React.Component {
render() {
const {index} = this.props;
return (
<div key={index} className="jest-card-hitslop">
<div className="jest-card jest-card-running" data-index={index}>
<div className="jest-card-front">
<div className="jest-card-label">JEST</div>
<div className="jest-card-logo-container">
<div className="jest-card-logo" />
</div>
<div className="jest-card-label jest-card-label-reverse">JEST</div>
</div>
<div className="jest-card-back">
<svg viewBox="0 0 200 200" style={{height: 150, width: 150}}>
<defs>
<path
d="M100 100 m -75 0 a75 75 0 1 0 150 0 a 75 75 0 1 0 -150 0"
id="runs-path"
/>
</defs>
<circle
cx="100"
cy="100"
r="88"
stroke="#fff"
strokeWidth="8"
fill="#C2A813"
/>
<g className="run-circle">
<circle cx="100" cy="100" r="50" fill="#fff" />
<circle
cx="100"
cy="100"
r="45"
fill="#C2A813"
className="run-circle"
/>
<circle
cx="100"
cy="100"
r="35"
fill="#fff"
className="run-circle"
/>
<circle
cx="100"
cy="100"
r="25"
fill="#C2A813"
className="run-circle"
/>
<circle
cx="100"
cy="100"
r="15"
fill="#fff"
className="run-circle"
/>
</g>
<g
fill="#fff"
fontWeight="bold"
fontSize={26}
letterSpacing="0.2em"
className="run-text"
>
<text>
<textPath xlinkHref="#runs-path" href="#runs-path">
RUNS
</textPath>
</text>
<text transform="rotate(90,100,100)">
<textPath xlinkHref="#runs-path" href="#runs-path">
RUNS
</textPath>
</text>
<text transform="rotate(180,100,100)">
<textPath xlinkHref="#runs-path" href="#runs-path">
RUNS
</textPath>
</text>
<text transform="rotate(270,100,100)">
<textPath xlinkHref="#runs-path" href="#runs-path">
RUNS
</textPath>
</text>
</g>
</svg>
</div>
</div>
</div>
);
}
}
class Hand extends React.Component {
render() {
const cards = [0, 1, 2, 3, 4].map(i => <Card key={i} index={i} />);
return (
<div className="jest-hand">
{cards}
<script src="/landing.js" />
</div>
);
}
}
const HeroInteractive = () => (
<div className="wrapperV1">
<div className="jest-hero-interactive">
<div className={styles.socialLinks}>
<TwitterButton />
<GitHubStarButton />
</div>
<Hand />
<div className="jest-button-container">
<Button href={'/docs/getting-started'}>
<Translate>Get Started</Translate>
</Button>
<Button href={'/docs/getting-started'}>
<Translate>Docs</Translate>
</Button>
<Button href={'/docs/configuration'}>
<Translate>Config</Translate>
</Button>
<Button href={'/help'}>
<Translate>Get help</Translate>
</Button>
</div>
</div>
</div>
);
class Index extends React.Component {
render() {
const {config: siteConfig} = this.props;
const showcase = UsersJSON.users.map((user, i) => (
<a href={user.infoLink} key={i}>
<img src={user.image} title={user.caption} alt={user.caption} />
</a>
));
return (
<div>
<Head>
<title>
{siteConfig.title} {siteConfig.titleDelimiter} {siteConfig.tagline}
</title>
</Head>
<HeroInteractive config={siteConfig} />
<div className="mainContainerV1" style={{padding: 0}}>
<Container
padding={['bottom', 'top']}
background="light"
className="intro"
>
<p>
<Translate>
Jest is a delightful JavaScript Testing Framework with a focus
on simplicity.
</Translate>
</p>
<p>
<MarkdownBlock>
<Translate>
It works with projects using: [Babel](https://babeljs.io/),
[TypeScript](https://www.typescriptlang.org/),
[Node](https://nodejs.org/), [React](https://reactjs.org),
[Angular](https://angular.io), [Vue](https://vuejs.org) and
more!
</Translate>
</MarkdownBlock>
</p>
</Container>
<Container padding={['bottom', 'top']} className="features">
<GridBlock
align="center"
className="yellow"
contents={[
{
content: (
<Translate>
Jest aims to work out of the box, config free, on most
JavaScript projects.
</Translate>
),
title: <Translate>Zero config</Translate>,
},
{
content: (
<Translate>
Make tests which keep track of large objects with ease.
Snapshots live either alongside your tests, or embedded
inline.
</Translate>
),
title: <Translate>Snapshots</Translate>,
},
{
content: (
<Translate>
Tests are parallelized by running them in their own
processes to maximize performance.
</Translate>
),
title: <Translate>Isolated</Translate>,
},
{
content: (
<Translate>
From `it` to `expect` - Jest has the entire toolkit in one
place. Well documented, well maintained, well good.
</Translate>
),
title: <Translate>Great api</Translate>,
},
]}
layout="fourColumn"
/>
</Container>
<Container
padding={['bottom', 'top']}
className="section-container lightBackground"
>
<GridBlock
className="green"
contents={[
{
content: (
<Translate>
By ensuring your tests have unique global state, Jest can
reliably run tests in parallel. To make things quick, Jest
runs previously failed tests first and re-organizes runs
based on how long test files take.
</Translate>
),
image: '/img/content/feature-fast.png',
imageAlign: 'left',
title: <Translate>Fast and safe</Translate>,
},
]}
/>
{/* Wondering where the image + buttons come from? That's client-side code in landing.js */}
</Container>
<Container padding={['bottom', 'top']} className="section-container">
<GridBlock
className="yellow"
contents={[
{
content: (
<Translate>
Generate code coverage by adding the flag
[`--coverage`](/docs/cli#--coverageboolean). No additional
setup needed. Jest can collect code coverage information
from entire projects, including untested files.
</Translate>
),
image: '/img/content/feature-coverage.png',
imageAlign: 'right',
title: <Translate>Code coverage</Translate>,
},
]}
/>
</Container>
<Container
padding={['bottom', 'top']}
className="section-container lightBackground"
>
<GridBlock
className="red"
contents={[
{
content: (
<Translate>
Jest uses a custom resolver for imports in your tests,
making it simple to mock any object outside of your test’s
scope. You can use mocked imports with the rich [Mock
Functions](/docs/mock-functions) API to spy on function
calls with readable test syntax.
</Translate>
),
image: '/img/content/feature-mocking.png',
imageAlign: 'left',
title: <Translate>Easy Mocking</Translate>,
},
]}
/>
</Container>
<Container padding={['bottom', 'top']} className="section-container">
<GridBlock
className="green matchers"
contents={[
{
content: (
<Translate>
Tests fail—when they do, Jest provides rich context why.
Here are some examples:
</Translate>
),
image: '/img/content/matchers/toBe.png',
imageAlign: 'right',
title: <Translate>Great Exceptions</Translate>,
},
]}
/>
</Container>
<Container
padding={['bottom', 'top']}
background="light"
className="section-container philosophy"
>
<div className="blockElement yellow">
<div className="blockContent">
<h2>
<Translate>Philosophy</Translate>
</h2>
</div>
</div>
<div className="blockElement imageAlignSide gridBlock threeByGridBlock bottom-margin philosophy">
<div className="blockContent">
<MarkdownBlock>
<Translate>
Jest is a JavaScript testing framework designed to ensure
correctness of any JavaScript codebase. It allows you to
write tests with an approachable, familiar and feature-rich
API that gives you results quickly.
</Translate>
</MarkdownBlock>
</div>
<div className="blockContent">
<MarkdownBlock>
<Translate>
Jest is well-documented, requires little configuration and
can be extended to match your requirements.
</Translate>
</MarkdownBlock>
<MarkdownBlock>
<Translate>Jest makes testing delightful.</Translate>
</MarkdownBlock>
<div className="show-small">
<p style={{fontFamily: 'Monaco, Courier, monospace'}}>
<Translate>- Jest Core Team</Translate>
</p>
</div>
</div>
<div className="blockContent flex-end hide-small">
<p style={{fontFamily: 'Monaco, Courier, monospace'}}>
<Translate>- Jest Core Team</Translate>
</p>
</div>
</div>
</Container>
<Container
padding={['bottom', 'top']}
className="section-container bottom-margin docs"
>
<div className="blockElement imageAlignSide gridBlock video-block">
<div className="blockContent ">
<div className="video">
<iframe
width="560"
height="315"
src="https://www.youtube.com/embed/cAKYQpTC7MA"
frameBorder="0"
allow="autoplay; encrypted-media"
allowFullScreen
/>
</div>
</div>
</div>
<div className="blockElement red bottom-margin">
<div className="blockContent">
<h2>
<Translate>Docs and talks</Translate>
</h2>
<MarkdownBlock>
<Translate>
The Jest core team and contributors regularly speak about
[Jest and Delightful JavaScript
Testing](https://www.youtube.com/watch?v=cAKYQpTC7MA). Check
out our talk about [Building High-Quality JavaScript
Tools](https://www.youtube.com/watch?v=PvabBs_utr8) at
jsconf.eu 2017 and our talk about [Jest as a
Platform](https://www.youtube.com/watch?v=NtjyeojAOBs) at
ReactiveConf 2017.
</Translate>
</MarkdownBlock>
</div>
</div>
</Container>
<Container
padding={['bottom', 'top']}
background="light"
className="section-container community imageAlignSide twoByGridBlock"
>
<div className="gridBlockV1 yellow">
<div className="blockContent">
<h2>
<Translate>Open Collective</Translate>
</h2>
<MarkdownBlock>
<Translate>
With so many users, the core team of Jest uses an [Open
Collective](https://opencollective.com/jest) for
non-Facebook contributors.
</Translate>
</MarkdownBlock>
<Contributors />
</div>
<div className="blockContent yellow">
<h2>
<Translate>Who uses Jest?</Translate>
</h2>
<MarkdownBlock>
<Translate>
A lot of people! With
[20m](https://www.npmjs.com/package/jest) downloads in the
last month, and used on over
[1,293,000](https://github.com/facebook/jest/network/dependents)
public repos on GitHub. Jest is used extensively at these
companies:
</Translate>
</MarkdownBlock>
<div className="gridBlockV1 logos">
{showcase}
<p className="others">And many others</p>
</div>
</div>
</div>
</Container>
</div>
</div>
);
}
}
export default function IndexPage(props) {
useEffect(setupLandingAnimation, []);
return (
<Layout>
<Index {...props} />
</Layout>
);
}