@japa/runner 3.0.0-9 → 3.0.1

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.
@@ -1 +0,0 @@
1
- export {};
@@ -1,31 +0,0 @@
1
- /*
2
- * @japa/runner
3
- *
4
- * (c) Japa
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import { assert } from 'chai';
10
- import { test } from 'node:test';
11
- import { Emitter, Refiner, Test, TestContext } from '../modules/core/main.js';
12
- import { wrapAssertions } from '../tests_helpers/main.js';
13
- test.describe('Core', () => {
14
- test('define test cleanup callback using the test context', async () => {
15
- let stack = [];
16
- const context = (t) => new TestContext(t);
17
- const emitter = new Emitter();
18
- const refiner = new Refiner();
19
- const t = new Test('foo', context, emitter, refiner);
20
- t.run(({ cleanup }) => {
21
- cleanup(() => {
22
- stack.push('cleanup');
23
- });
24
- stack.push('executed');
25
- });
26
- await t.exec();
27
- await wrapAssertions(() => {
28
- assert.deepEqual(stack, ['executed', 'cleanup']);
29
- });
30
- });
31
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,153 +0,0 @@
1
- /*
2
- * @japa/runner
3
- *
4
- * (c) Japa
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import { assert } from 'chai';
10
- import { test } from 'node:test';
11
- import { fileURLToPath, pathToFileURL } from 'node:url';
12
- import { FilesManager } from '../src/files_manager.js';
13
- import { wrapAssertions } from '../tests_helpers/main.js';
14
- const FILTERING_DATASET = [
15
- {
16
- files: [
17
- pathToFileURL('tests/unit/create_user.spec.js'),
18
- pathToFileURL('tests/unit/list_user.spec.js'),
19
- pathToFileURL('tests/unit/edit_user.spec.js'),
20
- pathToFileURL('tests/functional/user.spec.js'),
21
- pathToFileURL('tests/functional/register_user.spec.js'),
22
- ],
23
- filters: ['user'],
24
- output: [
25
- pathToFileURL('tests/unit/create_user.spec.js'),
26
- pathToFileURL('tests/unit/list_user.spec.js'),
27
- pathToFileURL('tests/unit/edit_user.spec.js'),
28
- pathToFileURL('tests/functional/user.spec.js'),
29
- pathToFileURL('tests/functional/register_user.spec.js'),
30
- ],
31
- },
32
- {
33
- files: [
34
- pathToFileURL('tests/unit/create_user.spec.js'),
35
- pathToFileURL('tests/unit/list_user.spec.js'),
36
- pathToFileURL('tests/unit/edit_user.spec.js'),
37
- pathToFileURL('tests/functional/user.spec.js'),
38
- pathToFileURL('tests/functional/register_user.spec.js'),
39
- ],
40
- filters: ['unit/user'],
41
- output: [
42
- pathToFileURL('tests/unit/create_user.spec.js'),
43
- pathToFileURL('tests/unit/list_user.spec.js'),
44
- pathToFileURL('tests/unit/edit_user.spec.js'),
45
- ],
46
- },
47
- {
48
- files: [
49
- pathToFileURL('tests/unit/create_user.spec.js'),
50
- pathToFileURL('tests/unit/list_user.spec.js'),
51
- pathToFileURL('tests/unit/edit_user.spec.js'),
52
- pathToFileURL('tests/functional/user.spec.js'),
53
- pathToFileURL('tests/functional/register_user.spec.js'),
54
- ],
55
- filters: ['onal/user'],
56
- output: [
57
- pathToFileURL('tests/functional/user.spec.js'),
58
- pathToFileURL('tests/functional/register_user.spec.js'),
59
- ],
60
- },
61
- {
62
- files: [
63
- pathToFileURL('tests/unit/users/create.spec.js'),
64
- pathToFileURL('tests/unit/users/edit.spec.js'),
65
- pathToFileURL('tests/unit/users/delete.spec.js'),
66
- pathToFileURL('tests/functional/users.spec.js'),
67
- pathToFileURL('tests/functional/register_user.spec.js'),
68
- ],
69
- filters: ['unit/users/*'],
70
- output: [
71
- pathToFileURL('tests/unit/users/create.spec.js'),
72
- pathToFileURL('tests/unit/users/edit.spec.js'),
73
- pathToFileURL('tests/unit/users/delete.spec.js'),
74
- ],
75
- },
76
- {
77
- files: [
78
- pathToFileURL('tests/unit/users/create.spec.js'),
79
- pathToFileURL('tests/unit/users/edit.spec.js'),
80
- pathToFileURL('tests/unit/users/delete.spec.js'),
81
- pathToFileURL('tests/functional/users.spec.js'),
82
- pathToFileURL('tests/functional/register_user.spec.js'),
83
- ],
84
- filters: ['users/create.spec.js'],
85
- output: [pathToFileURL('tests/unit/users/create.spec.js')],
86
- },
87
- ];
88
- test.describe('Files manager | grep', () => {
89
- test('apply filter on the file name', async () => {
90
- for (let { files, filters, output } of FILTERING_DATASET) {
91
- await wrapAssertions(() => {
92
- assert.deepEqual(new FilesManager().grep(files, filters), output);
93
- });
94
- }
95
- });
96
- });
97
- test.describe('Files manager | getFiles', () => {
98
- test('get files for the glob pattern', async () => {
99
- const cwd = new URL('../', import.meta.url);
100
- const files = await new FilesManager().getFiles(fileURLToPath(cwd), ['tests/**/*.spec.ts']);
101
- await wrapAssertions(() => {
102
- assert.deepEqual(files, [
103
- new URL('tests/base_reporter.spec.ts', cwd),
104
- new URL('tests/cli_parser.spec.ts', cwd),
105
- new URL('tests/config_manager.spec.ts', cwd),
106
- new URL('tests/core.spec.ts', cwd),
107
- new URL('tests/files_manager.spec.ts', cwd),
108
- new URL('tests/planner.spec.ts', cwd),
109
- new URL('tests/runner.spec.ts', cwd),
110
- ]);
111
- });
112
- });
113
- test('get files from multiple glob patterns', async () => {
114
- const cwd = new URL('../', import.meta.url);
115
- const files = await new FilesManager().getFiles(fileURLToPath(cwd), [
116
- 'tests/**/*.spec.ts',
117
- 'modules/**/*.ts',
118
- ]);
119
- await wrapAssertions(() => {
120
- assert.deepEqual(files, [
121
- new URL('tests/base_reporter.spec.ts', cwd),
122
- new URL('tests/cli_parser.spec.ts', cwd),
123
- new URL('tests/config_manager.spec.ts', cwd),
124
- new URL('tests/core.spec.ts', cwd),
125
- new URL('tests/files_manager.spec.ts', cwd),
126
- new URL('tests/planner.spec.ts', cwd),
127
- new URL('tests/runner.spec.ts', cwd),
128
- new URL('modules/core/main.ts', cwd),
129
- new URL('modules/core/types.ts', cwd),
130
- new URL('modules/core/reporters/base.ts', cwd),
131
- ]);
132
- });
133
- });
134
- test('get files from a custom implementation', async () => {
135
- const cwd = new URL('../', import.meta.url);
136
- const files = await new FilesManager().getFiles(fileURLToPath(cwd), () => {
137
- return [
138
- new URL('tests/cli_parser.spec.ts', cwd),
139
- new URL('tests/config_manager.spec.ts', cwd),
140
- new URL('tests/files_manager.spec.ts', cwd),
141
- new URL('modules/core/main.ts', cwd),
142
- ];
143
- });
144
- await wrapAssertions(() => {
145
- assert.deepEqual(files, [
146
- new URL('tests/cli_parser.spec.ts', cwd),
147
- new URL('tests/config_manager.spec.ts', cwd),
148
- new URL('tests/files_manager.spec.ts', cwd),
149
- new URL('modules/core/main.ts', cwd),
150
- ]);
151
- });
152
- });
153
- });
@@ -1 +0,0 @@
1
- export {};