importmap_mocha-rails 0.3.5 → 0.3.6
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.
- checksums.yaml +4 -4
- data/README.md +41 -0
- data/app/assets/javascripts/importmap_mocha.js +36 -0
- data/app/views/importmap_mocha/test/index.html.erb +6 -4
- data/lib/importmap_mocha/version.rb +1 -1
- data/vendor/javascripts/@mswjs--interceptors--presets--browser.js +100 -34
- data/vendor/javascripts/@mswjs--interceptors.js +78 -13
- data/vendor/javascripts/mocha.js +61 -16
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c9335fe6db50bcd36e033af9889ada87d1c4fd773883fe80f97bf1f316972b5
|
4
|
+
data.tar.gz: fdfd7acf390b829a4ff8abcc6e9ffdd0149bcb6e882feff0767ffb4fc07fcb1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d953534e4fa286fbb50030df6ac659b352d84db42d6530c88222240a028bf85447591776f93d0c66c65d10e97017b2eec5ec7511da419d939e1394134492f75a
|
7
|
+
data.tar.gz: 30b9619663f685a3f748e617db1d85be6dd10950767fe153172534a11778790d7d2c050455674cc15272a89b7f5159c2a878ccc3479039908d136b43aa079188
|
data/README.md
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
This plugin makes it easy to test ES modules with [importmap-rails](https://github.com/rails/importmap-rails) when using Rails 7 or later.
|
4
4
|
It integrates the [Mocha](https://mochajs.org/) JavaScript testing library (using [Chai](https://www.chaijs.com/) as the assertion library, [@mswjs/interceptors](https://github.com/mswjs/interceptors) as the mocking library) and runs tests for ES modules delivered with importmap in the browser.
|
5
5
|
|
6
|
+
| Library | Version |
|
7
|
+
|-------------------------------------------|---------|
|
8
|
+
| [Mocha](https://mochajs.org/) | 11.1.0 |
|
9
|
+
| [Chai](https://www.chaijs.com/) | 5.1.2 |
|
10
|
+
| [@mswjs/interceptors](https://github.com/mswjs/interceptors) | 0.37.5 |
|
11
|
+
|
12
|
+
[More useful in combination with the rails_live_reload gem](#use-with-rails_live_reload-gem)
|
13
|
+
|
6
14
|
# Installation
|
7
15
|
|
8
16
|
Assuming you have already installed importmap-rails with Rails 7, add the following to your Gemfile and run `bundle install`.
|
@@ -85,6 +93,39 @@ describe('clear controller', () => {
|
|
85
93
|
* config.importmap_mocha_path: The location where the test code is stored. Default is `test/javascripts` and `spec/javascripts`.
|
86
94
|
* config.importmap_mocha_scripts: The scripts to be loaded globally. e.g. `['jquery.js']`.
|
87
95
|
|
96
|
+
# Use with Rails_Live_Reload gem
|
97
|
+
|
98
|
+
It is strongly recommended to use with [rails_live_reload](https://github.com/railsjazz/rails_live_reload)
|
99
|
+
|
100
|
+

|
101
|
+
|
102
|
+
Add this line to your application's Gemfile:
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
group :development do
|
106
|
+
gem "importmap_mocha_rails"
|
107
|
+
gem "rails_live_reload"
|
108
|
+
end
|
109
|
+
```
|
110
|
+
|
111
|
+
And then execute:
|
112
|
+
|
113
|
+
```
|
114
|
+
bundle install
|
115
|
+
rails generate rails_live_reload:install
|
116
|
+
```
|
117
|
+
|
118
|
+
Edit initializer
|
119
|
+
```ruby
|
120
|
+
# frozen_string_literal: true
|
121
|
+
|
122
|
+
RailsLiveReload.configure do |config|
|
123
|
+
config.watch %r{app/views/.+\.(erb|haml|slim)$}
|
124
|
+
# Monitor JavaScript tests in addition to default paths
|
125
|
+
config.watch %r{(app|vendor|test)/(assets|javascript|javascripts)/\w+/(.+\.(css|js|html|png|jpg|ts|jsx)).*}, reload: :always
|
126
|
+
end if defined?(RailsLiveReload)
|
127
|
+
```
|
128
|
+
|
88
129
|
# Author
|
89
130
|
|
90
131
|
Takashi Kato tohosaku@users.osdn.me
|
@@ -0,0 +1,36 @@
|
|
1
|
+
export function changeFavicon(failures) {
|
2
|
+
const links = document.getElementsByTagName('link')
|
3
|
+
|
4
|
+
for (let i=0; i<links.length; i++) {
|
5
|
+
let link = links[i];
|
6
|
+
if (link.rel == 'icon') {
|
7
|
+
const icon = failures > 0 ? favicon('red')
|
8
|
+
: favicon('green')
|
9
|
+
link.remove()
|
10
|
+
const newlink = document.createElement("link");
|
11
|
+
newlink.rel = 'icon';
|
12
|
+
newlink.href = icon;
|
13
|
+
newlink.type = 'image/svg+xml';
|
14
|
+
const head = document.getElementsByTagName("head")[0];
|
15
|
+
head.appendChild(newlink);
|
16
|
+
|
17
|
+
return;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
function favicon(color, count) {
|
23
|
+
const icon = `<?xml version="1.0" encoding="UTF-8"?>
|
24
|
+
<svg width="100" height="100" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
25
|
+
<style>circle {
|
26
|
+
fill: ${color};
|
27
|
+
stroke: ${color};
|
28
|
+
stroke-width: 3px;
|
29
|
+
}
|
30
|
+
</style>
|
31
|
+
<circle cx="50" cy="50" r="47"/>
|
32
|
+
</svg>`
|
33
|
+
const base64Svg = btoa(unescape(encodeURIComponent(icon)));
|
34
|
+
|
35
|
+
return `data:image/svg+xml;base64,${base64Svg}`;
|
36
|
+
}
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<% if Rails.application.config.importmap_mocha_scripts.size > 0 %>
|
7
7
|
<%= javascript_include_tag *Rails.application.config.importmap_mocha_scripts %>
|
8
8
|
<% end %>
|
9
|
-
|
9
|
+
<link rel="icon" href="data:image/png;base64,iVBORw0KGgo=">
|
10
10
|
<%= javascript_include_tag 'mocha' %>
|
11
11
|
<%= stylesheet_link_tag 'mocha' %>
|
12
12
|
<%= javascript_importmap_tags 'importmap_mocha' %>
|
@@ -25,8 +25,10 @@
|
|
25
25
|
</div>
|
26
26
|
</div>
|
27
27
|
</div>
|
28
|
-
<script type="module">
|
29
|
-
|
30
|
-
|
28
|
+
<script type="module">
|
29
|
+
import { changeFavicon } from 'importmap_mocha'
|
30
|
+
|
31
|
+
mocha.run(changeFavicon)
|
32
|
+
</script>
|
31
33
|
</body>
|
32
34
|
</html>
|
@@ -837,23 +837,6 @@ function isPropertyAccessible(obj, key) {
|
|
837
837
|
}
|
838
838
|
|
839
839
|
// src/utils/responseUtils.ts
|
840
|
-
var RESPONSE_STATUS_CODES_WITHOUT_BODY = /* @__PURE__ */ new Set([
|
841
|
-
101,
|
842
|
-
103,
|
843
|
-
204,
|
844
|
-
205,
|
845
|
-
304
|
846
|
-
]);
|
847
|
-
var RESPONSE_STATUS_CODES_WITH_REDIRECT = /* @__PURE__ */ new Set([
|
848
|
-
301,
|
849
|
-
302,
|
850
|
-
303,
|
851
|
-
307,
|
852
|
-
308
|
853
|
-
]);
|
854
|
-
function isResponseWithoutBody(status) {
|
855
|
-
return RESPONSE_STATUS_CODES_WITHOUT_BODY.has(status);
|
856
|
-
}
|
857
840
|
function createServerErrorResponse(body) {
|
858
841
|
return new Response(
|
859
842
|
JSON.stringify(
|
@@ -922,13 +905,17 @@ async function handleRequest(options) {
|
|
922
905
|
});
|
923
906
|
const requestAbortPromise = new DeferredPromise();
|
924
907
|
if (options.request.signal) {
|
925
|
-
options.request.signal.
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
908
|
+
if (options.request.signal.aborted) {
|
909
|
+
requestAbortPromise.reject(options.request.signal.reason);
|
910
|
+
} else {
|
911
|
+
options.request.signal.addEventListener(
|
912
|
+
"abort",
|
913
|
+
() => {
|
914
|
+
requestAbortPromise.reject(options.request.signal.reason);
|
915
|
+
},
|
916
|
+
{ once: true }
|
917
|
+
);
|
918
|
+
}
|
932
919
|
}
|
933
920
|
const result = await until(async () => {
|
934
921
|
const requestListtenersPromise = emitAsync(options.emitter, "request", {
|
@@ -1147,6 +1134,12 @@ function hasConfigurableGlobal(propertyName) {
|
|
1147
1134
|
if (typeof descriptor === "undefined") {
|
1148
1135
|
return false;
|
1149
1136
|
}
|
1137
|
+
if (typeof descriptor.get === "function" && typeof descriptor.get() === "undefined") {
|
1138
|
+
return false;
|
1139
|
+
}
|
1140
|
+
if (typeof descriptor.get === "undefined" && descriptor.value == null) {
|
1141
|
+
return false;
|
1142
|
+
}
|
1150
1143
|
if (typeof descriptor.set === "undefined" && !descriptor.configurable) {
|
1151
1144
|
console.error(
|
1152
1145
|
`[MSW] Failed to apply interceptor: the global \`${propertyName}\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`
|
@@ -1156,6 +1149,83 @@ function hasConfigurableGlobal(propertyName) {
|
|
1156
1149
|
return true;
|
1157
1150
|
}
|
1158
1151
|
|
1152
|
+
// src/utils/fetchUtils.ts
|
1153
|
+
var FetchResponse = class _FetchResponse extends Response {
|
1154
|
+
static {
|
1155
|
+
/**
|
1156
|
+
* Response status codes for responses that cannot have body.
|
1157
|
+
* @see https://fetch.spec.whatwg.org/#statuses
|
1158
|
+
*/
|
1159
|
+
this.STATUS_CODES_WITHOUT_BODY = [101, 103, 204, 205, 304];
|
1160
|
+
}
|
1161
|
+
static {
|
1162
|
+
this.STATUS_CODES_WITH_REDIRECT = [301, 302, 303, 307, 308];
|
1163
|
+
}
|
1164
|
+
static isConfigurableStatusCode(status) {
|
1165
|
+
return status >= 200 && status <= 599;
|
1166
|
+
}
|
1167
|
+
static isRedirectResponse(status) {
|
1168
|
+
return _FetchResponse.STATUS_CODES_WITH_REDIRECT.includes(status);
|
1169
|
+
}
|
1170
|
+
/**
|
1171
|
+
* Returns a boolean indicating whether the given response status
|
1172
|
+
* code represents a response that can have a body.
|
1173
|
+
*/
|
1174
|
+
static isResponseWithBody(status) {
|
1175
|
+
return !_FetchResponse.STATUS_CODES_WITHOUT_BODY.includes(status);
|
1176
|
+
}
|
1177
|
+
static setUrl(url, response) {
|
1178
|
+
if (!url) {
|
1179
|
+
return;
|
1180
|
+
}
|
1181
|
+
if (response.url != "") {
|
1182
|
+
return;
|
1183
|
+
}
|
1184
|
+
Object.defineProperty(response, "url", {
|
1185
|
+
value: url,
|
1186
|
+
enumerable: true,
|
1187
|
+
configurable: true,
|
1188
|
+
writable: false
|
1189
|
+
});
|
1190
|
+
}
|
1191
|
+
/**
|
1192
|
+
* Parses the given raw HTTP headers into a Fetch API `Headers` instance.
|
1193
|
+
*/
|
1194
|
+
static parseRawHeaders(rawHeaders) {
|
1195
|
+
const headers = new Headers();
|
1196
|
+
for (let line = 0; line < rawHeaders.length; line += 2) {
|
1197
|
+
headers.append(rawHeaders[line], rawHeaders[line + 1]);
|
1198
|
+
}
|
1199
|
+
return headers;
|
1200
|
+
}
|
1201
|
+
constructor(body, init = {}) {
|
1202
|
+
const status = init.status ?? 200;
|
1203
|
+
const safeStatus = _FetchResponse.isConfigurableStatusCode(status) ? status : 200;
|
1204
|
+
const finalBody = _FetchResponse.isResponseWithBody(status) ? body : null;
|
1205
|
+
super(finalBody, {
|
1206
|
+
...init,
|
1207
|
+
status: safeStatus
|
1208
|
+
});
|
1209
|
+
if (status !== safeStatus) {
|
1210
|
+
const stateSymbol = Object.getOwnPropertySymbols(this).find(
|
1211
|
+
(symbol) => symbol.description === "state"
|
1212
|
+
);
|
1213
|
+
if (stateSymbol) {
|
1214
|
+
const state = Reflect.get(this, stateSymbol);
|
1215
|
+
Reflect.set(state, "status", status);
|
1216
|
+
} else {
|
1217
|
+
Object.defineProperty(this, "status", {
|
1218
|
+
value: status,
|
1219
|
+
enumerable: true,
|
1220
|
+
configurable: true,
|
1221
|
+
writable: false
|
1222
|
+
});
|
1223
|
+
}
|
1224
|
+
}
|
1225
|
+
_FetchResponse.setUrl(init.url, this);
|
1226
|
+
}
|
1227
|
+
};
|
1228
|
+
|
1159
1229
|
// src/interceptors/fetch/index.ts
|
1160
1230
|
var FetchInterceptor = class _FetchInterceptor extends Interceptor {
|
1161
1231
|
static {
|
@@ -1195,8 +1265,9 @@ var FetchInterceptor = class _FetchInterceptor extends Interceptor {
|
|
1195
1265
|
rawResponse
|
1196
1266
|
});
|
1197
1267
|
const decompressedStream = decompressResponse(rawResponse);
|
1198
|
-
const response = decompressedStream === null ? rawResponse : new
|
1199
|
-
|
1268
|
+
const response = decompressedStream === null ? rawResponse : new FetchResponse(decompressedStream, rawResponse);
|
1269
|
+
FetchResponse.setUrl(request.url, response);
|
1270
|
+
if (FetchResponse.isRedirectResponse(response.status)) {
|
1200
1271
|
if (request.redirect === "error") {
|
1201
1272
|
responsePromise.reject(createNetworkError("unexpected redirect"));
|
1202
1273
|
return;
|
@@ -1213,12 +1284,6 @@ var FetchInterceptor = class _FetchInterceptor extends Interceptor {
|
|
1213
1284
|
return;
|
1214
1285
|
}
|
1215
1286
|
}
|
1216
|
-
Object.defineProperty(response, "url", {
|
1217
|
-
writable: false,
|
1218
|
-
enumerable: true,
|
1219
|
-
configurable: false,
|
1220
|
-
value: request.url
|
1221
|
-
});
|
1222
1287
|
if (this.emitter.listenerCount("response") > 0) {
|
1223
1288
|
this.logger.info('emitting the "response" event...');
|
1224
1289
|
await emitAsync(this.emitter, "response", {
|
@@ -1477,8 +1542,9 @@ function parseJson(data) {
|
|
1477
1542
|
|
1478
1543
|
// src/interceptors/XMLHttpRequest/utils/createResponse.ts
|
1479
1544
|
function createResponse(request, body) {
|
1480
|
-
const responseBodyOrNull =
|
1481
|
-
return new
|
1545
|
+
const responseBodyOrNull = FetchResponse.isResponseWithBody(request.status) ? body : null;
|
1546
|
+
return new FetchResponse(responseBodyOrNull, {
|
1547
|
+
url: request.responseURL,
|
1482
1548
|
status: request.status,
|
1483
1549
|
statusText: request.statusText,
|
1484
1550
|
headers: createHeadersFromXMLHttpReqestHeaders(
|
@@ -752,19 +752,85 @@ function decodeBuffer(buffer, encoding) {
|
|
752
752
|
return decoder.decode(buffer);
|
753
753
|
}
|
754
754
|
|
755
|
-
// src/utils/
|
756
|
-
var
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
]
|
763
|
-
|
764
|
-
|
765
|
-
|
755
|
+
// src/utils/fetchUtils.ts
|
756
|
+
var FetchResponse = class _FetchResponse extends Response {
|
757
|
+
static {
|
758
|
+
/**
|
759
|
+
* Response status codes for responses that cannot have body.
|
760
|
+
* @see https://fetch.spec.whatwg.org/#statuses
|
761
|
+
*/
|
762
|
+
this.STATUS_CODES_WITHOUT_BODY = [101, 103, 204, 205, 304];
|
763
|
+
}
|
764
|
+
static {
|
765
|
+
this.STATUS_CODES_WITH_REDIRECT = [301, 302, 303, 307, 308];
|
766
|
+
}
|
767
|
+
static isConfigurableStatusCode(status) {
|
768
|
+
return status >= 200 && status <= 599;
|
769
|
+
}
|
770
|
+
static isRedirectResponse(status) {
|
771
|
+
return _FetchResponse.STATUS_CODES_WITH_REDIRECT.includes(status);
|
772
|
+
}
|
773
|
+
/**
|
774
|
+
* Returns a boolean indicating whether the given response status
|
775
|
+
* code represents a response that can have a body.
|
776
|
+
*/
|
777
|
+
static isResponseWithBody(status) {
|
778
|
+
return !_FetchResponse.STATUS_CODES_WITHOUT_BODY.includes(status);
|
779
|
+
}
|
780
|
+
static setUrl(url, response) {
|
781
|
+
if (!url) {
|
782
|
+
return;
|
783
|
+
}
|
784
|
+
if (response.url != "") {
|
785
|
+
return;
|
786
|
+
}
|
787
|
+
Object.defineProperty(response, "url", {
|
788
|
+
value: url,
|
789
|
+
enumerable: true,
|
790
|
+
configurable: true,
|
791
|
+
writable: false
|
792
|
+
});
|
793
|
+
}
|
794
|
+
/**
|
795
|
+
* Parses the given raw HTTP headers into a Fetch API `Headers` instance.
|
796
|
+
*/
|
797
|
+
static parseRawHeaders(rawHeaders) {
|
798
|
+
const headers = new Headers();
|
799
|
+
for (let line = 0; line < rawHeaders.length; line += 2) {
|
800
|
+
headers.append(rawHeaders[line], rawHeaders[line + 1]);
|
801
|
+
}
|
802
|
+
return headers;
|
803
|
+
}
|
804
|
+
constructor(body, init = {}) {
|
805
|
+
const status = init.status ?? 200;
|
806
|
+
const safeStatus = _FetchResponse.isConfigurableStatusCode(status) ? status : 200;
|
807
|
+
const finalBody = _FetchResponse.isResponseWithBody(status) ? body : null;
|
808
|
+
super(finalBody, {
|
809
|
+
...init,
|
810
|
+
status: safeStatus
|
811
|
+
});
|
812
|
+
if (status !== safeStatus) {
|
813
|
+
const stateSymbol = Object.getOwnPropertySymbols(this).find(
|
814
|
+
(symbol) => symbol.description === "state"
|
815
|
+
);
|
816
|
+
if (stateSymbol) {
|
817
|
+
const state = Reflect.get(this, stateSymbol);
|
818
|
+
Reflect.set(state, "status", status);
|
819
|
+
} else {
|
820
|
+
Object.defineProperty(this, "status", {
|
821
|
+
value: status,
|
822
|
+
enumerable: true,
|
823
|
+
configurable: true,
|
824
|
+
writable: false
|
825
|
+
});
|
826
|
+
}
|
827
|
+
}
|
828
|
+
_FetchResponse.setUrl(init.url, this);
|
829
|
+
}
|
830
|
+
};
|
766
831
|
export {
|
767
832
|
BatchInterceptor,
|
833
|
+
FetchResponse,
|
768
834
|
INTERNAL_REQUEST_ID_HEADER_NAME,
|
769
835
|
IS_PATCHED_MODULE,
|
770
836
|
Interceptor,
|
@@ -774,6 +840,5 @@ export {
|
|
774
840
|
deleteGlobalSymbol,
|
775
841
|
encodeBuffer,
|
776
842
|
getCleanUrl,
|
777
|
-
getGlobalSymbol
|
778
|
-
isResponseWithoutBody
|
843
|
+
getGlobalSymbol
|
779
844
|
};
|
data/vendor/javascripts/mocha.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// mocha@
|
1
|
+
// mocha@11.1.0 in javascript ES2018
|
2
2
|
(function (global, factory) {
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
4
4
|
typeof define === 'function' && define.amd ? define(factory) :
|
@@ -11652,6 +11652,13 @@
|
|
11652
11652
|
|
11653
11653
|
return _breakCircularDeps(inputObj);
|
11654
11654
|
};
|
11655
|
+
|
11656
|
+
/**
|
11657
|
+
* Checks if provided input can be parsed as a JavaScript Number.
|
11658
|
+
*/
|
11659
|
+
exports.isNumeric = input => {
|
11660
|
+
return !isNaN(parseFloat(input));
|
11661
|
+
};
|
11655
11662
|
}(utils$3));
|
11656
11663
|
|
11657
11664
|
var _nodeResolve_empty = {};
|
@@ -13771,7 +13778,7 @@
|
|
13771
13778
|
var hook = this._createHook(title, fn);
|
13772
13779
|
this._beforeAll.push(hook);
|
13773
13780
|
this.emit(constants.EVENT_SUITE_ADD_HOOK_BEFORE_ALL, hook);
|
13774
|
-
return
|
13781
|
+
return hook;
|
13775
13782
|
};
|
13776
13783
|
|
13777
13784
|
/**
|
@@ -13795,7 +13802,7 @@
|
|
13795
13802
|
var hook = this._createHook(title, fn);
|
13796
13803
|
this._afterAll.push(hook);
|
13797
13804
|
this.emit(constants.EVENT_SUITE_ADD_HOOK_AFTER_ALL, hook);
|
13798
|
-
return
|
13805
|
+
return hook;
|
13799
13806
|
};
|
13800
13807
|
|
13801
13808
|
/**
|
@@ -13819,7 +13826,7 @@
|
|
13819
13826
|
var hook = this._createHook(title, fn);
|
13820
13827
|
this._beforeEach.push(hook);
|
13821
13828
|
this.emit(constants.EVENT_SUITE_ADD_HOOK_BEFORE_EACH, hook);
|
13822
|
-
return
|
13829
|
+
return hook;
|
13823
13830
|
};
|
13824
13831
|
|
13825
13832
|
/**
|
@@ -13843,7 +13850,7 @@
|
|
13843
13850
|
var hook = this._createHook(title, fn);
|
13844
13851
|
this._afterEach.push(hook);
|
13845
13852
|
this.emit(constants.EVENT_SUITE_ADD_HOOK_AFTER_EACH, hook);
|
13846
|
-
return
|
13853
|
+
return hook;
|
13847
13854
|
};
|
13848
13855
|
|
13849
13856
|
/**
|
@@ -15296,11 +15303,11 @@
|
|
15296
15303
|
* @public
|
15297
15304
|
* @example
|
15298
15305
|
* // this reporter needs proper object references when run in parallel mode
|
15299
|
-
* class MyReporter
|
15306
|
+
* class MyReporter {
|
15300
15307
|
* constructor(runner) {
|
15301
|
-
*
|
15308
|
+
* runner.linkPartialObjects(true)
|
15302
15309
|
* .on(EVENT_SUITE_BEGIN, suite => {
|
15303
|
-
|
15310
|
+
* // this Suite may be the same object...
|
15304
15311
|
* })
|
15305
15312
|
* .on(EVENT_TEST_BEGIN, test => {
|
15306
15313
|
* // ...as the `test.parent` property
|
@@ -18593,7 +18600,7 @@
|
|
18593
18600
|
* @param {Function} fn
|
18594
18601
|
*/
|
18595
18602
|
before: function (name, fn) {
|
18596
|
-
suites[0].beforeAll(name, fn);
|
18603
|
+
return suites[0].beforeAll(name, fn);
|
18597
18604
|
},
|
18598
18605
|
|
18599
18606
|
/**
|
@@ -18603,7 +18610,7 @@
|
|
18603
18610
|
* @param {Function} fn
|
18604
18611
|
*/
|
18605
18612
|
after: function (name, fn) {
|
18606
|
-
suites[0].afterAll(name, fn);
|
18613
|
+
return suites[0].afterAll(name, fn);
|
18607
18614
|
},
|
18608
18615
|
|
18609
18616
|
/**
|
@@ -18613,7 +18620,7 @@
|
|
18613
18620
|
* @param {Function} fn
|
18614
18621
|
*/
|
18615
18622
|
beforeEach: function (name, fn) {
|
18616
|
-
suites[0].beforeEach(name, fn);
|
18623
|
+
return suites[0].beforeEach(name, fn);
|
18617
18624
|
},
|
18618
18625
|
|
18619
18626
|
/**
|
@@ -18623,7 +18630,7 @@
|
|
18623
18630
|
* @param {Function} fn
|
18624
18631
|
*/
|
18625
18632
|
afterEach: function (name, fn) {
|
18626
|
-
suites[0].afterEach(name, fn);
|
18633
|
+
return suites[0].afterEach(name, fn);
|
18627
18634
|
},
|
18628
18635
|
|
18629
18636
|
suite: {
|
@@ -19201,7 +19208,7 @@
|
|
19201
19208
|
};
|
19202
19209
|
|
19203
19210
|
var name = "mocha";
|
19204
|
-
var version = "
|
19211
|
+
var version = "11.1.0";
|
19205
19212
|
var homepage = "https://mochajs.org/";
|
19206
19213
|
var notifyLogo = "https://ibin.co/4QuRuGjXvl36.png";
|
19207
19214
|
var require$$17 = {
|
@@ -19407,7 +19414,9 @@
|
|
19407
19414
|
.ui(options.ui)
|
19408
19415
|
.reporter(
|
19409
19416
|
options.reporter,
|
19410
|
-
options
|
19417
|
+
options['reporter-option'] ||
|
19418
|
+
options.reporterOption ||
|
19419
|
+
options.reporterOptions // for backwards compatibility
|
19411
19420
|
)
|
19412
19421
|
.slow(options.slow)
|
19413
19422
|
.global(options.global);
|
@@ -20548,6 +20557,42 @@
|
|
20548
20557
|
/* eslint no-unused-vars: off */
|
20549
20558
|
/* eslint-env commonjs */
|
20550
20559
|
|
20560
|
+
// https://qiita.com/yamadashy/items/86702dfb3c572b4c5514
|
20561
|
+
const setZeroTimeout = (function(global) {
|
20562
|
+
const timeouts = [];
|
20563
|
+
const messageName = "zero-timeout-message";
|
20564
|
+
|
20565
|
+
if (typeof global === 'undefined') return;
|
20566
|
+
|
20567
|
+
function handleMessage(event) {
|
20568
|
+
if (event.source == global && event.data == messageName) {
|
20569
|
+
if (event.stopPropagation) {
|
20570
|
+
event.stopPropagation();
|
20571
|
+
}
|
20572
|
+
if (timeouts.length) {
|
20573
|
+
timeouts.shift()();
|
20574
|
+
}
|
20575
|
+
}
|
20576
|
+
}
|
20577
|
+
|
20578
|
+
if (global.postMessage) {
|
20579
|
+
if (global.addEventListener) {
|
20580
|
+
global.addEventListener("message", handleMessage, true);
|
20581
|
+
} else if (global.attachEvent) {
|
20582
|
+
global.attachEvent("onmessage", handleMessage);
|
20583
|
+
}
|
20584
|
+
|
20585
|
+
return function (fn) {
|
20586
|
+
timeouts.push(fn);
|
20587
|
+
global.postMessage(messageName, "*");
|
20588
|
+
}
|
20589
|
+
} else {
|
20590
|
+
return function () {
|
20591
|
+
setTimeout$1(fn, 0);
|
20592
|
+
}
|
20593
|
+
}
|
20594
|
+
}(window));
|
20595
|
+
|
20551
20596
|
/**
|
20552
20597
|
* Shim process.stdout.
|
20553
20598
|
*/
|
@@ -20645,7 +20690,7 @@
|
|
20645
20690
|
immediateQueue.shift()();
|
20646
20691
|
}
|
20647
20692
|
if (immediateQueue.length) {
|
20648
|
-
immediateTimeout =
|
20693
|
+
immediateTimeout = setZeroTimeout(timeslice);
|
20649
20694
|
} else {
|
20650
20695
|
immediateTimeout = null;
|
20651
20696
|
}
|
@@ -20658,7 +20703,7 @@
|
|
20658
20703
|
Mocha.Runner.immediately = function (callback) {
|
20659
20704
|
immediateQueue.push(callback);
|
20660
20705
|
if (!immediateTimeout) {
|
20661
|
-
immediateTimeout =
|
20706
|
+
immediateTimeout = setZeroTimeout(timeslice);
|
20662
20707
|
}
|
20663
20708
|
};
|
20664
20709
|
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: importmap_mocha-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: importmap-rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 2.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.0.0
|
27
27
|
description: Add JavaScript testing tools in importmap-rails environment.
|