testeranto 0.79.21 → 0.79.23

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/src/Report.tsx DELETED
@@ -1,498 +0,0 @@
1
- import React, { useEffect, useState } from "react";
2
- import ReactDom from "react-dom/client";
3
- import Col from 'react-bootstrap/Col';
4
- import Nav from 'react-bootstrap/Nav';
5
- import Row from 'react-bootstrap/Row';
6
- import Tab from 'react-bootstrap/Tab';
7
- import Tabs from 'react-bootstrap/Tabs';
8
- import Graph from "graphology";
9
- import { Sigma, RandomizeNodePositions, RelativeSize } from 'react-sigma';
10
-
11
- import 'bootstrap/dist/css/bootstrap.min.css';
12
-
13
- import { TesterantoFeatures } from "./Features.js";
14
- import { IRunTime, ITestTypes } from "./lib/types.js";
15
- import ExampleTab from "./ExampleTab.js";
16
-
17
- type IGraphData = {
18
- nodes: { id: string, label: string }[],
19
- edges: { id: string, source: string, target: string, label: string }[]
20
- }
21
-
22
- const graphToIGraphData: (g: Graph) => IGraphData = (g) => {
23
- return {
24
- nodes: g.nodes().map((n) => {
25
- return {
26
- id: n,
27
- label: n
28
- }
29
- }),
30
- edges: g.mapEdges((id, attributes, source, target) => {
31
- return {
32
- id,
33
- label: id,
34
- source,
35
- target,
36
- }
37
- })
38
- }
39
- }
40
-
41
- document.addEventListener("DOMContentLoaded", function () {
42
- const elem = document.getElementById("root");
43
- if (elem) {
44
- ReactDom.createRoot(elem).render(React.createElement(Report, {}));
45
- }
46
- });
47
-
48
- const Report = () => {
49
-
50
- const [state, setState] = useState<{
51
- tests: ITestTypes[],
52
- buildDir: string,
53
- features: TesterantoFeatures
54
- results: any
55
- }>({
56
- tests: [],
57
- buildDir: "",
58
- features: new TesterantoFeatures({}, {
59
- undirected: [],
60
- directed: [],
61
- dags: []
62
- }),
63
- results: {}
64
- });
65
-
66
- const [tests, setTests] = useState<
67
- {
68
- tests: ITestTypes[],
69
- buildDir: string,
70
- }
71
-
72
- >({
73
- tests: [],
74
- buildDir: ""
75
- });
76
-
77
- const [features, setFeatures] = useState<TesterantoFeatures>(
78
- new TesterantoFeatures({}, {
79
- undirected: [],
80
- directed: [],
81
- dags: []
82
- })
83
- );
84
-
85
- const [results, setResults] = useState<Record<string, { exitcode, log, testresults, manifest }>>(
86
- {}
87
- );
88
-
89
- const importState = async () => {
90
- const features = await import('features.test.js');
91
- const config = await (await fetch("./testeranto.json")).json();
92
- const results = await Promise.all(config.tests.map((test) => {
93
- return new Promise(async (res, rej) => {
94
- const src: string = test[0];
95
- const runtime: IRunTime = test[1];
96
- const s: string = [tests.buildDir, runtime as string].concat(src.split(".").slice(0, - 1).join(".")).join("/");
97
- const exitcode = await (await fetch(config.buildDir + "/" + s + "/exitcode")).text()
98
- const log = await (await fetch(config.buildDir + "/" + s + "/log.txt")).text()
99
- const testresults = await (await fetch(config.buildDir + "/" + s + "/tests.json")).json()
100
- const manifest = await (await fetch(config.buildDir + "/" + s + "/manifest.json")).json()
101
-
102
- res({ src, exitcode, log, testresults, manifest })
103
- })
104
- }))
105
-
106
- setState({ tests: config.tests as any, results, features: features as any, buildDir: config.buildDir })
107
- };
108
-
109
- const importFeatures = async () => {
110
- const module = await import('features.test.js');
111
- setFeatures(module.default);
112
- };
113
-
114
- const importTests = async () => {
115
- const x = await fetch("./testeranto.json")
116
- const y = await x.json();
117
- setTests(y as any);
118
- };
119
-
120
- useEffect(() => { importState(); }, []);
121
-
122
- useEffect(() => { importFeatures(); }, []);
123
- useEffect(() => { importTests(); }, []);
124
-
125
- useEffect(() => {
126
- const collateResults = async () => {
127
- console.log("collating", tests, features);
128
- const r = tests.tests.reduce(async (p, test) => {
129
- const src: string = test[0];
130
- const runtime: IRunTime = test[1];
131
- console.log(runtime)
132
- const s: string = [tests.buildDir, runtime as string].concat(src.split(".").slice(0, - 1).join(".")).join("/");
133
- const exitcode = await (await fetch(s + "/exitcode")).text()
134
- const log = await (await fetch(s + "/log.txt")).text()
135
- const testresults = await (await fetch(s + "/tests.json")).text()
136
-
137
- p[src] = { exitcode, log, testresults }
138
- }, {});
139
-
140
- setResults(r);
141
-
142
- };
143
- collateResults();
144
- }, []);
145
-
146
- return (
147
- <div>
148
- <style>
149
- {`
150
- pre, code, p {
151
- max-width: 40rem;
152
- text-wrap: auto;
153
- }
154
- footer {
155
- background-color: lightgray;
156
- margin: 0.5rem;
157
- padding: 0.5rem;
158
- position: fixed;
159
- bottom: 0;
160
- right: 0;
161
- }
162
- `}
163
- </style>
164
-
165
- {features && tests && < Tabs defaultActiveKey="manual" >
166
-
167
- <Tab eventKey="manual" title="manual">
168
- <article>
169
- <h1>Testeranto</h1>
170
- <h2>What is testeranto?</h2>
171
- <p>
172
- Testeranto is a novel testing framework for typescript project. Inspired by Behavior Driven Development, testeranto allows you to wrap you typescript with gherkin-like semantics, producing a report in the form of a static website. Testeranto runs it's tests both in node and chromium.
173
- </p>
174
- </article>
175
- </Tab>
176
-
177
- <Tab eventKey="config" title="config">
178
- <pre>{JSON.stringify(state, null, 2)}</pre>
179
- </Tab>
180
-
181
- <Tab eventKey="results" title="results">
182
- <pre>{JSON.stringify(state.results, null, 2)}</pre>
183
- </Tab>
184
-
185
- <Tab eventKey="features" title="features">
186
- <Tab.Container id="left-tabs-example5" defaultActiveKey="feature-0">
187
- <Row>
188
- <Col sm={2}>
189
- <Nav variant="pills" className="flex-column">
190
- {Object.keys(features.features).map((featureKey, ndx) => <Nav.Item key={ndx}>
191
- <Nav.Link eventKey={`feature-${ndx}`}>
192
- {featureKey}
193
- </Nav.Link>
194
- </Nav.Item>)}
195
- </Nav>
196
- </Col>
197
- <Col sm={6}>
198
- <Tab.Content>
199
- {Object.keys(features.features).map((featureKey, ndx) => {
200
- const feature = features[featureKey];
201
- return (
202
- <Tab.Pane eventKey={`feature-${ndx}`} key={ndx}>
203
- <pre>{JSON.stringify(feature, null, 2)}</pre>
204
- </Tab.Pane>
205
- )
206
- }
207
- )}
208
- </Tab.Content>
209
- </Col>
210
-
211
- <Col sm={4}>
212
- < Tabs defaultActiveKey="feature.networks" >
213
- <Tab eventKey="feature.networks" title="networks">
214
- < Tabs defaultActiveKey="dag" >
215
-
216
- <Tab eventKey="dag" title="DAG">
217
- <Tab.Content>
218
- <pre>{JSON.stringify(features.graphs.dags, null, 2)}</pre>
219
- </Tab.Content>
220
- </Tab>
221
-
222
- <Tab eventKey="directed" title="Directed">
223
- <Tab.Content>
224
- <pre>{JSON.stringify(features.graphs.directed, null, 2)}</pre>
225
- </Tab.Content>
226
- </Tab>
227
-
228
- <Tab eventKey="undirected" title="Undirected">
229
- <Tab.Content>
230
- <pre>{JSON.stringify(features.graphs.undirected, null, 2)}</pre>
231
- </Tab.Content>
232
- </Tab>
233
-
234
- </Tabs>
235
- </Tab>
236
-
237
- <Tab eventKey="feature.tests" title="tests">
238
- <pre id="theProps">{JSON.stringify(tests.tests, null, 2)}</pre>
239
- </Tab>
240
- </Tabs>
241
- </Col>
242
-
243
- </Row>
244
- </Tab.Container>
245
- </Tab>
246
-
247
- <Tab eventKey="networks" title="networks">
248
- <Tab.Container id="left-tabs-example88" defaultActiveKey={`dag`}>
249
- <Row>
250
- < Tabs defaultActiveKey="dag" >
251
-
252
- <Tab eventKey="dag" title="DAG">
253
- <Tab.Content>
254
-
255
- <Row>
256
- <Col sm={2}>
257
- <Nav variant="pills" className="flex-column">
258
- {features.graphs.dags.map((g, ndx2) => <Nav.Item key={ndx2}>
259
- <Nav.Link eventKey={`networks-dags-${ndx2}`}>
260
- {g.name}
261
- </Nav.Link>
262
- </Nav.Item>
263
- )}
264
- </Nav>
265
- </Col>
266
- <Col sm={6}>
267
- <Tab.Content>
268
-
269
- {
270
- features.graphs.dags[0] && <>
271
- <Sigma graph={graphToIGraphData(features.graphs.dags[0].graph)} settings={{ drawEdges: true, clone: false }}>
272
- <RelativeSize initialSize={25} />
273
- <RandomizeNodePositions />
274
- </Sigma>
275
- <pre>{JSON.stringify(features.graphs.dags[0].graph, null, 2)}</pre>
276
- </>
277
- }
278
-
279
-
280
-
281
- </Tab.Content>
282
- </Col>
283
-
284
- <Col sm={4}>
285
- < Tabs defaultActiveKey="networks.features" >
286
- <Tab eventKey="networks.features" title="features">
287
- <pre id="theProps">{JSON.stringify(features, null, 2)}</pre>
288
- </Tab>
289
-
290
- <Tab eventKey="feature.tests" title="tests">
291
- <pre id="theProps">{JSON.stringify(tests.tests, null, 2)}</pre>
292
- </Tab>
293
- </Tabs>
294
- </Col>
295
-
296
- </Row>
297
-
298
- </Tab.Content>
299
- </Tab>
300
-
301
- <Tab eventKey="directed" title="Directed">
302
- <Tab.Content>
303
-
304
- <Row>
305
- <Col sm={2}>
306
- <Nav variant="pills" className="flex-column">
307
- {features.graphs.directed.map((g, ndx2) => <Nav.Item key={ndx2}>
308
- <Nav.Link eventKey={`networks-directed-${ndx2}`}>
309
- {g.name}
310
- </Nav.Link>
311
- </Nav.Item>
312
- )}
313
- </Nav>
314
- </Col>
315
- <Col sm={6}>
316
- <Tab.Content>
317
-
318
- {
319
- features.graphs.directed[0] && <>
320
- <Sigma graph={graphToIGraphData(features.graphs.directed[0].graph)} settings={{ drawEdges: true, clone: false }}>
321
- <RelativeSize initialSize={25} />
322
- <RandomizeNodePositions />
323
- </Sigma>
324
- <pre>{JSON.stringify(features.graphs.directed[0].graph, null, 2)}</pre>
325
- </>
326
- }
327
-
328
-
329
-
330
-
331
- </Tab.Content>
332
- </Col>
333
- <Col sm={4}>
334
- < Tabs defaultActiveKey="networks.features" >
335
- <Tab eventKey="networks.features" title="features">
336
- <pre id="theProps">{JSON.stringify(features, null, 2)}</pre>
337
- </Tab>
338
-
339
- <Tab eventKey="feature.tests" title="tests">
340
- <pre id="theProps">{JSON.stringify(tests.tests, null, 2)}</pre>
341
- </Tab>
342
- </Tabs>
343
- </Col>
344
- </Row>
345
-
346
- </Tab.Content>
347
- </Tab>
348
-
349
- <Tab eventKey="undirected" title="Undirected">
350
- <Tab.Content>
351
- <Row>
352
- <Col sm={2}>
353
- <Nav variant="pills" className="flex-column">
354
- {features.graphs.undirected.map((g, ndx2) => <Nav.Item key={ndx2}>
355
- <Nav.Link eventKey={`networks-undirected-${ndx2}`}>
356
- {g.name}
357
- </Nav.Link>
358
- </Nav.Item>
359
- )}
360
- </Nav>
361
- </Col>
362
- <Col sm={6}>
363
- <Tab.Content>
364
-
365
- {
366
- features.graphs.undirected[0] && <>
367
- <Sigma graph={graphToIGraphData(features.graphs.undirected[0].graph)} settings={{ drawEdges: true, clone: false }}>
368
- <RelativeSize initialSize={25} />
369
- <RandomizeNodePositions />
370
- </Sigma>
371
- <pre>{JSON.stringify(features.graphs.undirected[0].graph, null, 2)}</pre>
372
- </>
373
- }
374
-
375
-
376
-
377
-
378
- </Tab.Content>
379
- </Col>
380
- <Col sm={4}>
381
- < Tabs defaultActiveKey="networks.features" >
382
- <Tab eventKey="networks.features" title="features">
383
- <pre id="theProps">{JSON.stringify(features, null, 2)}</pre>
384
- </Tab>
385
-
386
- <Tab eventKey="feature.tests" title="tests">
387
- <pre id="theProps">{JSON.stringify(tests.tests, null, 2)}</pre>
388
- </Tab>
389
- </Tabs>
390
- </Col>
391
- </Row>
392
- </Tab.Content>
393
- </Tab>
394
-
395
- </Tabs>
396
-
397
-
398
- </Row>
399
- </Tab.Container>
400
- </Tab>
401
-
402
- <Tab eventKey="tests" title="tests">
403
- <Tab.Container id="left-tabs-example5" defaultActiveKey="feature-0">
404
- <Row>
405
- <Col sm={4}>
406
- {/* <Tree tests={features.tests} /> */}
407
- <Nav variant="pills" className="flex-column">
408
- {
409
- tests.tests.map((t, ndx) =>
410
- <Nav.Item key={ndx}>
411
- <Nav.Link eventKey={`test-${ndx}`}>
412
- {t[0]} - {t[1]}
413
- </Nav.Link>
414
- </Nav.Item>
415
- )
416
- }
417
- </Nav>
418
- </Col>
419
- <Col sm={4}>
420
- <Tab.Content>
421
-
422
- {
423
- tests.tests.map((t, ndx) =>
424
- <Tab.Pane eventKey={`test-${ndx}`}>
425
- {/* <pre>{JSON.stringify(t, null, 2)}</pre> */}
426
- {/* <pre>{JSON.stringify(state.results, null, 2)}</pre> */}
427
- <pre>{JSON.stringify(Object.entries(state.results).filter(([k, v]: [string, { src: string }]) => {
428
- console.log(v.src, tests.tests[ndx][0])
429
- return v.src === tests.tests[ndx][0]
430
- }), null, 2)}</pre>
431
-
432
- {/* {tests.tests.map((t, ndx) => {
433
- return (
434
- <Tab.Pane eventKey={`feature-${ndx}`} key={ndx}>
435
- <pre>{JSON.stringify(t, null, 2)}</pre>
436
- </Tab.Pane>
437
- )
438
- }
439
- )} */}
440
-
441
- </Tab.Pane>
442
-
443
- )
444
- }
445
-
446
-
447
-
448
-
449
- </Tab.Content>
450
- </Col>
451
-
452
- <Col sm={4}>
453
- < Tabs defaultActiveKey="feature.networks" >
454
- <Tab eventKey="feature.networks" title="networks">
455
- < Tabs defaultActiveKey="dag" >
456
-
457
- <Tab eventKey="dag" title="DAG">
458
- <Tab.Content>
459
- <pre>{JSON.stringify(features.graphs.dags, null, 2)}</pre>
460
- </Tab.Content>
461
- </Tab>
462
-
463
- <Tab eventKey="directed" title="Directed">
464
- <Tab.Content>
465
- <pre>{JSON.stringify(features.graphs.directed, null, 2)}</pre>
466
- </Tab.Content>
467
- </Tab>
468
-
469
- <Tab eventKey="undirected" title="Undirected">
470
- <Tab.Content>
471
- <pre>{JSON.stringify(features.graphs.undirected, null, 2)}</pre>
472
- </Tab.Content>
473
- </Tab>
474
-
475
- </Tabs>
476
- </Tab>
477
-
478
- <Tab eventKey="tests.features" title="features">
479
- <pre id="theProps">{JSON.stringify(features, null, 2)}</pre>
480
- </Tab>
481
- </Tabs>
482
- </Col>
483
-
484
- </Row>
485
- </Tab.Container>
486
- </Tab>
487
-
488
- <Tab eventKey="examples" title="examples">
489
- <ExampleTab />
490
- </Tab>
491
-
492
- </Tabs >}
493
-
494
- <footer>made with ❤️ and <a href="https://adamwong246.github.io/testeranto/" >testeranto </a></footer>
495
-
496
- </div >
497
- );
498
- };