repo string | pull_number int64 | instance_id string | issue_numbers list | base_commit string | patch string | test_patch string | problem_statement string | hints_text string | created_at timestamp[ns, tz=UTC] | version float64 |
|---|---|---|---|---|---|---|---|---|---|---|
python-attrs/attrs | 367 | python-attrs__attrs-367 | [
"361"
] | 57817b2c0e9cf98a2d974e8e845e8f6a1a1be89a | diff --git a/src/attr/_make.py b/src/attr/_make.py
--- a/src/attr/_make.py
+++ b/src/attr/_make.py
@@ -23,6 +23,8 @@
_init_converter_pat = "__attr_converter_{}"
_init_factory_pat = "__attr_factory_{}"
_tuple_property_pat = " {attr_name} = property(itemgetter({index}))"
+_classvar_prefixes = ("typing.ClassVar", "t... | diff --git a/tests/test_annotations.py b/tests/test_annotations.py
--- a/tests/test_annotations.py
+++ b/tests/test_annotations.py
@@ -11,6 +11,7 @@
import attr
+from attr._make import _classvar_prefixes
from attr.exceptions import UnannotatedAttributeError
@@ -204,13 +205,14 @@ class A:
assert A.__i... | Support ClassVar string annotations
The following doesn't work in Python 3.7
```
from __future__ import annotations
import attr
from typing import ClassVar
@attr.dataclass
class A:
x: ClassVar[int]
a = A()
```
Because `ClassVar[int]` will be `'ClassVar[int]` in `A.__annotations__` and so `return s... | Oh god more string comparisons. 🙈
This is the last blocker for the next release. Any ideas how to solve this save expanding the comparison to just ClassVar and call it a day?
I believe these are our only viable options:
1. `eval` the first part (up to the first `[`) of every string annotation.
* If it raises, mo... | 2018-04-11T08:32:48Z | 17.4 |
python-attrs/attrs | 394 | python-attrs__attrs-394 | [
"387"
] | 9c414702bd26c2793386250c4442d48864e3e0b9 | diff --git a/src/attr/_make.py b/src/attr/_make.py
--- a/src/attr/_make.py
+++ b/src/attr/_make.py
@@ -671,7 +671,7 @@ def attrs(
:param bool cmp: Create ``__eq__``, ``__ne__``, ``__lt__``, ``__le__``,
``__gt__``, and ``__ge__`` methods that compare the class as if it were
a tuple of its ``attrs`... | diff --git a/tests/test_make.py b/tests/test_make.py
--- a/tests/test_make.py
+++ b/tests/test_make.py
@@ -1249,3 +1249,42 @@ class C(object):
)
assert C() == copy.deepcopy(C())
+
+
+class TestMakeCmp:
+ """
+ Tests for _make_cmp().
+ """
+
+ @pytest.mark.parametrize(
+ "op", ... | attrs._make should document why it is more restrictive with __eq__ than other comparisons
The type check in `__eq__` for generated classes is different than in other comparison methods.
For all other methods, `isinstance(other, self.__class__)` is used, which means subclasses will participate in the "happy" branch o... | Agreed; a reasonable developer would be surprised by the asymmetry described.
(FWIW I am; though I try not to subclass, so hadn't noticed this.)
Well yeah same, I think `attrs` should even have a `attr.s(..., allow_subclassing=True|False)` and default it to false :P, but that's a different story.
Agree on all counts... | 2018-06-16T05:59:11Z | 18.1 |
python-attrs/attrs | 383 | python-attrs__attrs-383 | [
"382"
] | 8274c9fdbc1513c87272340f92cd51dfea27c2ab | diff --git a/src/attr/validators.py b/src/attr/validators.py
--- a/src/attr/validators.py
+++ b/src/attr/validators.py
@@ -135,7 +135,12 @@ class _InValidator(object):
options = attrib()
def __call__(self, inst, attr, value):
- if value not in self.options:
+ try:
+ in_options = val... | diff --git a/tests/test_validators.py b/tests/test_validators.py
--- a/tests/test_validators.py
+++ b/tests/test_validators.py
@@ -243,6 +243,19 @@ def test_fail(self):
"'test' must be in [1, 2, 3] (got None)",
) == e.value.args
+ def test_fail_with_string(self):
+ """
+ Raise V... | Poor error message/type for validators.in_ with a string
```python
import attr
@attr.s
class C:
s = attr.ib(validator=attr.validators.in_('abc'))
C(s=1) # TypeError: 'in <string>' requires string as left operand, not int
```
`__contains__` behaves a little weirdly for strings, but I still think this er... | What is the actual problem here? I don't think it's fair to expect in_ to also type check?
I think you want
```python
s = attr.ib(validator=[attr.validators.instance_of(str), attr.validators.in_('abc')])
```
?
I think the request is for something like:
```python
def __call__(self, inst, attr, value):... | 2018-05-23T13:16:10Z | 18.1 |
python-attrs/attrs | 286 | python-attrs__attrs-286 | [
"284"
] | 7501cecf0f4313c3b2597d03ac0853cca1659065 | diff --git a/src/attr/_compat.py b/src/attr/_compat.py
--- a/src/attr/_compat.py
+++ b/src/attr/_compat.py
@@ -3,6 +3,7 @@
import platform
import sys
import types
+import warnings
PY2 = sys.version_info[0] == 2
@@ -85,11 +86,54 @@ def iteritems(d):
def metadata_proxy(d):
return types.MappingProxyT... | diff --git a/tests/test_slots.py b/tests/test_slots.py
--- a/tests/test_slots.py
+++ b/tests/test_slots.py
@@ -13,7 +13,7 @@
import attr
-from attr._compat import PY2
+from attr._compat import PY2, PYPY, just_warn, make_set_closure_cell
@attr.s
@@ -325,76 +325,98 @@ class C2(C1Bare):
@pytest.mark.skipif(... | Allow using attrs without ctypes
#226 introduced the use of `ctypes`. I use attrs in a Google App Engine application. The app runs in a sandbox which limits the use of certain modules. `ctypes` is one of those libraries.
I can peg my app to use only attrs 17.2.0, but it would be nice to have a fail-gently approach w... | Now, that’s unfortunate! Making the support unconditional is gonna be easy, the big question is how to document/communicate the behavior it to the user. 🤔
Probably log a warning? Hopefully in a way that's visible.
Also, we won't need ctypes in CPython 3.7 right? | 2017-11-09T10:33:37Z | 17.3 |
python-attrs/attrs | 292 | python-attrs__attrs-292 | [
"291"
] | a84a36d45f34a82a1bb3180a33d5842f7718cdef | diff --git a/src/attr/_make.py b/src/attr/_make.py
--- a/src/attr/_make.py
+++ b/src/attr/_make.py
@@ -201,6 +201,22 @@ def _is_class_var(annot):
return str(annot).startswith("typing.ClassVar")
+def _get_annotations(cls):
+ """
+ Get annotations for *cls*.
+ """
+ anns = getattr(cls, "__annotations... | diff --git a/tests/test_annotations.py b/tests/test_annotations.py
--- a/tests/test_annotations.py
+++ b/tests/test_annotations.py
@@ -131,3 +131,26 @@ class C:
assert (
"The following `attr.ib`s lack a type annotation: v, y.",
) == e.value.args
+
+ @pytest.mark.parametrize("slots", [T... | Type hint defaults don't work with inheritance
Consider
```
In [12]: @attr.s(auto_attribs=True)
...: class A:
...: a: int = 10
...:
In [13]: @attr.s(auto_attribs=True)
...: class B(A):
...: pass
...:
In [14]: A()
Out[14]: A(a=10)
In [15]: B()
------------------------... | Ugh so it’s not inheritance, it’s inheritance + no new annotations. The problem is that `__annotations__` gets inherited:
```pycon
>>> import attr
>>> @attr.s(auto_attribs=True)
... class A:
... a: int = 10
>>> @attr.s(auto_attribs=True)
... class B(A):
... pass
>>> A.__annotations__
{'a': <c... | 2017-11-11T07:04:59Z | 17.3 |
python-attrs/attrs | 343 | python-attrs__attrs-343 | [
"300"
] | 93eb1e4d21b5cc5c88da61e8182a42bb41cab557 | diff --git a/src/attr/_compat.py b/src/attr/_compat.py
--- a/src/attr/_compat.py
+++ b/src/attr/_compat.py
@@ -10,6 +10,13 @@
PYPY = platform.python_implementation() == "PyPy"
+if PYPY or sys.version_info[:2] >= (3, 6):
+ ordered_dict = dict
+else:
+ from collections import OrderedDict
+ ordered_dict = Or... | diff --git a/tests/test_make.py b/tests/test_make.py
--- a/tests/test_make.py
+++ b/tests/test_make.py
@@ -19,7 +19,7 @@
import attr
from attr import _config
-from attr._compat import PY2
+from attr._compat import PY2, ordered_dict
from attr._make import (
Attribute, Factory, _AndValidator, _Attributes, _Clas... | Allow overwriting order inferred from _CountingAttr.counter when passing ordered `these`
attrs classes can be constructed dynamically using `attr.s(maybe_cls=A, these=some_dict)`.
Usually `some_dict` will be a standard (unordered) python dictionary and the order of attributes has to be inferred from `_CountingAttr.cou... | I think @Julian would like this?
Yep! Would love to see what this looks like. | 2018-02-05T09:39:46Z | 17.4 |
python-attrs/attrs | 277 | python-attrs__attrs-277 | [
"262"
] | 2a50c4b93002a0f4f4355051759beae5e0324497 | diff --git a/src/attr/__init__.py b/src/attr/__init__.py
--- a/src/attr/__init__.py
+++ b/src/attr/__init__.py
@@ -1,5 +1,7 @@
from __future__ import absolute_import, division, print_function
+from functools import partial
+
from ._funcs import (
asdict,
assoc,
@@ -43,6 +45,7 @@
s = attributes = attrs
... | diff --git a/tests/test_annotations.py b/tests/test_annotations.py
--- a/tests/test_annotations.py
+++ b/tests/test_annotations.py
@@ -4,12 +4,15 @@
Python 3.6+ only.
"""
+import types
import typing
import pytest
import attr
+from attr.exceptions import UnannotatedAttributeError
+
class TestAnnotations:... | Add option to collect annotated fields
Since I’m sick of hearing that “[PEP 557](https://www.python.org/dev/peps/pep-0557/) is like attrs, but using variable annotations for field declarations”, I’d like to have an option to collect annotated fields that have no attr.ib definition.
ie.
```python
@attr.s(collect_... | Hm I'd actually be ok with doing this by default?
A turn off switch would be nice, just default collect_bare to true? Is this a compatibility issue?
I’d love to but that is technically backward incompatible.
Durn it.
We could run it thru a deprecation cycle I guess?
`s/collect_bare/automatic_attributes/`
Maybe just `... | 2017-10-27T08:03:24Z | 17.2 |
python-attrs/attrs | 229 | python-attrs__attrs-229 | [
"221"
] | 37a421e559a6330b7ace242698b06b258b979e91 | diff --git a/src/attr/_make.py b/src/attr/_make.py
--- a/src/attr/_make.py
+++ b/src/attr/_make.py
@@ -181,11 +181,6 @@ def _transform_attrs(cls, these):
If *these* is passed, use that and don't look for them on the class.
"""
- super_cls = []
- for c in reversed(cls.__mro__[1:-1]):
- sub_attrs... | diff --git a/tests/test_dark_magic.py b/tests/test_dark_magic.py
--- a/tests/test_dark_magic.py
+++ b/tests/test_dark_magic.py
@@ -271,3 +271,15 @@ def compute(self):
return self.x + 1
assert C(1, 2) == C()
+
+ @pytest.mark.parametrize("slots", [True, False])
+ @pytest.mark.parametrize... | Can't overide a __super__'s attrib.
Hi.
Is it not possible to do this? Let's say I want to change the default for arg 'p' in the inherited Class, B:
```
@attr.s
class A(object):
p=attr.ib(default='old')
@attr.s
class B(A):
p=attr.ib(default='new')
B().p
```
I get farts:
```
Traceback (mos... | Yes that’s a bug that got mentioned in a different ticket and asked the reporter to file a new bug but he didn’t get around to it so it got lost. | 2017-08-12T07:31:40Z | 17.2 |
python-attrs/attrs | 60 | python-attrs__attrs-60 | [
"3"
] | 5a1814f8d07e00d47d7d81274e4b4ee10dd83d41 | diff --git a/src/attr/__init__.py b/src/attr/__init__.py
--- a/src/attr/__init__.py
+++ b/src/attr/__init__.py
@@ -19,6 +19,7 @@
get_run_validators,
set_run_validators,
)
+from . import exceptions
from . import filters
from . import validators
@@ -49,6 +50,7 @@
"attrib",
"attributes",
"att... | diff --git a/tests/test_dark_magic.py b/tests/test_dark_magic.py
--- a/tests/test_dark_magic.py
+++ b/tests/test_dark_magic.py
@@ -8,6 +8,7 @@
from attr._compat import TYPE
from attr._make import Attribute, NOTHING
+from attr.exceptions import FrozenInstanceError
@attr.s
@@ -62,6 +63,11 @@ class SubSlots(Super... | clean division between "value" and "object"
Objects, as in object-oriented programming, are side-effecty, mutable state, whose methods ought to represent I/O.
Values, as in functional programming, are immutable data, whose methods ought to represent computation.
Python does not have as good a division between these v... | How would that look API-wise? Would something like `@attr.object` or `@attr.value` be presets for `@attr.s`?
I'm not sure. I'm trying to decide what I think the default for `attr.s` is; there's a strong case in my mind for both default-to-mutable or default-to-immutable. `attr.s(mutable=True)`?
The default should ... | 2016-08-16T14:35:17Z | 16 |
python-attrs/attrs | 181 | python-attrs__attrs-181 | [
"165"
] | a328e671690be4e6342d50056d121506b64da9d3 | diff --git a/src/attr/validators.py b/src/attr/validators.py
--- a/src/attr/validators.py
+++ b/src/attr/validators.py
@@ -48,9 +48,9 @@ def instance_of(type):
:param type: The type to check for.
:type type: type or tuple of types
- The :exc:`TypeError` is raised with a human readable error message, the
... | diff --git a/tests/test_validators.py b/tests/test_validators.py
--- a/tests/test_validators.py
+++ b/tests/test_validators.py
@@ -7,7 +7,7 @@
import pytest
import zope.interface
-from attr.validators import and_, instance_of, provides, optional
+from attr.validators import and_, instance_of, provides, optional, in... | attr default based on other attributes
Hi!
I have unsucessfully tried to define a default value by referencing other attributes. I'm sure the code below doesnt' work for some obvious or fundamental reason, but I would be grateful for comments on how to do something like it:
```python
import attr
from attr.valid... | Hi,
for now I suggest using `__attrs_post_init__` (http://attrs.readthedocs.io/en/stable/examples.html?highlight=attrs_post_init#other-goodies). The linked example is basically what you want.
I have wanted to do this several times. For example, you have a test of a function which takes many inputs. You want to test ... | 2017-05-01T17:45:41Z | 16.3 |
python-attrs/attrs | 186 | python-attrs__attrs-186 | [
"161"
] | fdfd51e249f11483a9f731a4f19282df0f97e1e7 | diff --git a/src/attr/_make.py b/src/attr/_make.py
--- a/src/attr/_make.py
+++ b/src/attr/_make.py
@@ -897,7 +897,7 @@ def __init__(self, default, validator, repr, cmp, hash, init, convert,
self.default = default
# If validator is a list/tuple, wrap it using helper validator.
if validator and... | diff --git a/tests/test_make.py b/tests/test_make.py
--- a/tests/test_make.py
+++ b/tests/test_make.py
@@ -21,6 +21,7 @@
_AndValidator,
_CountingAttr,
_transform_attrs,
+ and_,
attr,
attributes,
fields,
@@ -71,6 +72,8 @@ def v2(_, __):
def test_validator_decorator_single(self):
... | validators.optional should take lists like validator=
We’ve added the support for taking a list of validators to validator=, optional() should be able to take lists too otherwise users have to wrap all validators in the list with optional().
| 2017-05-10T09:52:56Z | 16.3 | |
mochajs/mocha | 5,292 | mochajs__mocha-5292 | [
"5289"
] | b1f1cb78b655191b7a43dc962b513bf1b076890c | diff --git a/lib/reporters/xunit.js b/lib/reporters/xunit.js
--- a/lib/reporters/xunit.js
+++ b/lib/reporters/xunit.js
@@ -104,7 +104,7 @@ function XUnit(runner, options) {
);
tests.forEach(function (t) {
- self.test(t);
+ self.test(t, options);
});
self.write('</testsuite>');
@@ -152,... | diff --git a/test/reporters/xunit.spec.js b/test/reporters/xunit.spec.js
--- a/test/reporters/xunit.spec.js
+++ b/test/reporters/xunit.spec.js
@@ -592,4 +592,69 @@ describe('XUnit reporter', function () {
expect(lines[0], 'to contain', defaultSuiteName);
});
});
+
+ describe('showRelativePaths reporter ... | 🚀 Feature: allow using test file's relative path in xunit reporter output
### Feature Request Checklist
- [x] I have read and agree to Mocha's [Code of Conduct](https://github.com/mochajs/mocha/blob/main/.github/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/mochajs/mocha/blob/main/.github/CONTR... | 👍 this strikes me as a very reasonable feature request. Absolute paths in CI output are irksome in a lot of contexts. The irritation of constantly having to remove the absolute prefix is definitely something I resonate with!
Accepting PRs as an opt-in reporter option. Thanks for filing!
Thanks, in the meantime this i... | 2025-02-05T19:45:27Z | 11.1 |
mochajs/mocha | 5,325 | mochajs__mocha-5325 | [
"5310"
] | 1a0caf6b653d39b9fb09cde6ee1e92a075be8f4b | diff --git a/docs-next/public/example/Array.js b/docs-next/public/example/Array.js
new file mode 100644
--- /dev/null
+++ b/docs-next/public/example/Array.js
@@ -0,0 +1,75 @@
+"use strict";
+
+describe('Array', function () {
+ describe('.push()', function () {
+ it('should append a value', function () {
+ var ... | diff --git a/docs-next/public/example/tests.html b/docs-next/public/example/tests.html
new file mode 100644
--- /dev/null
+++ b/docs-next/public/example/tests.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>Mocha</title>
+ <link rel="stylesheet" href="https:... | 📝 Docs: Add an `/example/tests` page to the new website
### Documentation Request Checklist
- [x] I have read and agree to Mocha's [Code of Conduct](https://github.com/mochajs/mocha/blob/main/.github/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/mochajs/mocha/blob/main/.github/CONTRIBUTING.md)
... | 2025-04-08T12:23:43Z | 11.2 | |
mochajs/mocha | 5,165 | mochajs__mocha-5165 | [
"4903"
] | 6caa9026eb120b136dc8210614b31310f8bff83b | diff --git a/lib/cli/cli.js b/lib/cli/cli.js
--- a/lib/cli/cli.js
+++ b/lib/cli/cli.js
@@ -12,7 +12,7 @@
const debug = require('debug')('mocha:cli:cli');
const symbols = require('log-symbols');
-const yargs = require('yargs/yargs');
+const yargs = require('yargs');
const path = require('path');
const {
loadRc,... | diff --git a/test/node-unit/cli/run.spec.js b/test/node-unit/cli/run.spec.js
--- a/test/node-unit/cli/run.spec.js
+++ b/test/node-unit/cli/run.spec.js
@@ -7,7 +7,7 @@ describe('command', function () {
describe('run', function () {
describe('builder', function () {
const IGNORED_OPTIONS = new Set(['help',... | 🔒 Security: Upgrade yargs-parser and yargs to latest stable version
Currently the mocha@10.0.0 version has not upgraded its yarg-parser and yargs which is causing a security vulnerability (NO-CVE: Regular Expression Denial Of Service (ReDoS)) . Please help upgrade both to the most stable version as of current date. T... | Snyk scan is also flagging Mocha ReDos as a High Risk Vulnerability:
https://security.snyk.io/vuln/SNYK-JS-MOCHA-2863123.
This issue hasn't had any recent activity, and I'm labeling it `stale`. Remove the label or comment or this issue will be closed in 14 days. Thanks for contributing to Mocha!
See also #4938 and #48... | 2024-07-02T16:25:28Z | 11 |
mochajs/mocha | 5,231 | mochajs__mocha-5231 | [
"5202"
] | 14e640ee49718d587779a9594b18f3796c42cf2a | diff --git a/lib/interfaces/common.js b/lib/interfaces/common.js
--- a/lib/interfaces/common.js
+++ b/lib/interfaces/common.js
@@ -57,7 +57,7 @@ module.exports = function (suites, context, mocha) {
* @param {Function} fn
*/
before: function (name, fn) {
- suites[0].beforeAll(name, fn);
+ retu... | diff --git a/test/unit/timeout.spec.js b/test/unit/timeout.spec.js
--- a/test/unit/timeout.spec.js
+++ b/test/unit/timeout.spec.js
@@ -70,5 +70,31 @@ describe('timeouts', function () {
});
});
});
+
+ describe('chaining calls', function () {
+ before(function (done) {
+ setTimeout(fu... | 🚀 Feature: Allow to set timeout on before/after/beforeEach/afterEach in declaration
### Feature Request Checklist
- [X] I have read and agree to Mocha's [Code of Conduct](https://github.com/mochajs/mocha/blob/main/.github/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/mochajs/mocha/blob/main/.gi... | 👍 Agreed, I'm surprised they didn't have this already! This took me a bit to parse through as someone who doesn't use those APIs much. Putting a summary here for clarity...
There are two ways to describe a timeout:
* `this.timeout(...);`: allowed for _hooks_ (`before(...)`, etc.) as well as _tests_ (`it(...)`, etc.)... | 2024-10-14T03:36:54Z | 10.8 |
mochajs/mocha | 5,198 | mochajs__mocha-5198 | [
"5141"
] | d5766c887e72b1bb55d5efeac33b1cadd0544b84 | diff --git a/lib/cli/options.js b/lib/cli/options.js
--- a/lib/cli/options.js
+++ b/lib/cli/options.js
@@ -181,8 +181,24 @@ const loadPkgRc = (args = {}) => {
result = {};
const filepath = args.package || findUp.sync(mocharc.package);
if (filepath) {
+ let configData;
try {
- const pkg = JSON.pars... | diff --git a/test/node-unit/cli/options.spec.js b/test/node-unit/cli/options.spec.js
--- a/test/node-unit/cli/options.spec.js
+++ b/test/node-unit/cli/options.spec.js
@@ -149,7 +149,7 @@ describe('options', function () {
loadOptions('--package /something/wherever --require butts');
},
... | 🐛 Bug: mocha fails silently on invalid `package.json` section
### Bug Report Checklist
- [X] I have read and agree to Mocha's [Code of Conduct](https://github.com/mochajs/mocha/blob/master/.github/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/mochajs/mocha/blob/master/.github/CONTRIBUTING.md)
-... | 🤔 I don't reproduce this in https://github.com/mochajs/mocha-examples/tree/4b00891d6c7886f2d451e962a974478e7d3c1aa9/packages/hello-world. After adding an invalid `abc` to the top of its `package.json`:
```plaintext
$ npm run test
npm ERR! code EJSONPARSE
npm ERR! JSON.parse Invalid package.json: JSONParseError: ... | 2024-08-14T17:33:22Z | 10.7 |
mochajs/mocha | 5,032 | mochajs__mocha-5032 | [
"4552",
"4552"
] | 103c56b63542e36ba7a289ec25913d77bf2156b6 | diff --git a/lib/nodejs/serializer.js b/lib/nodejs/serializer.js
--- a/lib/nodejs/serializer.js
+++ b/lib/nodejs/serializer.js
@@ -6,7 +6,7 @@
'use strict';
-const {type} = require('../utils');
+const {type, breakCircularDeps} = require('../utils');
const {createInvalidArgumentTypeError} = require('../errors');
... | diff --git a/test/integration/fixtures/parallel/circular-error.mjs b/test/integration/fixtures/parallel/circular-error.mjs
new file mode 100644
--- /dev/null
+++ b/test/integration/fixtures/parallel/circular-error.mjs
@@ -0,0 +1,10 @@
+import {describe,it} from "../../../../index.js";
+
+describe('test1', () => {
+ it... | 🐛 Bug: Parallel mode crashes if test exception contains circular references
<!--
Have you read Mocha's Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/mochajs/mocha/blob/master/.github/CODE_OF_CONDUCT.md
For more, check out the Moc... | 2023-11-21T08:48:00Z | 10.5 | |
mochajs/mocha | 4,985 | mochajs__mocha-4985 | [
"5112"
] | 37deed262d4bc0788d32c66636495d10038ad398 | diff --git a/lib/reporters/xunit.js b/lib/reporters/xunit.js
--- a/lib/reporters/xunit.js
+++ b/lib/reporters/xunit.js
@@ -158,6 +158,7 @@ XUnit.prototype.test = function (test) {
var attrs = {
classname: test.parent.fullTitle(),
name: test.title,
+ file: test.file,
time: test.duration / 1000 || 0
... | diff --git a/test/reporters/xunit.spec.js b/test/reporters/xunit.spec.js
--- a/test/reporters/xunit.spec.js
+++ b/test/reporters/xunit.spec.js
@@ -30,6 +30,7 @@ describe('XUnit reporter', function () {
var expectedLine = 'some-line';
var expectedClassName = 'fullTitle';
var expectedTitle = 'some title';
+ var... | 🚀 Feature: Add file path to xunit reporter
### Feature Request Checklist
- [X] I have read and agree to Mocha's [Code of Conduct](https://github.com/mochajs/mocha/blob/master/.github/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/mochajs/mocha/blob/master/.github/CONTRIBUTING.md)
- [X] I have se... | 2023-05-15T14:09:59Z | 10.2 | |
mochajs/mocha | 5,074 | mochajs__mocha-5074 | [
"5085"
] | 6f3f45e587a17463b75047631152429fa14b82a3 | diff --git a/lib/cli/run.js b/lib/cli/run.js
--- a/lib/cli/run.js
+++ b/lib/cli/run.js
@@ -369,7 +369,7 @@ exports.handler = async function (argv) {
try {
await runMocha(mocha, argv);
} catch (err) {
- console.error('\n' + (err.stack || `Error: ${err.message || err}`));
+ console.error('\n Exception du... | diff --git a/test/integration/reporters.spec.js b/test/integration/reporters.spec.js
--- a/test/integration/reporters.spec.js
+++ b/test/integration/reporters.spec.js
@@ -211,7 +211,7 @@ describe('reporters', function () {
return;
}
- var pattern = `^Error: invalid or unsupported TAP ... | 🐛 Bug: Errorhandling fails when node:module registered errors are thrown
### Bug Report Checklist
- [X] I have read and agree to Mocha's [Code of Conduct](https://github.com/mochajs/mocha/blob/master/.github/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/mochajs/mocha/blob/master/.github/CONTRIB... | 2024-01-08T10:53:04Z | 10.3 | |
mochajs/mocha | 4,842 | mochajs__mocha-4842 | [
"3596"
] | 22f9306265287eee3d273e174873fa16046376b6 | diff --git a/lib/cli/run-helpers.js b/lib/cli/run-helpers.js
--- a/lib/cli/run-helpers.js
+++ b/lib/cli/run-helpers.js
@@ -225,18 +225,18 @@ exports.validateLegacyPlugin = (opts, pluginType, map = {}) => {
// if this exists, then it's already loaded, so nothing more to do.
if (!map[pluginId]) {
+ let foundId... | diff --git a/test/browser-specific/fixtures/webpack/webpack.config.js b/test/browser-specific/fixtures/webpack/webpack.config.js
--- a/test/browser-specific/fixtures/webpack/webpack.config.js
+++ b/test/browser-specific/fixtures/webpack/webpack.config.js
@@ -17,7 +17,7 @@ module.exports = {
plugins: [
new FailO... | Correctly diagnose errors from required reporter module
### Prerequisites
- [x] Checked that your issue hasn't already been filed by cross-referencing [issues with the `faq` label](https://github.com/mochajs/mocha/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3Afaq%20)
- [x] Checked next-gen ES issues and syntax probl... | While I can see how a better error message could be helpful, the _real_ bug here is in _your_ reporter depending on missing project dependencies. | 2022-03-09T16:31:19Z | 9.2 |
mochajs/mocha | 4,835 | mochajs__mocha-4835 | [
"4330"
] | 472a8be14f9b578c8b1ef3e6ae05d06fc2d9891b | diff --git a/lib/cli/options.js b/lib/cli/options.js
--- a/lib/cli/options.js
+++ b/lib/cli/options.js
@@ -208,9 +208,10 @@ module.exports.loadPkgRc = loadPkgRc;
* Priority list:
*
* 1. Command-line args
- * 2. RC file (`.mocharc.c?js`, `.mocharc.ya?ml`, `mocharc.json`)
- * 3. `mocha` prop of `package.json`
- * 4... | diff --git a/test/node-unit/cli/options.spec.js b/test/node-unit/cli/options.spec.js
--- a/test/node-unit/cli/options.spec.js
+++ b/test/node-unit/cli/options.spec.js
@@ -42,9 +42,10 @@ describe('options', function () {
/**
* Order of priority:
* 1. Command-line args
- * 2. RC file (`.mocharc.js`, `.mochar... | 🚀 Feature: Support setting options via environment vars
As discussed in #4232, it can be difficult to pass mocha command-line options through `npm run` scripts. As @boneskull said:
> yargs has a feature that supports setting options via an environment variable; we should probably take advantage of that at some poi... | sorry, butt-closed this one
yargs has support for this via `.env()` which we _should_ be able to leverage.
From reading [the `yargs` docs](https://yargs.js.org/docs/#api-envprefix) seems like `.env('MOCHA')` should be sufficient, I'll open a PR soon
in my experience, it's never that easy, but I wish you luck regardle... | 2022-02-25T18:21:19Z | 10.4 |
mochajs/mocha | 4,771 | mochajs__mocha-4771 | [
"4216"
] | 9a1c45891f8d646c1bd540407ec7b3e63940deda | diff --git a/lib/cli/run-helpers.js b/lib/cli/run-helpers.js
--- a/lib/cli/run-helpers.js
+++ b/lib/cli/run-helpers.js
@@ -21,25 +21,24 @@ const {UnmatchedFile} = require('./collect-files');
/**
* Exits Mocha when tests + code under test has finished execution (default)
- * @param {number} code - Exit code; typica... | diff --git a/test/integration/fixtures/failing-sync.fixture.js b/test/integration/fixtures/failing-sync.fixture.js
new file mode 100644
--- /dev/null
+++ b/test/integration/fixtures/failing-sync.fixture.js
@@ -0,0 +1,9 @@
+'use strict';
+
+var assert = require('assert');
+
+describe('a suite', function() {
+ it('shoul... | 🚀 Feature: Possibility to return 0 exit code when tests run successfully even with fails
**Is your feature request related to a problem or a nice-to-have?? Please describe.**
A clear and concise description of what the problem is. E.g. I'm always frustrated when [...]
Sometimes it is useful to separate situations ... | > Sometimes it is useful to separate situations when tests run successfully, and there is no infrastructure or runtime problems, and when there are some runtime problems.
I didn't understand it. Could you explain more detail for usecases.
Using Mocha in some build tools (for example Gradle).
After Mocha successfull... | 2021-10-18T13:01:32Z | 10.6 |
mochajs/mocha | 4,807 | mochajs__mocha-4807 | [
"4803"
] | 60fafa45106e911801d9071a97b0f33542b6835f | diff --git a/lib/nodejs/esm-utils.js b/lib/nodejs/esm-utils.js
--- a/lib/nodejs/esm-utils.js
+++ b/lib/nodejs/esm-utils.js
@@ -53,15 +53,30 @@ exports.requireOrImport = hasStableEsmImplementation
err.code === 'ERR_UNSUPPORTED_DIR_IMPORT'
) {
try {
+ // Importing a file usually ... | diff --git a/test/integration/esm.spec.js b/test/integration/esm.spec.js
--- a/test/integration/esm.spec.js
+++ b/test/integration/esm.spec.js
@@ -81,4 +81,25 @@ describe('esm', function () {
'test-that-imports-non-existing-module'
);
});
+
+ it('should throw an ERR_MODULE_NOT_FOUND and not ERR_REQUIRE_... | Missing file/package in import statement misreported as ESM error
### Prerequisites
<!--
Place an `x` between the square brackets on the lines below for every satisfied prerequisite.
-->
- [x] Checked that your issue hasn't already been filed by cross-referencing [issues with the `faq` label](https://github.com... | I believe the checks for `ERR_MODULE_NOT_FOUND` and `ERR_UNKNOWN_FILE_EXTENSION` as they are here are both wrong/outdated:
`ERR_MODULE_NOT_FOUND`: I see the code comment about the red herring:
https://github.com/mochajs/mocha/blob/28b482472a519b7abaf30a18b8ad709707bfd5a7/lib/nodejs/esm-utils.js#L58-L65
I think... | 2022-01-04T05:29:23Z | 9.1 |
mochajs/mocha | 4,746 | mochajs__mocha-4746 | [
"4740"
] | 4860738af9de9493fade35aea3df65dc7461e100 | diff --git a/browser-entry.js b/browser-entry.js
--- a/browser-entry.js
+++ b/browser-entry.js
@@ -213,7 +213,4 @@ Mocha.process = process;
global.Mocha = Mocha;
global.mocha = mocha;
-// this allows test/acceptance/required-tokens.js to pass; thus,
-// you can now do `const describe = require('mocha').describe` in... | diff --git a/test/browser-specific/setup.js b/test/browser-specific/setup.js
--- a/test/browser-specific/setup.js
+++ b/test/browser-specific/setup.js
@@ -8,3 +8,5 @@ global.expect = require('unexpected')
.use(require('unexpected-map'))
.use(require('unexpected-sinon'))
.use(require('unexpected-eventemitter'))... | Window properties impeded using mocha
I recently tried to use mocha in a project whose runtime environment had a `window.ui` property and we had to patch our copy of mocha.js to make it work. The window property overshadows the mocha prototype property and mocha wouldn't even initialize properly. I suspect there are ot... | 2021-09-12T15:11:31Z | 9.1 | |
mochajs/mocha | 4,668 | mochajs__mocha-4668 | [
"4665"
] | f033ff1ab561101e956285924343c23150cd6595 | diff --git a/lib/esm-utils.js b/lib/esm-utils.js
--- a/lib/esm-utils.js
+++ b/lib/esm-utils.js
@@ -49,7 +49,8 @@ exports.requireOrImport = hasStableEsmImplementation
} catch (err) {
if (
err.code === 'ERR_MODULE_NOT_FOUND' ||
- err.code === 'ERR_UNKNOWN_FILE_EXTENSION'
+ err... | diff --git a/test/integration/esm.spec.js b/test/integration/esm.spec.js
--- a/test/integration/esm.spec.js
+++ b/test/integration/esm.spec.js
@@ -1,4 +1,5 @@
'use strict';
+var path = require('path');
var helpers = require('./helpers');
var run = helpers.runMochaJSON;
var runMochaAsync = helpers.runMochaAsync;
@@ ... | `ts-node/register` not supported in 9.0.0
### Prerequisites
- [x] Checked that your issue hasn't already been filed by cross-referencing [issues with the `faq` label](https://github.com/mochajs/mocha/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3Afaq%20)
- [x] Checked next-gen ES issues and syntax problems by using... | Will look into it tonight. Hopefully, just `require`-ing when we get `ERR_UNSUPPORTED_DIR_IMPORT` will solve the problem.
Oh, wait, I see your fix @swansontec. Looks like it _will_ solve it. Thanks!
I'm surprised that this issue is arising only two weeks after publishing v9.0.0. Is nobody using typescript with ts-node?... | 2021-06-25T06:54:20Z | 9 |
mochajs/mocha | 4,614 | mochajs__mocha-4614 | [
"4580"
] | 34643e4c0821aeb8d6977c1942bc106c9363789a | diff --git a/lib/cli/watch-run.js b/lib/cli/watch-run.js
--- a/lib/cli/watch-run.js
+++ b/lib/cli/watch-run.js
@@ -261,17 +261,21 @@ const createRerunner = (mocha, watcher, {beforeRun} = {}) => {
let rerunScheduled = false;
const run = () => {
- mocha = beforeRun ? beforeRun({mocha, watcher}) || mocha : moch... | diff --git a/test/integration/helpers.js b/test/integration/helpers.js
--- a/test/integration/helpers.js
+++ b/test/integration/helpers.js
@@ -470,6 +470,7 @@ async function runMochaWatchJSONAsync(args, opts, change) {
// eslint-disable-next-line no-control-regex
.replace(/\u001b\[\?25./g, '')
.spl... | Watcher crashes when reloading code that throws (regression mocha@7 to mocha@8)
<!--
Have you read Mocha's Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/mochajs/mocha/blob/master/.github/CODE_OF_CONDUCT.md
For more, check out the ... | When I tested your MCVE(nice MCVE), it only happened with node.js 15.x.
With 14.x and mocha v8 watcher is fine.
It seems it caused by node 15.x. But I'm not sure because mocha v7 is fine with node 15.x.
Didn't Node 15 change handling of unhandled rejections to throw?
Maybe this in combination with mocha 8 refacto... | 2021-03-28T12:10:43Z | 8.3 |
mochajs/mocha | 4,638 | mochajs__mocha-4638 | [
"3675"
] | 7c3daea17365fc826751fd9a35f97ba8cfbb7100 | diff --git a/lib/reporters/base.js b/lib/reporters/base.js
--- a/lib/reporters/base.js
+++ b/lib/reporters/base.js
@@ -190,6 +190,13 @@ function stringifyDiffObjs(err) {
*/
var generateDiff = (exports.generateDiff = function(actual, expected) {
try {
+ const diffSize = 2048;
+ if (actual.length > diffSize) ... | diff --git a/test/reporters/base.spec.js b/test/reporters/base.spec.js
--- a/test/reporters/base.spec.js
+++ b/test/reporters/base.spec.js
@@ -164,6 +164,34 @@ describe('Base reporter', function() {
' \n actual expected\n \n a foobar inline diff\n '
);
});
+
+ it("should... | Mocha failing when error message too big
### Description
Mocha never ends with big error messages
### Steps to Reproduce
```
const {expect} = require('chai')
it('Test failing', function () {
const longArray = _.times(10000, function (i) {
return {a : i}
})
const shortArray = []... | Please retry this but use the built in `assert` module. same result? if so, the problem may be in our diff-generating code.
<sub>Sent with <a href="http://githawk.com">GitHawk</a></sub>
With current master(6b5a7855110d9c493dc41aec9fb2cea15aaa42aa),
it is hang pretty long rather than forever
```sh
$ time mocha r... | 2021-05-24T14:15:43Z | 8.4 |
mochajs/mocha | 4,557 | mochajs__mocha-4557 | [
"4551"
] | 84d0c9671ba7ebb2a88a7a8311965dbc2bb424d2 | diff --git a/lib/esm-utils.js b/lib/esm-utils.js
--- a/lib/esm-utils.js
+++ b/lib/esm-utils.js
@@ -3,7 +3,29 @@ const url = require('url');
const formattedImport = async file => {
if (path.isAbsolute(file)) {
- return import(url.pathToFileURL(file));
+ try {
+ return await import(url.pathToFileURL(file... | diff --git a/test/integration/esm.spec.js b/test/integration/esm.spec.js
--- a/test/integration/esm.spec.js
+++ b/test/integration/esm.spec.js
@@ -1,5 +1,7 @@
'use strict';
-var run = require('./helpers').runMochaJSON;
+var helpers = require('./helpers');
+var run = helpers.runMochaJSON;
+var runMochaAsync = helpers.r... | If one among multiple ESM tests has a syntax error, then Mocha doesn’t report which one
### Prerequisites
<!--
Place an `x` between the square brackets on the lines below for every satisfied prerequisite.
-->
- [x] Checked that your issue hasn't already been filed by cross-referencing [issues with the `faq` lab... | 2021-01-20T15:56:51Z | 8.2 | |
mochajs/mocha | 4,607 | mochajs__mocha-4607 | [
"4131"
] | bbf0c11b29544de91a18c1bd667c975ee44b7c90 | diff --git a/example/config/.mocharc.js b/example/config/.mocharc.js
--- a/example/config/.mocharc.js
+++ b/example/config/.mocharc.js
@@ -33,7 +33,7 @@ module.exports = {
parallel: false,
recursive: false,
reporter: 'spec',
- 'reporter-option': ['foo=bar', 'baz=quux'],
+ 'reporter-option': ['foo=bar', 'baz=... | diff --git a/test/reporters/json.spec.js b/test/reporters/json.spec.js
--- a/test/reporters/json.spec.js
+++ b/test/reporters/json.spec.js
@@ -1,12 +1,16 @@
'use strict';
+var fs = require('fs');
var sinon = require('sinon');
+var JSONReporter = require('../../lib/reporters/json');
+var utils = require('../../lib/u... | Add output option to JSON reporter
**Describe the solution you'd like**
I'd like to use test report for other applications (e.g. Slack)
So, JSON file is useful.
`package.json`:
```json
{
"scripts": {
"test": "mocha ./test/*-test.js --reporter json --reporter-options output=report.json",
"posttest"... | @munierujp In your shell you can pipe the report output to a file. You don't need a `reporter-option` for this. In Windows it is the ">" sign.
The standard output may occasionally contain noise.
And, xunit reporter supports `output` option already.
> By default, it will output to the console. To write directly to a... | 2021-03-14T23:40:23Z | 9 |
mochajs/mocha | 4,418 | mochajs__mocha-4418 | [
"4417",
"4417"
] | 4d7a1716ff5c7fbc74ca048a21b67f4524fcd55a | diff --git a/lib/cli/node-flags.js b/lib/cli/node-flags.js
--- a/lib/cli/node-flags.js
+++ b/lib/cli/node-flags.js
@@ -7,6 +7,7 @@
*/
const nodeFlags = process.allowedNodeEnvironmentFlags;
+const {isMochaFlag} = require('./run-option-metadata');
const unparse = require('yargs-unparser');
/**
@@ -43,16 +44,14 @... | diff --git a/test/node-unit/cli/node-flags.spec.js b/test/node-unit/cli/node-flags.spec.js
--- a/test/node-unit/cli/node-flags.spec.js
+++ b/test/node-unit/cli/node-flags.spec.js
@@ -1,22 +1,34 @@
'use strict';
-const nodeEnvFlags = process.allowedNodeEnvironmentFlags;
+const nodeEnvFlags = [...process.allowedNodeEn... | node flag parsing strategy is backwards
https://github.com/nodejs/node/pull/34637 introduces a `-u` flag for `node`, which conflicts with Mocha's `-u`/`--ui` flag. I had expected Mocha would prefer its _own_ options over `node`'s where there was a conflict, but this is not the case--instead, Mocha explicitly whitelist... | cc @bethgriggs
This _does_ mean that if someone wants to use custom conditions w/ `mocha`, they need to use `--conditions`, not `-u`.
cc @bethgriggs
This _does_ mean that if someone wants to use custom conditions w/ `mocha`, they need to use `--conditions`, not `-u`. | 2020-08-25T18:18:24Z | 8.1 |
mochajs/mocha | 4,382 | mochajs__mocha-4382 | [
"4347"
] | 02bdb6bc6c029fb0c01389b27797d00faa76ddde | diff --git a/lib/cli/watch-run.js b/lib/cli/watch-run.js
--- a/lib/cli/watch-run.js
+++ b/lib/cli/watch-run.js
@@ -59,6 +59,10 @@ exports.watchParallelRun = (
// in `createRerunner`), we need to call `mocha.ui()` again to set up the context/globals.
newMocha.ui(newMocha.options.ui);
+ // we need to... | diff --git a/test/integration/fixtures/options/watch/hook.fixture.js b/test/integration/fixtures/options/watch/hook.fixture.js
new file mode 100644
--- /dev/null
+++ b/test/integration/fixtures/options/watch/hook.fixture.js
@@ -0,0 +1,7 @@
+module.exports = {
+ mochaHooks: {
+ ["<hook>"]: function() {
+ throw ... | Thrown error in afterEach as a root hook plugin is ignored in watchmode
<!--
Have you read Mocha's Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/mochajs/mocha/blob/master/.github/CODE_OF_CONDUCT.md
For more, check out the Mocha Gi... | This might be the same root problem as #4344.
One more related issue: console logs are ignored in root hook plugins in watchmode.
that sounds like a bug
Hit this issue myself recently. I did a little digging & issue seems to be caused by the cloning the suite on L40.
https://github.com/mochajs/mocha/blob/02bdb6bc6... | 2020-07-26T02:20:06Z | 8 |
mochajs/mocha | 4,315 | mochajs__mocha-4315 | [
"4307"
] | a2f2e087a27ee39eec729e9b4c1f5f27a8b69b9e | diff --git a/lib/cli/options.js b/lib/cli/options.js
--- a/lib/cli/options.js
+++ b/lib/cli/options.js
@@ -54,16 +54,19 @@ const configuration = Object.assign({}, YARGS_PARSER_CONFIG, {
/**
* This is a really fancy way to:
- * - ensure unique values for `array`-type options
- * - use its array's last element for `... | diff --git a/test/node-unit/cli/options.spec.js b/test/node-unit/cli/options.spec.js
--- a/test/node-unit/cli/options.spec.js
+++ b/test/node-unit/cli/options.spec.js
@@ -562,7 +562,9 @@ describe('options', function() {
readFileSync = sandbox.stub();
readFileSync.onFirstCall().throws();
... | Migrating from mocha.opts to mocharc broke glob pattern support
### Prerequisites
<details>
<summary>Click for details</summary>
- [X] Checked that your issue hasn't already been filed by cross-referencing [issues with the `faq` label](https://github.com/mochajs/mocha/issues?utf8=%E2%9C%93&q=is%3Aissue%20lab... | I confirm, I have the same problem.
@TheOptimisticFactory thank you for your detailed description.
I haven't tested, but I guess you are correct.
It's the `list` function which splits the parsed string by the `,` separator.
As a work around you can use: `spec: [ 'controllers/**/*.test.js', 'test/**/*.test.js' ]`
@... | 2020-06-06T07:17:06Z | 7.1 |
mochajs/mocha | 4,165 | mochajs__mocha-4165 | [
"4160"
] | c0f1d1456dbc068f0552a5ceaed0d9b95e940ce1 | diff --git a/lib/runner.js b/lib/runner.js
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -654,7 +654,7 @@ Runner.prototype.runTests = function(suite, fn) {
self.emit(constants.EVENT_TEST_END, test);
// skip inner afterEach hooks below errSuite level
var origSuite = self.suite;
- self.suit... | diff --git a/test/integration/fixtures/pending/programmatic.fixture.js b/test/integration/fixtures/pending/programmatic.fixture.js
new file mode 100644
--- /dev/null
+++ b/test/integration/fixtures/pending/programmatic.fixture.js
@@ -0,0 +1,8 @@
+'use strict';
+const Mocha = require('../../../../lib/mocha');
+
+const m... | Mocha runner throws if test.pending is set to true in the 'test' event
I have a script that hooks on to mocha events and dynamically determines which tests to run at runtime. I do this by setting `args.pending = true` in the `test` hook. 7.0.0 seems to break this behavior.
Here's a sample repro
```javascript
funct... | @karanjitsingh could you please patch [following line](https://github.com/mochajs/mocha/blob/master/lib/runner.js#L657) in "lib/runner.js":
- old: `self.suite = errSuite;`
- new: `self.suite = errSuite || self.suite;`
@karanjitsingh our CI tests haven't covered this test scenario, since they didn't fail in the past. ... | 2020-01-22T14:06:57Z | 7 |
mochajs/mocha | 4,234 | mochajs__mocha-4234 | [
"2783"
] | c0137eb698add08f29035467ea1dc230904f82ba | diff --git a/browser-entry.js b/browser-entry.js
--- a/browser-entry.js
+++ b/browser-entry.js
@@ -52,6 +52,17 @@ process.removeListener = function(e, fn) {
}
};
+/**
+ * Implements listenerCount for 'uncaughtException'.
+ */
+
+process.listenerCount = function(name) {
+ if (name === 'uncaughtException') {
+ ... | diff --git a/lib/test.js b/lib/test.js
--- a/lib/test.js
+++ b/lib/test.js
@@ -26,9 +26,9 @@ function Test(title, fn) {
'string'
);
}
- Runnable.call(this, title, fn);
- this.pending = !fn;
this.type = 'test';
+ Runnable.call(this, title, fn);
+ this.reset();
}
/**
@@ -36,6 +36,15 @@ function ... | Mocha can't run tests twice programmatically
Programmatically, I cannot run a Mocha test twice.
I.e. I can't do `mocha.run()` twice.
I looked at a similar issue (#[995](https://github.com/mochajs/mocha/issues/995)), however, the solutions are not optimal and/or not work.
For example, deleting the require cache... | Mmmm ><. I guess I will stick with my solution of spawning a child process for each mocha run; but I wanted to avoid this.
I had the same problem.
Reading the similar issue #[736](https://github.com/mochajs/mocha/issues/736), it seems it's all about cleaning the "require.cache" of the previously loaded spec's file
... | 2020-04-21T20:31:18Z | 7.1 |
mochajs/mocha | 4,147 | mochajs__mocha-4147 | [
"4144"
] | 7d78f209c6a4f8ef4eba584fe10515fd3901830e | diff --git a/lib/runner.js b/lib/runner.js
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -800,7 +800,7 @@ Runner.prototype.runSuite = function(suite, fn) {
};
/**
- * Handle uncaught exceptions.
+ * Handle uncaught exceptions within runner.
*
* @param {Error} err
* @private
@@ -893,6 +893,17 @@ Runner.prototype.... | diff --git a/test/integration/fixtures/uncaught/listeners.fixture.js b/test/integration/fixtures/uncaught/listeners.fixture.js
new file mode 100644
--- /dev/null
+++ b/test/integration/fixtures/uncaught/listeners.fixture.js
@@ -0,0 +1,12 @@
+'use strict';
+
+const assert = require('assert');
+const mocha = require("../... | Mocha 7: A global `uncaughtException` handle is leaked for every completed test runner
### Description
A global `uncaughtException` handle is leaked for every completed test runner, in turn causing a `MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 uncaughtException listeners added to [proc... | 2020-01-09T14:55:18Z | 7 | |
mochajs/mocha | 4,063 | mochajs__mocha-4063 | [
"4035"
] | ec17f6315e0817bfb8e37279d31affc4ec108623 | diff --git a/lib/cli/node-flags.js b/lib/cli/node-flags.js
--- a/lib/cli/node-flags.js
+++ b/lib/cli/node-flags.js
@@ -68,6 +68,7 @@ exports.impliesNoTimeouts = flag => debugFlags.has(flag);
/**
* All non-strictly-boolean arguments to node--those with values--must specify those values using `=`, e.g., `--inspect=0.0... | diff --git a/test/node-unit/cli/node-flags.spec.js b/test/node-unit/cli/node-flags.spec.js
--- a/test/node-unit/cli/node-flags.spec.js
+++ b/test/node-unit/cli/node-flags.spec.js
@@ -132,5 +132,14 @@ describe('node-flags', function() {
['--v8-numeric-one=1', '--v8-boolean-one', '--v8-numeric-two=2']
);
... | 6.2.1 fails for node 8.x if there is a --require
<!--
Have you read Mocha's Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/mochajs/mocha/blob/master/.github/CODE_OF_CONDUCT.md
For more, check out the Mocha Gitter chat room: https:/... | I just hit this; will fix.
probably 5f1cad5ee254ab3ac48d4585726a884255a23583
no, it's not directly responsible, but exposed the bug | 2019-10-12T00:05:54Z | 6.2 |
mochajs/mocha | 4,068 | mochajs__mocha-4068 | [
"4022"
] | d9f5079b3b26c61fec3329a902dea00ccc961f70 | diff --git a/lib/reporters/base.js b/lib/reporters/base.js
--- a/lib/reporters/base.js
+++ b/lib/reporters/base.js
@@ -154,14 +154,14 @@ exports.cursor = {
}
};
-function showDiff(err) {
+var showDiff = (exports.showDiff = function(err) {
return (
err &&
err.showDiff !== false &&
sameType(err.ac... | diff --git a/test/reporters/xunit.spec.js b/test/reporters/xunit.spec.js
--- a/test/reporters/xunit.spec.js
+++ b/test/reporters/xunit.spec.js
@@ -350,6 +350,42 @@ describe('XUnit reporter', function() {
'</failure></testcase>';
expect(expectedWrite, 'to be', expectedTag);
});
+
+ it('sh... | reporter xunit output report incomplete
### Prerequisites
- [X] Checked that your issue hasn't already been filed by cross-referencing [issues with the `faq` label](https://github.com/mochajs/mocha/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3Afaq%20)
- [X] Checked next-gen ES issues and syntax problems by using the... | Please run the same test again and write the output to a file, see [docu](https://mochajs.org/#xunit). It's important to know wether the file output is correct or truncated as well.
Hi, I am Serge's colleague.
The output is truncated as well.
[report-output.zip](https://github.com/mochajs/mocha/files/3626331/repo... | 2019-10-14T20:55:10Z | 6.2 |
mochajs/mocha | 3,834 | mochajs__mocha-3834 | [
"3808"
] | a4f1a442a22e53ad629a5f565d4a17b687afce53 | diff --git a/lib/cli/options.js b/lib/cli/options.js
--- a/lib/cli/options.js
+++ b/lib/cli/options.js
@@ -80,11 +80,12 @@ const nargOpts = types.array
/**
* Wrapper around `yargs-parser` which applies our settings
* @param {string|string[]} args - Arguments to parse
+ * @param {Object} defaultValues - Default val... | diff --git a/test/integration/file-utils.spec.js b/test/integration/file-utils.spec.js
--- a/test/integration/file-utils.spec.js
+++ b/test/integration/file-utils.spec.js
@@ -58,7 +58,7 @@ describe('file utils', function() {
ex.and('to have length', expectedLength);
});
- it('should parse extensions fr... | Extension option does not clear the default .js
### Prerequisites
- [x] Checked that your issue hasn't already been filed by cross-referencing [issues with the `faq` label](https://github.com/mochajs/mocha/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3Afaq%20)
- [ x Checked next-gen ES issues and syntax problems by u... | As far as I can tell this particular feature hasn't worked since v6. Tried on `6.0.0-0` and includes `.js` files. When run with debugger
```
DEBUG=mocha:cli:* mocha --extension bar
```
Gives initial cli "loaded opts" as `extension: [ 'bar', 'js' ]`
Suggesting its appending a default early on. Perhaps feature was ... | 2019-03-14T00:11:30Z | 6.1 |
mochajs/mocha | 3,816 | mochajs__mocha-3816 | [
"3813"
] | e6542538aa10c6137babf96d9ddc851fc6595ad3 | diff --git a/lib/mocha.js b/lib/mocha.js
--- a/lib/mocha.js
+++ b/lib/mocha.js
@@ -120,12 +120,15 @@ function Mocha(options) {
utils.deprecate(
'enableTimeouts is DEPRECATED and will be removed from a future version of Mocha. Instead, use "timeout: false" to disable timeouts.'
);
+ if (options.enabl... | diff --git a/test/unit/mocha.spec.js b/test/unit/mocha.spec.js
--- a/test/unit/mocha.spec.js
+++ b/test/unit/mocha.spec.js
@@ -20,24 +20,49 @@ describe('Mocha', function() {
beforeEach(function() {
sandbox.stub(Mocha.prototype, 'useColors').returnsThis();
sandbox.stub(utils, 'deprecate');
+ sand... | Regression caused by the deprecation of `enableTimeouts`
### Description
There is a regression caused by the deprecation of `enableTimeouts`
As you cas see here: https://github.com/mochajs/mocha/pull/3556/files#diff-aa849a970cef551664c12f04a4209f6fR121
`enableTimeouts` was marked as deprecated and the use of `ti... | Thanks. Looks like I obliterated this guard. | 2019-03-07T01:48:43Z | 6 |
mochajs/mocha | 3,767 | mochajs__mocha-3767 | [
"3761"
] | 6535965e8655a66de54fc0ad9465c2eb825f13f8 | diff --git a/lib/cli/node-flags.js b/lib/cli/node-flags.js
--- a/lib/cli/node-flags.js
+++ b/lib/cli/node-flags.js
@@ -29,16 +29,32 @@ const debugFlags = new Set(['debug', 'debug-brk', 'inspect', 'inspect-brk']);
* - `--v8-*` (but *not* `--v8-options`)
* @summary Whether or not to pass a flag along to the `node` ... | diff --git a/test/integration/options/node-flags.spec.js b/test/integration/options/node-flags.spec.js
new file mode 100644
--- /dev/null
+++ b/test/integration/options/node-flags.spec.js
@@ -0,0 +1,19 @@
+'use strict';
+
+var invokeMocha = require('../helpers').invokeMocha;
+
+describe('node flags', function() {
+ it... | cli option `--require trace-something` causes `bad option`-error
### Prerequisites
- [x] Checked that your issue hasn't already been filed by cross-referencing [issues with the `faq` label](https://github.com/mochajs/mocha/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3Afaq%20)
- [x] Checked next-gen ES issues and syn... | also happens when
```
mocha --trace-warnings --inspect
/usr/local/bin/node: bad option: --trace-warnings --inspect
```
but not when
```
mocha --inspect
```
or
```
mocha --trace-warnings
```
Reasonably sure this has to do with the Node flag processing going on [here](https://github.com/mochajs/mocha/blob/653... | 2019-02-25T05:06:20Z | 6 |
mochajs/mocha | 3,737 | mochajs__mocha-3737 | [
"3668"
] | 5d9d3eb665825ea69435388f5776150f40c844be | diff --git a/lib/mocha.js b/lib/mocha.js
--- a/lib/mocha.js
+++ b/lib/mocha.js
@@ -543,7 +543,9 @@ Mocha.prototype._growl = growl.notify;
* mocha.globals(['jQuery', 'MyLib']);
*/
Mocha.prototype.globals = function(globals) {
- this.options.globals = (this.options.globals || []).concat(globals);
+ this.options.gl... | diff --git a/test/unit/mocha.spec.js b/test/unit/mocha.spec.js
--- a/test/unit/mocha.spec.js
+++ b/test/unit/mocha.spec.js
@@ -5,7 +5,7 @@ var Mocha = require('../../lib/mocha');
var sinon = require('sinon');
describe('Mocha', function() {
- var opts = {reporter: function() {}}; // no output
+ var opts = {reporte... | bug fix: concat(undefined) returns [undefined]
### Requirements
### Description of the Change
This line: `this.options.globals = (this.options.globals || []).concat(globals);` has the potential to produce arrays that contain the `undefined` element.
The result of `concat(undefined)` is `[undefined]`, an array ... |
[](https://coveralls.io/builds/21038001)
Coverage increased (+0.04%) to 90.814% when pulling **3efcc84c8b5f7e7ee7c85f93d62931748f7fffdd on givanse:concat-undefined** into **0a86e6f4a7d1724782d2cc4695ac6422bae94f37 on mochajs:master**.
@givanse Seems plaus... | 2019-02-16T15:05:36Z | 6 |
mochajs/mocha | 3,699 | mochajs__mocha-3699 | [
"3681"
] | 52b9a5fb97bc3a6581dc6538aa0092276e71ea41 | diff --git a/lib/cli/node-flags.js b/lib/cli/node-flags.js
--- a/lib/cli/node-flags.js
+++ b/lib/cli/node-flags.js
@@ -7,6 +7,7 @@
*/
const nodeFlags = require('node-environment-flags');
+const unparse = require('yargs-unparser');
/**
* These flags are considered "debug" flags.
@@ -34,6 +35,7 @@ const debugFl... | diff --git a/test/assertions.js b/test/assertions.js
--- a/test/assertions.js
+++ b/test/assertions.js
@@ -9,7 +9,7 @@ exports.mixinMochaAssertions = function(expect) {
return (
Object.prototype.toString.call(v) === '[object Object]' &&
typeof v.output === 'string' &&
- typeof v.... | `--inspect` flag doesn't work
When I tried to debug mocha with `--inspect` option, `ReferenceError: describe is not defined` error occurred.
It seems it is not run under `mocha` context.
```sh
$ ./node_modules/.bin/mocha --version
6.0.0-1
$ ./node_modules/.bin/mocha --inspect ex.test.js
Debugger listening o... | I tried to fix this issue, but I could find a good solution. Any idea? /cc @mochajs/core
```sh
$ ./bin/mocha --inspect example.js
mocha:cli exec /Users/outsider/bin/lib/node.js/node-v10.15.0-darwin-x64/bin/node w/ args: [ '--inspect',
'example.js',
'/Users/outsider/mocha/bin/_mocha',
'--timeout',
... | 2019-01-28T21:06:18Z | 6 |
mochajs/mocha | 3,632 | mochajs__mocha-3632 | [
"2755"
] | f223298b869e1a7f333678b37e3d2772efecc63d | diff --git a/lib/mocha.js b/lib/mocha.js
--- a/lib/mocha.js
+++ b/lib/mocha.js
@@ -92,7 +92,7 @@ function Mocha(options) {
this.files = [];
this.options = options;
// root suite
- this.suite = new exports.Suite('', new exports.Context());
+ this.suite = new exports.Suite('', new exports.Context(), true);
... | diff --git a/test/unit/suite.spec.js b/test/unit/suite.spec.js
--- a/test/unit/suite.spec.js
+++ b/test/unit/suite.spec.js
@@ -302,6 +302,27 @@ describe('Suite', function() {
});
});
+ describe('.create()', function() {
+ before(function() {
+ this.first = new Suite('Root suite', {}, true);
+ th... | Decouple the "root" property on Suite from title length.
Right now, Mocha deems a `Suite` to be a `root` if the title for it is empty, as can be seen [here](https://github.com/mochajs/mocha/blob/2bb2b9fa35818db7a02e5068364b0c417436b1af/lib/suite.js#L60):
```
function Suite (title, parentContext) {
if (!utils.isS... | 2018-12-21T22:27:32Z | 6 | |
mochajs/mocha | 3,375 | mochajs__mocha-3375 | [
"3370"
] | 7613521a8d38fc51f50f70a83ae83a6557fbd36c | diff --git a/bin/options.js b/bin/options.js
--- a/bin/options.js
+++ b/bin/options.js
@@ -32,6 +32,7 @@ function getOptions() {
try {
const opts = fs
.readFileSync(optsPath, 'utf8')
+ .replace(/^#.*$/gm, '')
.replace(/\\\s/g, '%20')
.split(/\s/)
.filter(Boolean)
| diff --git a/test/integration/regression.spec.js b/test/integration/regression.spec.js
--- a/test/integration/regression.spec.js
+++ b/test/integration/regression.spec.js
@@ -32,6 +32,7 @@ describe('regressions', function() {
var processArgv = process.argv.join('');
var mochaOpts = fs
.readFileSync(pat... | Add support for comment lines in Mocha options file
### Prerequisites
- [x] Checked that your issue hasn't already been filed by cross-referencing [issues with the `faq` label](https://github.com/mochajs/mocha/issues?utf8=%E2%9C%93&q=is%3Aissue%20label%3Afaq%20)
Related proposals:
#2587
#2870
#2963
### De... | 2018-05-03T22:44:01Z | 5 | |
mochajs/mocha | 3,222 | mochajs__mocha-3222 | [
"3119"
] | 3509029e5da38daca0d650094117600b6617a862 | diff --git a/lib/runnable.js b/lib/runnable.js
--- a/lib/runnable.js
+++ b/lib/runnable.js
@@ -53,7 +53,6 @@ function Runnable (title, fn) {
this._slow = 75;
this._enableTimeouts = true;
this.timedOut = false;
- this._trace = new Error('done() called multiple times');
this._retries = -1;
this._currentRe... | diff --git a/test/integration/fixtures/multiple-done-with-error.fixture.js b/test/integration/fixtures/multiple-done-with-error.fixture.js
new file mode 100644
--- /dev/null
+++ b/test/integration/fixtures/multiple-done-with-error.fixture.js
@@ -0,0 +1,8 @@
+'use strict';
+
+it('should fail in a test-case', function (d... | Error object stored on Runnable._trace leaks memory
FYI: In V8, Error objects keep closures alive until the `err.stack` property is accessed, which prevents collection of the closure (and associated objects) until the Error objects die.
Mocha creates a long-living Error for each Runnable: https://github.com/mochajs/... | @schuay Is this a bug in V8?
[Webpack's workaround](https://github.com/webpack/webpack/commit/be2477bac7324af5ee0ad9abe899df9639fed263)
I don't really think Mocha should be changing any code unless there are widespread problems with this. If it's a handful of projects having the problem, they should be able to work... | 2018-01-28T21:34:15Z | 5 |
mochajs/mocha | 3,268 | mochajs__mocha-3268 | [
"3265"
] | aaaa5abdd72e6d9db446c3c0d414947241ce6042 | diff --git a/lib/utils.js b/lib/utils.js
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -8,8 +8,15 @@ var debug = require('debug')('mocha:watch');
var fs = require('fs');
var glob = require('glob');
var path = require('path');
+var join = path.join;
var he = require('he');
+/**
+ * Ignored directories.
+ */
+
+var igno... | diff --git a/test/node-unit/file-utils.spec.js b/test/node-unit/file-utils.spec.js
--- a/test/node-unit/file-utils.spec.js
+++ b/test/node-unit/file-utils.spec.js
@@ -105,6 +105,26 @@ describe('file utils', function () {
});
});
+ describe('.files', function () {
+ (symlinkSupported ? it : it.skip)('shoul... | "utils.files is not a function" (mocha: 5.0.2)
### Description
Hey, i've just upgraded to the latest mocha version `5.0.2` and I now start to see a `"utils.files is not a function"` error when running in watch mode with passing a glob path. Seems this commit ec8901a23c5194b6f7e6eee9c2568e5020c944ce removed the funct... | Same here, looks like `utils.files` was removed in https://github.com/mochajs/mocha/commit/ec8901a23c5194b6f7e6eee9c2568e5020c944ce but is still in use at https://github.com/mochajs/mocha/blob/master/bin/_mocha#L532.
This exists in 5.0.1 as well it seems.
Confirm this is still an issue.
Downgraded to 5.0.1, it works. | 2018-03-07T05:02:59Z | 5 |
mochajs/mocha | 3,024 | mochajs__mocha-3024 | [
"3018"
] | 228dc4758dfebf0430b9295c6b75221c3390aee4 | diff --git a/browser-entry.js b/browser-entry.js
--- a/browser-entry.js
+++ b/browser-entry.js
@@ -45,7 +45,7 @@ process.removeListener = function (e, fn) {
} else {
global.onerror = function () {};
}
- var i = Mocha.utils.indexOf(uncaughtExceptionHandlers, fn);
+ var i = uncaughtExceptionHandler... | diff --git a/lib/test.js b/lib/test.js
--- a/lib/test.js
+++ b/lib/test.js
@@ -5,8 +5,8 @@
*/
var Runnable = require('./runnable');
-var create = require('lodash.create');
-var isString = require('./utils').isString;
+var utils = require('./utils');
+var isString = utils.isString;
/**
* Expose `Test`.
@@ -33,... | upgrade (mostly) production deps
after #3016 but before v4.0.0, these production deps should be upgraded to the latest version, if not too painful:
- `commander`
- `debug`
- `diff`
- `glob`
- `lodash.create`
- `readable-stream`
- `supports-color`
the following dev deps should be upgraded as well, with cavea... | 2017-09-28T04:18:03Z | 3.5 | |
mochajs/mocha | 3,143 | mochajs__mocha-3143 | [
"3142"
] | 5fbbce999284f137332ab359be11117d265b6cb1 | diff --git a/lib/interfaces/bdd.js b/lib/interfaces/bdd.js
--- a/lib/interfaces/bdd.js
+++ b/lib/interfaces/bdd.js
@@ -102,7 +102,7 @@ module.exports = function (suite) {
*/
context.xit = context.xspecify = context.it.skip = function (title) {
- context.it(title);
+ return context.it(title);
... | diff --git a/test/integration/fixtures/pending/skip-shorthand.fixture.js b/test/integration/fixtures/pending/skip-shorthand.fixture.js
new file mode 100644
--- /dev/null
+++ b/test/integration/fixtures/pending/skip-shorthand.fixture.js
@@ -0,0 +1,7 @@
+'use strict';
+
+describe('pending shorthand', function () {
+ xit... | Add timeout option to xits using arrow functions
<!--
Have you read Mocha's Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/mochajs/mocha/blob/master/.github/CODE_OF_CONDUCT.md
For more, check out the Mocha Gitter chat room: https:/... | Is this a documented API? I don't recall ever seeing anyone use this before.
anyway, this looks pretty trivial to address. I'm going to call it a bug even though it's more of an "internal consistency" issue, since we don't necessarily expect consumers to use the object returned from `it` or `xit` for anything.
@bone... | 2017-12-11T20:22:43Z | 4 |
mochajs/mocha | 2,746 | mochajs__mocha-2746 | [
"2745"
] | 2d7e2526b84d536c14279761a6637ed7ce2b10a8 | diff --git a/bin/options.js b/bin/options.js
--- a/bin/options.js
+++ b/bin/options.js
@@ -17,6 +17,10 @@ module.exports = getOptions;
*/
function getOptions () {
+ if (process.argv.length === 3 && (process.argv[2] === '-h' || process.argv[2] === '--help')) {
+ return;
+ }
+
var optsPath = process.argv.ind... | diff --git a/test/integration/fixtures/options/help/test/mocha.opts b/test/integration/fixtures/options/help/test/mocha.opts
new file mode 100644
--- /dev/null
+++ b/test/integration/fixtures/options/help/test/mocha.opts
@@ -0,0 +1 @@
+foo
diff --git a/test/integration/helpers.js b/test/integration/helpers.js
--- a/tes... | `mocha -h` doesn't always display help
Pretty straightforward testcase:
```
zarel@Phenylalanine ~> mocha -h
Usage: mocha [debug] [options] [files]
[...]
zarel@Phenylalanine ~> mkdir test
zarel@Phenylalanine ~> echo "test" > test/mocha.opts
zarel@Phenylalanine ~> mocha -h
No test files found
```
... | 2017-03-17T18:17:09Z | 4 | |
mochajs/mocha | 2,696 | mochajs__mocha-2696 | [
"1818"
] | ac0c1c8382a50963425e00d306e4d158f6bfd9c3 | diff --git a/lib/mocha.js b/lib/mocha.js
--- a/lib/mocha.js
+++ b/lib/mocha.js
@@ -483,6 +483,24 @@ Mocha.prototype.delay = function delay () {
return this;
};
+/**
+ * Tests marked only fail the suite
+ * @returns {Mocha}
+ */
+Mocha.prototype.forbidOnly = function () {
+ this.options.forbidOnly = true;
+ retu... | diff --git a/test/integration/fixtures/options/forbid-only/only.js b/test/integration/fixtures/options/forbid-only/only.js
new file mode 100644
--- /dev/null
+++ b/test/integration/fixtures/options/forbid-only/only.js
@@ -0,0 +1,7 @@
+'use strict';
+
+describe('forbid only - test marked with only', function () {
+ it(... | add --strict flag
I'd like a `--strict` CLI flag that will cause my tests to exit with non-zero status if
- any test is marked as only
- any test is marked as skipped
- any test is marked as pending
| This may be a good solution to the problem of accidentally committing these.
@mochajs/mocha any opinions?
Hmm, I thought skipped tests are actually marked as pending?
People do commit these (looking at you `.only`), so I believe this is useful, and I'm looking forward to it.
Not so sure about the tests marked as s... | 2017-01-31T06:10:10Z | 3.4 |
mochajs/mocha | 2,642 | mochajs__mocha-2642 | [
"2626",
"2626"
] | c82c49362971855a3cb4b1244ba7df8b3492b6a4 | diff --git a/lib/utils.js b/lib/utils.js
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -322,7 +322,7 @@ exports.parseQuery = function (qs) {
var key = pair.slice(0, i);
var val = pair.slice(++i);
- obj[key] = decodeURIComponent(val);
+ obj[key] = decodeURIComponent(val.replace(/\+/g, '%20'));
return o... | diff --git a/test/utils.spec.js b/test/utils.spec.js
--- a/test/utils.spec.js
+++ b/test/utils.spec.js
@@ -95,6 +95,10 @@ describe('utils', function () {
r3: '^co.*'
});
});
+
+ it('should parse "+" as a space', function () {
+ parseQuery('?grep=foo+bar').should.eql({grep: 'foo bar'});
+ ... | 3.x: url encoded grep not properly unescaped
HI,
Running `3.0.2`, in browser tests `grep` argument
won t work properly with an url like `http://localhost:3000/test/?grep=CustomAjaxTable+should+update+header+class+on+sortable+header+click`
It will work if the spaces are not replaced by `+` sign,
`http://localhost... | 2016-12-19T00:56:54Z | 3.2 | |
mochajs/mocha | 2,513 | mochajs__mocha-2513 | [
"2490"
] | 9915dfbc671f7f5d3cab55acde7356d839c1170c | diff --git a/.eslintrc.js b/.eslintrc.js
new file mode 100644
--- /dev/null
+++ b/.eslintrc.js
@@ -0,0 +1,3 @@
+module.exports = {
+ "extends": "semistandard"
+};
diff --git a/browser-entry.js b/browser-entry.js
--- a/browser-entry.js
+++ b/browser-entry.js
@@ -35,12 +35,12 @@ var originalOnerrorHandler = global.onerr... | diff --git a/lib/test.js b/lib/test.js
--- a/lib/test.js
+++ b/lib/test.js
@@ -19,7 +19,7 @@ module.exports = Test;
* @param {String} title
* @param {Function} fn
*/
-function Test(title, fn) {
+function Test (title, fn) {
if (!isString(title)) {
throw new Error('Test `title` should be a "string" but "' +... | use semistandard
We have some code standards in place, but not enough. We have disabled many warnings which we probably shouldn't have, to avoid changing too much code when we picked up ESLint originally. I'd also prefer to use a widely-used style instead of a custom style.
- Install eslint-semistandard-config and al... | Great move! 👍
| 2016-09-30T13:04:19Z | 3.1 |
mochajs/mocha | 2,479 | mochajs__mocha-2479 | [
"2465"
] | 539255c8a8c8bba5b432156b0f86f57eb13b0ce5 | diff --git a/lib/runnable.js b/lib/runnable.js
--- a/lib/runnable.js
+++ b/lib/runnable.js
@@ -133,7 +133,7 @@ Runnable.prototype.enableTimeouts = function(enabled) {
* @api public
*/
Runnable.prototype.skip = function() {
- throw new Pending();
+ throw new Pending('sync skip');
};
/**
@@ -298,14 +298,19 @@ ... | diff --git a/test/runner.js b/test/runner.js
--- a/test/runner.js
+++ b/test/runner.js
@@ -1,55 +1,59 @@
-var mocha = require('../')
- , Suite = mocha.Suite
- , Runner = mocha.Runner
- , Test = mocha.Test;
+var mocha = require('../');
+var Suite = mocha.Suite;
+var Runner = mocha.Runner;
+var Test = mocha.Test;
+var... | Calling done() after this.skip() results in 'done() called multiple times'
The following code skips the test in mocha v2, but causes an error in v3
#### Test
```
describe('broken skip behaviour', function() {
it('should not report done() called multiple times', function(done) {
this.skip()
done()
... | > I've tried with various version of mocha from 1-3 and it looks like I can simply remove the call to done() in all versions. Can you confirm?
You don't need `done` if all your test code executes synchronously; you need it (or to return a promise encapsulating the asynchronous code) if your test executes anything sync... | 2016-09-14T23:26:52Z | 3 |
mochajs/mocha | 2,499 | mochajs__mocha-2499 | [
"2496"
] | 8ccccba817143539f074362f2f95b3f731d23cef | diff --git a/lib/utils.js b/lib/utils.js
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -89,7 +89,7 @@ exports.map = function(arr, fn, scope) {
* @param {number} start
* @return {number}
*/
-exports.indexOf = function(arr, obj, start) {
+var indexOf = exports.indexOf = function(arr, obj, start) {
for (var i = start ... | diff --git a/test/acceptance/utils.spec.js b/test/acceptance/utils.spec.js
--- a/test/acceptance/utils.spec.js
+++ b/test/acceptance/utils.spec.js
@@ -77,6 +77,10 @@ describe('lib/utils', function () {
var stringify = utils.stringify;
+ it('should return an object representation of a string created with a S... | Objects prematurely coerced into string primitives
This is regarding an issue I reported on the WebStorm tracker: https://youtrack.jetbrains.com/issue/WEB-23383
Differences between symbols that are not strictly equal, appear as being equal and are thus hard to read and confusing.
Here is a simplified version of a tes... | How assertion libraries generate error messages is outside of the scope of Mocha. I suggest taking this up with chai or the relevant chai plugin you might be using
@Munter Apparently the behavior is related to https://github.com/mochajs/mocha/blob/master/lib/utils.js#L435
Also, @boneskull suggested to post this here... | 2016-09-22T21:22:04Z | 3 |
mochajs/mocha | 2,345 | mochajs__mocha-2345 | [
"1813",
"1813"
] | 96d9e06669262c395d74a12c2f15490535829507 | diff --git a/karma.conf.js b/karma.conf.js
--- a/karma.conf.js
+++ b/karma.conf.js
@@ -41,7 +41,7 @@ module.exports = function(config) {
// TO RUN LOCALLY:
// Execute `CI=1 make test-browser`, once you've set the SAUCE_USERNAME and
// SAUCE_ACCESS_KEY env vars.
- if (process.env.CI) {
+ if (process.env.CI &&... | diff --git a/test/acceptance/fs.js b/test/acceptance/fs.js
--- a/test/acceptance/fs.js
+++ b/test/acceptance/fs.js
@@ -1,16 +1,18 @@
var fs = require('fs');
+var path = require('path');
+var tmpFile = path.join.bind(path, require('os-tmpdir')());
describe('fs.readFile()', function(){
describe('when the file exis... | Tests are broken in Windows
Having read the contributing guidelines, I realized that on a windows machine I could not confirm whether any changes I committed failed tests or not because many of the tests are failing in windows.
Summary of issues and potential fixes:
- I wasn't able to get the windows make to work pro... | Hi @tswaters,
> I'm looking for confirmation that these changes (a) are welcome
Fantastic initiative! I must admit I wasn't even aware of the failing tests on windows, but fixing these is more than welcome!
> (b) wouldn't break the tests when run in a unix environment (unsure if spawn vs. exec produces different re... | 2016-07-01T06:19:32Z | 2.5 |
mochajs/mocha | 2,094 | mochajs__mocha-2094 | [
"2089"
] | 2a8594424c73ffeca41ef1668446372160528b4a | diff --git a/lib/utils.js b/lib/utils.js
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -472,6 +472,7 @@ function jsonStringify(object, spaces, depth) {
break;
case 'boolean':
case 'regexp':
+ case 'symbol':
case 'number':
val = val === 0 && (1 / val) === -Infinity // `-0`
... | diff --git a/test/acceptance/utils.js b/test/acceptance/utils.js
--- a/test/acceptance/utils.js
+++ b/test/acceptance/utils.js
@@ -331,6 +331,15 @@ describe('lib/utils', function () {
stringify(a).should.equal('{\n "foo": 1\n}');
});
+
+ // In old version node.js, Symbol is not available by default.
+... | Diff doesn't be displayed when object has Symbol value
When I assert an object that has a `Symbol` value, the test doesn't display diff even if it fails. For example, the following test fails without generating diff.
``` javascript
// test.js
const assert = require('assert');
it('should generate diff', () => {
cons... | 2016-02-06T04:09:58Z | 2.4 | |
mochajs/mocha | 2,081 | mochajs__mocha-2081 | [
"1760",
"1936"
] | cf513cbff35141dc7275325bef9fe6d6e13ce979 | diff --git a/lib/interfaces/bdd.js b/lib/interfaces/bdd.js
--- a/lib/interfaces/bdd.js
+++ b/lib/interfaces/bdd.js
@@ -79,7 +79,7 @@ module.exports = function(suite) {
var it = context.it = context.specify = function(title, fn) {
var suite = suites[0];
- if (suite.pending) {
+ if (suite.isPendin... | diff --git a/test/suite.js b/test/suite.js
--- a/test/suite.js
+++ b/test/suite.js
@@ -288,6 +288,11 @@ describe('Suite', function(){
this.first.suites.should.have.length(1);
this.first.suites[0].should.equal(this.second);
});
+
+ it('treats suite as pending if its parent is pending', function(){
... | `this.skip()` completely broken if html reporter used.
Demo: https://github.com/Kirill89/mocha-test
`Error: TypeError: test.err is undefined (http://localhost:1111/node_modules/mocha/mocha.js:2786)`
- Firefox 38.0.5
- Chrome 43.0.2357.124 (64-bit)
this.skip causes: Cannot read property 'toString' of undefined
Error l... | what are you trying to accomplish by skipping the hook?
@boneskull I'm trying skip whole "describe" section.
@boneskull mocha already has same [test](https://github.com/mochajs/mocha/blob/master/test/integration/fixtures/pending/skip.sync.before.js), and it is works for reporter "spec". Can you explain me why doesn't... | 2016-01-28T11:39:17Z | 2.4 |
mochajs/mocha | 1,965 | mochajs__mocha-1965 | [
"1964"
] | 3af1b8a54d7c17fceccf10f4fe02fd03000841c5 | diff --git a/lib/interfaces/bdd.js b/lib/interfaces/bdd.js
--- a/lib/interfaces/bdd.js
+++ b/lib/interfaces/bdd.js
@@ -77,7 +77,7 @@ module.exports = function(suite) {
* acting as a thunk.
*/
- context.it = context.specify = function(title, fn) {
+ var it = context.it = context.specify = function(ti... | diff --git a/test/acceptance/misc/only/bdd-require.js b/test/acceptance/misc/only/bdd-require.js
new file mode 100644
--- /dev/null
+++ b/test/acceptance/misc/only/bdd-require.js
@@ -0,0 +1,18 @@
+/*jshint node: true */
+
+var mocha = require('../../../../lib/mocha');
+
+var beforeEach = mocha.beforeEach;
+var it = moc... | require('mocha').beforeEach does not run outer lifecycle hooks when running inner testcases marked by `it.only`
This code associated with this writeup is available here: https://gist.github.com/cowboyd/f5611829c7a3ad084642
given the following mocha code:
``` javascript
var beforeEach = require('mocha').beforeEach;
de... | After further investigation, this only happens when using the [Require](http://mochajs.org/#require) interface. If using the global BDD interface, this is not an issue.
Also, it appears to be a problem with the `require`d `beforEach`. When using the `require`'d `it` and `describe`, but the global `beforeEach`, everyth... | 2015-11-12T21:06:34Z | 2.3 |
mochajs/mocha | 1,410 | mochajs__mocha-1410 | [
"1395",
"1395"
] | 9cb8a91996d9ecee4e0a954aca7daaa9bc057a46 | diff --git a/lib/runnable.js b/lib/runnable.js
--- a/lib/runnable.js
+++ b/lib/runnable.js
@@ -4,7 +4,8 @@
var EventEmitter = require('events').EventEmitter
, debug = require('debug')('mocha:runnable')
- , milliseconds = require('./ms');
+ , milliseconds = require('./ms')
+ , utils = require('./utils');
/**... | diff --git a/test/acceptance/throw.js b/test/acceptance/throw.js
new file mode 100644
--- /dev/null
+++ b/test/acceptance/throw.js
@@ -0,0 +1,111 @@
+var mocha = require('../../')
+ , Suite = mocha.Suite
+ , Runner = mocha.Runner
+ , Test = mocha.Test;
+
+describe('a test that throws', function () {
+ var suite, ru... | throw undefined
``` js
it('expected', function () {
throw 'foo';
});
it('unexpected', function () {
throw undefined;
});
```
then
``` sh
1) expected
✓ unexpected
```
in 1.21.5
throw undefined
``` js
it('expected', function () {
throw 'foo';
});
it('unexpected', function () {
throw undefined;
});... | I'm working on this issue right now.
I agree that throwing `undefined` should make the test fail. What about throwing `null`?
Current behaviour is: a test passes if thrown either `undefined` or `null`. UNLESS you are throwing async on an async test, due to `Runner.prototype.uncaught`. It even generates an error with... | 2014-11-01T13:51:53Z | 2 |
mochajs/mocha | 1,520 | mochajs__mocha-1520 | [
"1496"
] | b9256736095e616d510edb4dfb8b50f96528492f | diff --git a/lib/mocha.js b/lib/mocha.js
--- a/lib/mocha.js
+++ b/lib/mocha.js
@@ -410,9 +410,7 @@ Mocha.prototype.run = function(fn){
function done(failures) {
if (reporter.done) {
reporter.done(failures, fn);
- } else {
- fn(failures);
- }
+ } else fn && fn(failures);
}... | diff --git a/test/mocha.js b/test/mocha.js
new file mode 100644
--- /dev/null
+++ b/test/mocha.js
@@ -0,0 +1,33 @@
+var Mocha = require('../');
+var Test = Mocha.Test;
+
+describe('Mocha', function(){
+ var blankOpts = { reporter: function(){} }; // no output
+
+ describe('.run(fn)', function(){
+ it('should not r... | Mocha.run throws a TypeError if callback is not provided
To reproduce the issue, install Mocha 2.1.0 and run this script on Node console.
``` javascript
var Mocha = require("mocha");
var mocha = new Mocha();
mocha.addFile("./test.js");
mocha.run();
```
Here is `test.js`
``` javascript
it("nothing", function() {});
`... | Same issue here, the workaround solved it for now.
@dasilvacontin As @julien-f experienced the same issue, you may want to change the label, unconfirmed, to something like invalid or bug?
Sure, thanks for the heads up, @flowersinthesand!
| 2015-01-31T23:35:21Z | 2.1 |
mochajs/mocha | 1,878 | mochajs__mocha-1878 | [
"1864"
] | 75a7f71ceeabf8ff1dc775fc08ea30aa20f0928b | diff --git a/lib/reporters/xunit.js b/lib/reporters/xunit.js
--- a/lib/reporters/xunit.js
+++ b/lib/reporters/xunit.js
@@ -77,6 +77,11 @@ function XUnit(runner, options) {
});
}
+/**
+ * Inherit from `Base.prototype`.
+ */
+inherits(XUnit, Base);
+
/**
* Override done to close the stream (if it's a file).
*
... | diff --git a/test/integration/reporters.js b/test/integration/reporters.js
--- a/test/integration/reporters.js
+++ b/test/integration/reporters.js
@@ -1,8 +1,12 @@
var assert = require('assert');
+var os = require('os');
+var fs = require('fs');
+var crypto = require('crypto');
+var path = require('path');
... | xunit reporter does not report <testcase />
currently Xunit reporter only reports the top
```
<testsuite name="Mocha Tests" tests="16" failures="0" errors="0" skipped="0" timestamp="Fri, 04 Sep 2015 23:05:49 GMT" time="0.043">`
```
but not the child test cases
something that i would expect is:
```
<testsuite name="M... | quite possible it's broken since we don't have good tests for the reporters
yep. since i upgraded mocha from 2.2.4 to 2.3.0.
using:
```
--reporter xunit --reporter-options output=build/testreport-integration.xml
```
only writes the first line:
```
<testsuite name="Mocha Tests" tests="242" failures="0" errors="0" s... | 2015-09-09T19:33:21Z | 2.3 |
mochajs/mocha | 1,698 | mochajs__mocha-1698 | [
"1687"
] | 28e0a4f9abfdae15841ce01c89e5c59224f6fc2d | diff --git a/lib/reporters/html.js b/lib/reporters/html.js
--- a/lib/reporters/html.js
+++ b/lib/reporters/html.js
@@ -5,6 +5,7 @@
var Base = require('./base')
, utils = require('../utils')
, Progress = require('../browser/progress')
+ , escapeRe = require('../browser/escape-string-regexp')
, escape = utils.... | diff --git a/test/browser/ui.html b/test/browser/ui.html
new file mode 100644
--- /dev/null
+++ b/test/browser/ui.html
@@ -0,0 +1,46 @@
+<html>
+ <head>
+ <title>Mocha</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <meta name="viewport" content="width=device-width, initial-sca... | html reporter link to specific test is broken on some special characters
If the test title contains some special characters (for instance $ or () ) then its link in the HTML report does not work.
IMO the fix should be escaping regex [here](https://github.com/mochajs/mocha/blob/908d8dbe15b5ef5f4a5658f6cc870bf563e80717/... | I can reproduce the bug.
Digging deeper, the issue is caused because the `grep` query string argument is passed verbatim into the `RegExp` constructor, [here](https://github.com/mochajs/mocha/blob/master/support/tail.js):
``` javascript
if (query.grep) mocha.grep(new RegExp(query.grep));
```
Because the grep argumen... | 2015-05-13T06:45:46Z | 2.2 |
mochajs/mocha | 1,337 | mochajs__mocha-1337 | [
"1066"
] | 9b747dba4217baac45eb47aa7303a3dba55c2a9f | diff --git a/lib/runnable.js b/lib/runnable.js
--- a/lib/runnable.js
+++ b/lib/runnable.js
@@ -45,6 +45,7 @@ function Runnable(title, fn) {
this._slow = 75;
this._enableTimeouts = true;
this.timedOut = false;
+ this._trace = new Error('done() called multiple times')
}
/**
@@ -190,14 +191,14 @@ Runnable.pr... | diff --git a/test/acceptance/multiple.done.js b/test/acceptance/multiple.done.js
--- a/test/acceptance/multiple.done.js
+++ b/test/acceptance/multiple.done.js
@@ -12,4 +12,12 @@ describe('multiple calls to done()', function(){
// done();
});
})
+
+ it('should produce a reasonable trace', function (done)... | Misleading source info in "done() called multiple times" message
The error message "done() called multiple times" will be associated with whatever part of the test suite that's currently running. This can lead to a lot of confusion for the uninitiated developer.
For example, consider the following suite:
``` javascri... | I ran into the same issue. Will be nice mocha can fix this.
+1
Seeing this in version 1.19.0 as well. This does look to be the same issue as #990 but this report has simple code examples that demonstrate the problem. Perhaps @hallas won't dismiss this issue with obstinacy.
For me this turned out to be a library, sa... | 2014-09-05T06:37:26Z | 1.21 |
mochajs/mocha | 1,243 | mochajs__mocha-1243 | [
"1242"
] | fb0447ed60a7b74493746217de0b06d30dafd5bd | diff --git a/lib/runnable.js b/lib/runnable.js
--- a/lib/runnable.js
+++ b/lib/runnable.js
@@ -160,7 +160,6 @@ Runnable.prototype.globals = function(arr){
Runnable.prototype.run = function(fn){
var self = this
- , ms = this.timeout()
, start = new Date
, ctx = this.ctx
, finished
@@ -177,11 +176... | diff --git a/test/acceptance/failing/timeout.js b/test/acceptance/failing/timeout.js
new file mode 100644
--- /dev/null
+++ b/test/acceptance/failing/timeout.js
@@ -0,0 +1,18 @@
+
+describe('timeout', function(){
+ this.timeout(20);
+
+ it('should be honored with sync suites', function(){
+ sleep(30);
+ });
+
+ ... | -t isn't honored for long running sync operations.
I believe the duration should be checked against `_timeout` [here](https://github.com/visionmedia/mocha/blob/master/lib/runnable.js#L183). Thoughts?
Something like:
``` javascript
if(that._timeout < duration)err = new Error('took too long!');
```
| 2014-06-19T06:40:22Z | 1.2 | |
mochajs/mocha | 1,224 | mochajs__mocha-1224 | [
"1191"
] | bc708c17225f60b1c8ceec5c2f77298273bdf297 | diff --git a/lib/runnable.js b/lib/runnable.js
--- a/lib/runnable.js
+++ b/lib/runnable.js
@@ -223,7 +223,13 @@ Runnable.prototype.run = function(fn){
var result = fn.call(ctx);
if (result && typeof result.then === 'function') {
self.resetTimeout();
- result.then(function(){ done() }, done);
+ ... | diff --git a/test/runnable.js b/test/runnable.js
--- a/test/runnable.js
+++ b/test/runnable.js
@@ -299,6 +299,28 @@ describe('Runnable(title, fn)', function(){
})
})
+ describe('when the promise is rejected without a reason', function(){
+ var expectedErr = new Error('Promise rejected with... | Tests succeed on rejected falsey promises
Using Q, one of these two tests fails and the other one succeeds:
```
describe("mocha with promises", function() {
it("should fail on falsey rejected promises", function() {
return q.reject(false);
});
it("should fail on truthy rejected promises", function() {
return ... | 2014-05-22T21:04:36Z | 1.19 | |
mochajs/mocha | 1,110 | mochajs__mocha-1110 | [
"1015"
] | ffaa38d49d10d4a5efd8e8b67db2960c4731cdc3 | diff --git a/lib/runner.js b/lib/runner.js
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -168,10 +168,6 @@ Runner.prototype.checkGlobals = function(test){
ok = ok.concat(test._allowedGlobals || []);
}
- // check length - 2 ('errno' and 'location' globals)
- if (isNode && 1 == ok.length - globals.length) return... | diff --git a/test/runner.js b/test/runner.js
--- a/test/runner.js
+++ b/test/runner.js
@@ -97,6 +97,21 @@ describe('Runner', function(){
runner.checkGlobals('im a test');
})
+ it('should emit "fail" when a single new disallowed global is introduced after a single extra global is allowed', function(done... | How is mocha.globals supposed to work?
Sorry for the terrible issue title :grin:.
When testing a jQuery plugin with Mocha, I'was warned about a global variable leak which [seems to be normal](http://bugs.jquery.com/ticket/14156).
So, I decided to get rid of it using `mocha.globals(["jQuery*"])` and it worked as expec... | 2014-01-13T03:33:27Z | 1.17 | |
mochajs/mocha | 795 | mochajs__mocha-795 | [
"797"
] | 4b05a59ed249095496a29930c975dfccd056e64e | diff --git a/lib/runner.js b/lib/runner.js
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -234,6 +234,8 @@ Runner.prototype.hook = function(name, fn){
if (!hook) return fn();
self.currentRunnable = hook;
+ hook.ctx.currentTest = self.test;
+
self.emit('hook', hook);
hook.on('error', function(err)... | diff --git a/test/hook.async.js b/test/hook.async.js
--- a/test/hook.async.js
+++ b/test/hook.async.js
@@ -13,18 +13,24 @@ describe('async', function(){
, 'before all'
, 'parent before'
, 'before'
+ , 'before test one'
, 'one'
, 'after'
+ , 'after test one passed'
, '... | how to get test data in beforeEach() and afterEach()
I need to get the name of each test in `beforeEach` and the pass/fail status of each finished test in `afterEach`. I looked at using `this.test`, but from there the best thing I found was `this.test.parent`, which is the suite of tests. That's all well and good, but ... | 2013-04-05T12:07:00Z | 1.9 | |
mochajs/mocha | 577 | mochajs__mocha-577 | [
"402"
] | d162c324ec1f077785d6ec282d4abfaff8476335 | diff --git a/lib/context.js b/lib/context.js
--- a/lib/context.js
+++ b/lib/context.js
@@ -40,6 +40,19 @@ Context.prototype.timeout = function(ms){
return this;
};
+/**
+ * Set test slowness threshold `ms`.
+ *
+ * @param {Number} ms
+ * @return {Context} self
+ * @api private
+ */
+
+Context.prototype.slow = fun... | diff --git a/test/runnable.js b/test/runnable.js
--- a/test/runnable.js
+++ b/test/runnable.js
@@ -41,6 +41,14 @@ describe('Runnable(title, fn)', function(){
})
})
+ describe('#slow(ms)', function(){
+ it('should set the slow threshold', function(){
+ var run = new Runnable;
+ run.slow(100)
+ ... | Configure 'slow' property per test
Hi! I'm using mocha in the browser.
Just the same way I can configure a single test 'timeout' threshold:
``` javascript
it('should take less than 500ms', function(done){
this.timeout(500);
setTimeout(done, 300);
});
```
it would be great to configure 'slow' threshold as there m... | +1 from me
Would it make sense to segregate fast and slow tests into separate files/directories and run them separately?
@nanodeath if you wanted to yeah sure, no reason you couldn't. Or you could even keep them in context and "tag" them, something like `it('should do something @slow', callback)` and `--grep @slow` e... | 2012-09-07T18:01:59Z | 1.4 |
mochajs/mocha | 635 | mochajs__mocha-635 | [
"243"
] | 7d488041b618cba0b2c5afcb9d53db09d2f979b3 | diff --git a/lib/reporters/html.js b/lib/reporters/html.js
--- a/lib/reporters/html.js
+++ b/lib/reporters/html.js
@@ -28,7 +28,7 @@ exports = module.exports = HTML;
* Stats template.
*/
-var statsTemplate = '<ul id="stats">'
+var statsTemplate = '<ul id="mocha-stats">'
+ '<li class="progress"><canvas width="4... | diff --git a/test/acceptance/globals.js b/test/acceptance/globals.js
--- a/test/acceptance/globals.js
+++ b/test/acceptance/globals.js
@@ -27,7 +27,13 @@ describe('global leaks', function(){
it('should pass with wildcard', function(){
global.callback123 = 'foo';
global.callback345 = 'bar';
- })
+ });
+
+... | Opera reports 1 failure when actually everything passed
I have a test case that has exactly 41 tests and while testing in node or Chrome/Safari/Firefox everything works great except in Opera.
It says:
```
passes: 41
failures: 1
duration: 0.21s
```
In chrome (for example) it says:
```
passes: 41
failures: 0
duration... | +1, same issue in paulmillr/es6-shim
+1, same issue in Chrome on one of my projects. I find it occurs after the very first test operation, incrementing both the passes and failures by one, no matter what the first test operation is.
hmm interesting I'll take a look
k yeah i get the same, nice that opera finally has... | 2012-11-02T01:08:56Z | 1.6 |
mochajs/mocha | 368 | mochajs__mocha-368 | [
"124",
"166"
] | 10471eb988f66da2f4eb9ef516d2ecdafc9c98ab | diff --git a/lib/runner.js b/lib/runner.js
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -53,7 +53,8 @@ function Runner(suite) {
Runner.prototype.__proto__ = EventEmitter.prototype;
/**
- * Run tests with full titles matching `re`.
+ * Run tests with full titles matching `re`. Updates runner.total
+ * with number of t... | diff --git a/test/runner.js b/test/runner.js
--- a/test/runner.js
+++ b/test/runner.js
@@ -1,7 +1,8 @@
var mocha = require('../')
, Suite = mocha.Suite
- , Runner = mocha.Runner;
+ , Runner = mocha.Runner
+ , Test = mocha.Test;
describe('Runner', function(){
var suite, runner;
@@ -11,6 +12,27 @@ describe... | total should adjust for --grep
when grepping don't display the empty suites
| It looks like this might already be fixed in 1.0.1. I testing on websocket.io's test and the total (3 instead of 17) was displayed correctly.
```
$ mocha --grep fire -R spec
websocket server
connections
✓ must fire a connection event
✓ must fire a close event when client closes
✓ must fire a cl... | 2012-04-09T21:47:25Z | 1 |
mochajs/mocha | 462 | mochajs__mocha-462 | [
"396"
] | 5ef889459242d00bddcfe33cb746c2491c91ebd2 | diff --git a/lib/interfaces/bdd.js b/lib/interfaces/bdd.js
--- a/lib/interfaces/bdd.js
+++ b/lib/interfaces/bdd.js
@@ -84,7 +84,7 @@ module.exports = function(suite){
* acting as a thunk.
*/
- context.it = function(title, fn){
+ context.it = context.specify = function(title, fn){
suites[0].ad... | diff --git a/test/acceptance/interfaces/bdd.js b/test/acceptance/interfaces/bdd.js
--- a/test/acceptance/interfaces/bdd.js
+++ b/test/acceptance/interfaces/bdd.js
@@ -22,4 +22,14 @@ describe('Array', function(){
arr.should.eql([1,2]);
})
})
-})
\ No newline at end of file
+})
+
+context('Array', function... | Add `specify` as a synonym for `it` in BDD interface
Apparently this is in RSpec, as per <a href="http://codebetter.com/jameskovacs/2012/04/19/ruby-and-rspec-powerful-languages-allow-simpler-frameworks/">a blog post I read</a>. It does seem nice in some cases. Yes/no?
| doesn't matter much to me, i dont dislike it but having two functions for the same thing could get kinda lame if your team starts mixing them. anyone else? +1, -1?
Yeah I'm happy to let this simmer until someone who really wants it comes along; no strong feelings. I've run into a few cases where it might make sense bu... | 2012-06-14T16:07:29Z | 1.1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.