Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f509078020 | ||
|
|
ff237f4b66 | ||
|
|
e42e3d9e00 | ||
|
|
166e5f4d6c | ||
|
|
6ad8d20694 | ||
|
|
bc3a495160 | ||
|
|
b323631611 | ||
|
|
e8767ba660 | ||
|
|
169a2a8ad2 | ||
|
|
b267029301 | ||
|
|
cf574634b8 | ||
|
|
f8c01574e6 |
47
.github/ISSUE_TEMPLATE.md
vendored
47
.github/ISSUE_TEMPLATE.md
vendored
@@ -1,47 +0,0 @@
|
||||
## Are you creating an issue in the correct repository?
|
||||
|
||||
- When in doubt, create an issue here.
|
||||
- If you have an issue with the Jasmine docs, file an issue in the docs repo
|
||||
here: https://github.com/jasmine/jasmine.github.io
|
||||
- If you have an issue with TypeScript typings, start a discussion at
|
||||
[DefinitelyTpyed](https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/new?category=issues-with-a-types-package)
|
||||
- This repository is for the core Jasmine framework
|
||||
- If you are using a test runner that wraps Jasmine, consider filing an issue with that library if appropriate:
|
||||
- [Jasmine npm](https://github.com/jasmine/jasmine-npm/issues)
|
||||
- [Jasmine browser runner](https://github.com/jasmine/jasmine-browser/issues)
|
||||
- [Jasmine gem](https://github.com/jasmine/jasmine-gem/issues)
|
||||
- [Jasmine py](https://github.com/jasmine/jasmine-py/issues)
|
||||
- [Gulp Jasmine Browser](https://github.com/jasmine/gulp-jasmine-browser/issues)
|
||||
- [Karma](https://github.com/karma-runner/karma/issues)
|
||||
- [Grunt Contrib Jasmine](https://github.com/gruntjs/grunt-contrib-jasmine/issues)
|
||||
|
||||
<!--- Provide a general summary of the issue in the Title above -->
|
||||
|
||||
## Expected Behavior
|
||||
<!--- If you're describing a bug, tell us what should happen -->
|
||||
<!--- If you're suggesting a change/improvement, tell us how it should work -->
|
||||
|
||||
## Current Behavior
|
||||
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
|
||||
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
|
||||
|
||||
## Possible Solution
|
||||
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
|
||||
<!--- or ideas how to implement the addition or change -->
|
||||
|
||||
## Suite that reproduces the behavior (for bugs)
|
||||
<!--- Provide a sample suite that reproduces the bug. -->
|
||||
```javascript
|
||||
describe("sample", function() {
|
||||
});
|
||||
```
|
||||
## Context
|
||||
<!--- How has this issue affected you? What are you trying to accomplish? -->
|
||||
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
|
||||
|
||||
## Your Environment
|
||||
<!--- Include as many relevant details about the environment you experienced the bug in -->
|
||||
* Version used:
|
||||
* Environment name and version (e.g. Chrome 39, node.js 5.4):
|
||||
* Operating System and version (desktop or mobile):
|
||||
* Link to your project:
|
||||
98
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
98
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
name: Bug Report
|
||||
description: I think I've found a bug in Jasmine
|
||||
labels: ["unconfirmed bug"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to report a bug. Please follow these steps first.
|
||||
|
||||
## Troubleshooting
|
||||
Please take the time to rule out issues with your code or third party libraries before filing a bug report. If you are reporting an error, try to determine whether the error is coming from Jasmine, another library, or your own code.
|
||||
|
||||
Check the [FAQ](https://jasmine.github.io/pages/faq.html) and any other relevant [documentation](https://jasmine.github.io/pages/docs_home.html) to see if your issue has already been addressed.
|
||||
|
||||
## Special troubleshooting steps for asynchronous scenarios
|
||||
If the issue has to do with testing asynchronous code, please read the [async tutorial](https://jasmine.github.io/tutorials/async) and the async section of the FAQ. In particular, check for the following common errors:
|
||||
|
||||
* Are you trying to write a synchronous test for asynchronous code?
|
||||
* Does the test signal completion before the code under test finishes?
|
||||
* Do expectations run before the code that they're trying to verify?
|
||||
|
||||
## Try the latest version of Jasmine
|
||||
If at all possible, upgrade to the latest versions of `jasmine-core` and any other relevant packages (e.g. `jasmine`, `jasmine-browser-runner`). If you can't do that, please check the [release notes](https://github.com/jasmine/jasmine/tree/main/release_notes) for all newer versions to make sure that the bug hasn't already been fixed.
|
||||
|
||||
## Put together a [minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example)
|
||||
Please help us help you by creating a minimal but complete setup that demonstrates the problem. Remove any code and libraries that aren't absolutely necessary, but make sure it doesn't depend on any code you haven't included. In many cases a simple code snippet is enough. In cases involving external libraries, *especially* Karma or Angular, we're likely to need a runable Git repository or jsbin/stackblitz/etc.
|
||||
|
||||
**If we can't reproduce it, we can't fix it. Bug reports without a minimal, reproducible example are very likely to be closed.**
|
||||
|
||||
- type: textarea
|
||||
id: steps-to-reproduce
|
||||
attributes:
|
||||
label: Steps to Reproduce
|
||||
placeholder: |
|
||||
Example steps:
|
||||
1. Paste the example code below into `mySpec.js`.
|
||||
2. Run `npx jasmine@<some version> mySpec.js`
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected-behavior
|
||||
attributes:
|
||||
label: Expected Behavior
|
||||
description: What do you think should have happened?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: actual-behavior
|
||||
attributes:
|
||||
label: Actual Behavior
|
||||
description: What happened instead?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: code-sample
|
||||
attributes:
|
||||
label: Example code that reproduces the problem
|
||||
description: Please include either a code snippet that reproduces the problem or a link to a repository or jsbin/stackblitz/etc containing a minimal, reproducible example as described above.
|
||||
render: JavaScript
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: possible-solution
|
||||
attributes:
|
||||
label: Possible Solution
|
||||
description: This is optional, but if you have an idea for how to fix the bug we'd like to hear it.
|
||||
- type: textarea
|
||||
id: context
|
||||
attributes:
|
||||
label: Context
|
||||
description: How has this issue affected you? What are you trying to accomplish? By providing context, you can help us come up with a solution that is most useful in the real world.
|
||||
- type: input
|
||||
id: jasmine-core-version
|
||||
attributes:
|
||||
label: jasmine-core version
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: other-versions
|
||||
attributes:
|
||||
label: Versions of other relevant packages
|
||||
placeholder: |
|
||||
jasmine-browser-runner 1.2.0
|
||||
fancy-reporter 132.4.8
|
||||
- type: input
|
||||
id: browser-or-node-version
|
||||
attributes:
|
||||
label: Node.js or browser version
|
||||
placeholder: E.g. "node 16.2.0" or "Safari 15"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: os
|
||||
attributes:
|
||||
label: Operating System
|
||||
placeholder: E.g. "Windows 10", "MacOS 12.5", "MCC Interim Linux 0.99.p8"
|
||||
validations:
|
||||
required: true
|
||||
14
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
14
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Issues with the `jasmine` CLI
|
||||
url: https://github.com/jasmine/jasmine-npm/issues
|
||||
about: Please create issues related to the `jasmine` package in its repository.
|
||||
- name: Issues with jasmine-browser-runner
|
||||
url: https://github.com/jasmine/jasmine-browser-runner/issues
|
||||
about: Please create issues related to the `jasmine-browser-runner` package in its repository.
|
||||
- name: Documentation issues
|
||||
url: https://github.com/jasmine/jasmine.github.io/issues
|
||||
about: Please create documentation issues in the docs repository.
|
||||
- name: TypeScript issues
|
||||
url: https://github.com/DefinitelyTyped/DefinitelyTyped/discussions
|
||||
about: Please create issues related to TypeScript compilation errors or other problems with type definitions at DefinitelyTyped.
|
||||
31
.github/ISSUE_TEMPLATE/feature_proposal.yml
vendored
Normal file
31
.github/ISSUE_TEMPLATE/feature_proposal.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
name: Feature Proposal
|
||||
description: I'd like to propose a new feature
|
||||
labels: ["feature request"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: Thanks for taking the time to propose a new feature. Although Jasmine is mostly feature complete, we're always open to hearing new ideas.
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Feature Proposal
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: context
|
||||
attributes:
|
||||
label: Context
|
||||
description: How would this feature be useful to you? What are you trying to accomplish? By providing context, you can help us come up with a solution that is most useful in the real world.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: example
|
||||
attributes:
|
||||
label: Example
|
||||
description: If you're proposing a new API or something similar, please show an example of how it would be used.
|
||||
render: JavaScript
|
||||
- type: textarea
|
||||
id: other-info
|
||||
attributes:
|
||||
label: Other Information
|
||||
description: Anything else that you think would be helpful.
|
||||
73
.github/ISSUE_TEMPLATE/support_request.yml
vendored
Normal file
73
.github/ISSUE_TEMPLATE/support_request.yml
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
name: Question or Support Request
|
||||
description: I need help using Jasmine
|
||||
labels: ["question"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Jasmine is supported by volunteers working in their free time. Although we're generally willing to help, we're going to ask you to put in some effort first to help us help you.
|
||||
|
||||
## Troubleshooting
|
||||
Please take the time to rule out problems with your code or third party libraries before opening an issue. If you're running into an error, try to determine whether the error is coming from Jasmine, another library, or your own code.
|
||||
|
||||
Check the [FAQ](https://jasmine.github.io/pages/faq.html) and any other relevant [documentation](https://jasmine.github.io/pages/docs_home.html) to see if your question has already been answered. Consider searching [Stack Overflow](https://stackoverflow.com/questions/tagged/jasmine) and past issues in this repository for related questions as well.
|
||||
|
||||
## Special troubleshooting steps for asynchronous scenarios
|
||||
If the issue has to do with testing asynchronous code, please read the [async tutorial](https://jasmine.github.io/tutorials/async) and the async section of the FAQ. In particular, check for the following common errors:
|
||||
|
||||
* Are you trying to write a synchronous test for asynchronous code?
|
||||
* Does the test signal completion before the code under test finishes?
|
||||
* Do expectations run before the code that they're trying to verify?
|
||||
|
||||
## Consider asking Angular questions in an Angular forum
|
||||
|
||||
Questions like "how do I test this Angular service" are mostly about Angular, not Jasmine. You'll likely get better responses in an Angular forum. Here's a rule of thumb: If you can't demonstrate the problem without Angular, you probably have an Angular question.
|
||||
|
||||
## Try the latest version of Jasmine
|
||||
If at all possible, upgrade to the latest versions of `jasmine-core` and any other relevant packages (e.g. `jasmine`, `jasmine-browser-runner`).
|
||||
|
||||
## Put together a [minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example)
|
||||
Please help us help you by creating a minimal but complete setup that demonstrates the problem. Remove any code and libraries that aren't absolutely necessary, but make sure it doesn't depend on any code you haven't included. In many cases a simple code snippet is enough. In cases involving external libraries, *especially* Karma or Angular, we're likely to need a runable Git repository or jsbin/stackblitz/etc.
|
||||
|
||||
- type: textarea
|
||||
id: question
|
||||
attributes:
|
||||
label: Your question
|
||||
description: Clearly describe what you'd like help with.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: code-sample
|
||||
attributes:
|
||||
label: Example code that demonstrates the problem
|
||||
description: Please include either a code snippet that demonstrates the problem or a link to a repository or jsbin/stackblitz/etc containing a minimal, reproducible example as described above.
|
||||
render: JavaScript
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: jasmine-core-version
|
||||
attributes:
|
||||
label: jasmine-core version
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: other-versions
|
||||
attributes:
|
||||
label: Versions of other relevant packages
|
||||
placeholder: |
|
||||
jasmine-browser-runner 1.2.0
|
||||
fancy-reporter 132.4.8
|
||||
- type: input
|
||||
id: browser-or-node-version
|
||||
attributes:
|
||||
label: Node.js or browser version
|
||||
placeholder: E.g. "node 16.2.0" or "Safari 15"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: os
|
||||
attributes:
|
||||
label: Operating System
|
||||
placeholder: E.g. "Windows 10", "MacOS 12.5", "MCC Interim Linux 0.99.p8"
|
||||
validations:
|
||||
required: true
|
||||
@@ -35,7 +35,7 @@ Microsoft Edge) as well as Node.
|
||||
| Node | 12.17+, 14, 16, 18 |
|
||||
| Safari | 14-16 |
|
||||
| Chrome | Evergreen |
|
||||
| Firefox | Evergreen, 91 |
|
||||
| Firefox | Evergreen, 91, 102 |
|
||||
| Edge | Evergreen |
|
||||
|
||||
For evergreen browsers, each version of Jasmine is tested against the version of the browser that is available to us
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2008-2022 Pivotal Labs
|
||||
Copyright (c) 2008-2023 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2008-2022 Pivotal Labs
|
||||
Copyright (c) 2008-2023 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2008-2022 Pivotal Labs
|
||||
Copyright (c) 2008-2023 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2008-2022 Pivotal Labs
|
||||
Copyright (c) 2008-2023 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
@@ -741,6 +741,8 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
|
||||
this.resultCallback = attrs.resultCallback || function() {};
|
||||
this.id = attrs.id;
|
||||
this.filename = attrs.filename;
|
||||
this.parentSuiteId = attrs.parentSuiteId;
|
||||
this.description = attrs.description || '';
|
||||
this.queueableFn = attrs.queueableFn;
|
||||
this.beforeAndAfterFns =
|
||||
@@ -774,35 +776,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
this.exclude();
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef SpecResult
|
||||
* @property {String} id - The unique id of this spec.
|
||||
* @property {String} description - The description passed to the {@link it} that created this spec.
|
||||
* @property {String} fullName - The full description including all ancestors of this spec.
|
||||
* @property {Expectation[]} failedExpectations - The list of expectations that failed during execution of this spec.
|
||||
* @property {Expectation[]} passedExpectations - The list of expectations that passed during execution of this spec.
|
||||
* @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred during execution this spec.
|
||||
* @property {String} pendingReason - If the spec is {@link pending}, this will be the reason.
|
||||
* @property {String} status - Once the spec has completed, this string represents the pass/fail status of this spec.
|
||||
* @property {number} duration - The time in ms used by the spec execution, including any before/afterEach.
|
||||
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSpecProperty}
|
||||
* @property {DebugLogEntry[]|null} debugLogs - Messages, if any, that were logged using {@link jasmine.debugLog} during a failing spec.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
this.result = {
|
||||
id: this.id,
|
||||
description: this.description,
|
||||
fullName: this.getFullName(),
|
||||
failedExpectations: [],
|
||||
passedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
pendingReason: '',
|
||||
duration: null,
|
||||
properties: null,
|
||||
debugLogs: null
|
||||
};
|
||||
|
||||
this.reportedDone = false;
|
||||
this.reset();
|
||||
}
|
||||
|
||||
Spec.prototype.addExpectationResult = function(passed, data, isError) {
|
||||
@@ -912,14 +886,33 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
};
|
||||
|
||||
Spec.prototype.reset = function() {
|
||||
/**
|
||||
* @typedef SpecResult
|
||||
* @property {String} id - The unique id of this spec.
|
||||
* @property {String} description - The description passed to the {@link it} that created this spec.
|
||||
* @property {String} fullName - The full description including all ancestors of this spec.
|
||||
* @property {String|null} parentSuiteId - The ID of the suite containing this spec, or null if this spec is not in a describe().
|
||||
* @property {String} filename - The name of the file the spec was defined in.
|
||||
* @property {Expectation[]} failedExpectations - The list of expectations that failed during execution of this spec.
|
||||
* @property {Expectation[]} passedExpectations - The list of expectations that passed during execution of this spec.
|
||||
* @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred during execution this spec.
|
||||
* @property {String} pendingReason - If the spec is {@link pending}, this will be the reason.
|
||||
* @property {String} status - Once the spec has completed, this string represents the pass/fail status of this spec.
|
||||
* @property {number} duration - The time in ms used by the spec execution, including any before/afterEach.
|
||||
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSpecProperty}
|
||||
* @property {DebugLogEntry[]|null} debugLogs - Messages, if any, that were logged using {@link jasmine.debugLog} during a failing spec.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
this.result = {
|
||||
id: this.id,
|
||||
description: this.description,
|
||||
fullName: this.getFullName(),
|
||||
parentSuiteId: this.parentSuiteId,
|
||||
filename: this.filename,
|
||||
failedExpectations: [],
|
||||
passedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
pendingReason: this.excludeMessage,
|
||||
pendingReason: this.excludeMessage || '',
|
||||
duration: null,
|
||||
properties: null,
|
||||
debugLogs: null
|
||||
@@ -1816,17 +1809,23 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
|
||||
this.describe = function(description, definitionFn) {
|
||||
ensureIsNotNested('describe');
|
||||
return suiteBuilder.describe(description, definitionFn).metadata;
|
||||
const filename = callerCallerFilename();
|
||||
return suiteBuilder.describe(description, definitionFn, filename)
|
||||
.metadata;
|
||||
};
|
||||
|
||||
this.xdescribe = function(description, definitionFn) {
|
||||
ensureIsNotNested('xdescribe');
|
||||
return suiteBuilder.xdescribe(description, definitionFn).metadata;
|
||||
const filename = callerCallerFilename();
|
||||
return suiteBuilder.xdescribe(description, definitionFn, filename)
|
||||
.metadata;
|
||||
};
|
||||
|
||||
this.fdescribe = function(description, definitionFn) {
|
||||
ensureIsNotNested('fdescribe');
|
||||
return suiteBuilder.fdescribe(description, definitionFn).metadata;
|
||||
const filename = callerCallerFilename();
|
||||
return suiteBuilder.fdescribe(description, definitionFn, filename)
|
||||
.metadata;
|
||||
};
|
||||
|
||||
function specResultCallback(spec, result, next) {
|
||||
@@ -1853,17 +1852,20 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
|
||||
this.it = function(description, fn, timeout) {
|
||||
ensureIsNotNested('it');
|
||||
return suiteBuilder.it(description, fn, timeout).metadata;
|
||||
const filename = callerCallerFilename();
|
||||
return suiteBuilder.it(description, fn, timeout, filename).metadata;
|
||||
};
|
||||
|
||||
this.xit = function(description, fn, timeout) {
|
||||
ensureIsNotNested('xit');
|
||||
return suiteBuilder.xit(description, fn, timeout).metadata;
|
||||
const filename = callerCallerFilename();
|
||||
return suiteBuilder.xit(description, fn, timeout, filename).metadata;
|
||||
};
|
||||
|
||||
this.fit = function(description, fn, timeout) {
|
||||
ensureIsNotNested('fit');
|
||||
return suiteBuilder.fit(description, fn, timeout).metadata;
|
||||
const filename = callerCallerFilename();
|
||||
return suiteBuilder.fit(description, fn, timeout, filename).metadata;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -2003,6 +2005,10 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
};
|
||||
}
|
||||
|
||||
function callerCallerFilename() {
|
||||
return new j$.StackTrace(new Error()).frames[3].file;
|
||||
}
|
||||
|
||||
return Env;
|
||||
};
|
||||
|
||||
@@ -9530,6 +9536,8 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
this.id = attrs.id;
|
||||
this.parentSuite = attrs.parentSuite;
|
||||
this.description = attrs.description;
|
||||
this.reportedParentSuiteId = attrs.reportedParentSuiteId;
|
||||
this.filename = attrs.filename;
|
||||
this.expectationFactory = attrs.expectationFactory;
|
||||
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
|
||||
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
|
||||
@@ -9635,6 +9643,8 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
* @property {String} id - The unique id of this suite.
|
||||
* @property {String} description - The description text passed to the {@link describe} that made this suite.
|
||||
* @property {String} fullName - The full description including all ancestors of this suite.
|
||||
* @property {String|null} parentSuiteId - The ID of the suite containing this suite, or null if this is not in another describe().
|
||||
* @property {String} filename - The name of the file the suite was defined in.
|
||||
* @property {Expectation[]} failedExpectations - The list of expectations that failed in an {@link afterAll} for this suite.
|
||||
* @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred on this suite.
|
||||
* @property {String} status - Once the suite has completed, this string represents the pass/fail status of this suite.
|
||||
@@ -9646,6 +9656,8 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
id: this.id,
|
||||
description: this.description,
|
||||
fullName: this.getFullName(),
|
||||
parentSuiteId: this.reportedParentSuiteId,
|
||||
filename: this.filename,
|
||||
failedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
duration: null,
|
||||
@@ -9873,9 +9885,9 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
this.focusedRunables = [];
|
||||
}
|
||||
|
||||
describe(description, definitionFn) {
|
||||
describe(description, definitionFn, filename) {
|
||||
ensureIsFunction(definitionFn, 'describe');
|
||||
const suite = this.suiteFactory_(description);
|
||||
const suite = this.suiteFactory_(description, filename);
|
||||
if (definitionFn.length > 0) {
|
||||
throw new Error('describe does not expect any arguments');
|
||||
}
|
||||
@@ -9886,9 +9898,9 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
return suite;
|
||||
}
|
||||
|
||||
fdescribe(description, definitionFn) {
|
||||
fdescribe(description, definitionFn, filename) {
|
||||
ensureIsFunction(definitionFn, 'fdescribe');
|
||||
const suite = this.suiteFactory_(description);
|
||||
const suite = this.suiteFactory_(description, filename);
|
||||
suite.isFocused = true;
|
||||
|
||||
this.focusedRunables.push(suite.id);
|
||||
@@ -9898,37 +9910,37 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
return suite;
|
||||
}
|
||||
|
||||
xdescribe(description, definitionFn) {
|
||||
xdescribe(description, definitionFn, filename) {
|
||||
ensureIsFunction(definitionFn, 'xdescribe');
|
||||
const suite = this.suiteFactory_(description);
|
||||
const suite = this.suiteFactory_(description, filename);
|
||||
suite.exclude();
|
||||
this.addSpecsToSuite_(suite, definitionFn);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
||||
it(description, fn, timeout) {
|
||||
it(description, fn, timeout, filename) {
|
||||
// it() sometimes doesn't have a fn argument, so only check the type if
|
||||
// it's given.
|
||||
if (arguments.length > 1 && typeof fn !== 'undefined') {
|
||||
ensureIsFunctionOrAsync(fn, 'it');
|
||||
}
|
||||
|
||||
return this.it_(description, fn, timeout);
|
||||
return this.it_(description, fn, timeout, filename);
|
||||
}
|
||||
|
||||
xit(description, fn, timeout) {
|
||||
xit(description, fn, timeout, filename) {
|
||||
// xit(), like it(), doesn't always have a fn argument, so only check the
|
||||
// type when needed.
|
||||
if (arguments.length > 1 && typeof fn !== 'undefined') {
|
||||
ensureIsFunctionOrAsync(fn, 'xit');
|
||||
}
|
||||
const spec = this.it_(description, fn, timeout);
|
||||
const spec = this.it_(description, fn, timeout, filename);
|
||||
spec.exclude('Temporarily disabled with xit');
|
||||
return spec;
|
||||
}
|
||||
|
||||
fit(description, fn, timeout) {
|
||||
fit(description, fn, timeout, filename) {
|
||||
// Unlike it and xit, the function is required because it doesn't make
|
||||
// sense to focus on nothing.
|
||||
ensureIsFunctionOrAsync(fn, 'fit');
|
||||
@@ -9936,7 +9948,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
if (timeout) {
|
||||
j$.util.validateTimeout(timeout);
|
||||
}
|
||||
const spec = this.specFactory_(description, fn, timeout);
|
||||
const spec = this.specFactory_(description, fn, timeout, filename);
|
||||
this.currentDeclarationSuite_.addChild(spec);
|
||||
this.focusedRunables.push(spec.id);
|
||||
this.unfocusAncestor_();
|
||||
@@ -9996,12 +10008,12 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
});
|
||||
}
|
||||
|
||||
it_(description, fn, timeout) {
|
||||
it_(description, fn, timeout, filename) {
|
||||
if (timeout) {
|
||||
j$.util.validateTimeout(timeout);
|
||||
}
|
||||
|
||||
const spec = this.specFactory_(description, fn, timeout);
|
||||
const spec = this.specFactory_(description, fn, timeout, filename);
|
||||
if (this.currentDeclarationSuite_.markedExcluding) {
|
||||
spec.exclude();
|
||||
}
|
||||
@@ -10010,12 +10022,17 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
return spec;
|
||||
}
|
||||
|
||||
suiteFactory_(description) {
|
||||
suiteFactory_(description, filename) {
|
||||
const config = this.env_.configuration();
|
||||
const parentSuite = this.currentDeclarationSuite_;
|
||||
const reportedParentSuiteId =
|
||||
parentSuite === this.topSuite ? null : parentSuite.id;
|
||||
return new j$.Suite({
|
||||
id: 'suite' + this.nextSuiteId_++,
|
||||
description,
|
||||
parentSuite: this.currentDeclarationSuite_,
|
||||
filename,
|
||||
parentSuite,
|
||||
reportedParentSuiteId,
|
||||
timer: new j$.Timer(),
|
||||
expectationFactory: this.expectationFactory_,
|
||||
asyncExpectationFactory: this.suiteAsyncExpectationFactory_,
|
||||
@@ -10047,12 +10064,15 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
this.currentDeclarationSuite_ = parentSuite;
|
||||
}
|
||||
|
||||
specFactory_(description, fn, timeout) {
|
||||
specFactory_(description, fn, timeout, filename) {
|
||||
this.totalSpecsDefined++;
|
||||
const config = this.env_.configuration();
|
||||
const suite = this.currentDeclarationSuite_;
|
||||
const parentSuiteId = suite === this.topSuite ? null : suite.id;
|
||||
const spec = new j$.Spec({
|
||||
id: 'spec' + this.nextSpecId_++,
|
||||
filename,
|
||||
parentSuiteId,
|
||||
beforeAndAfterFns: beforeAndAfterFns(suite),
|
||||
expectationFactory: this.expectationFactory_,
|
||||
asyncExpectationFactory: this.specAsyncExpectationFactory_,
|
||||
@@ -10464,5 +10484,5 @@ getJasmineRequireObj().UserContext = function(j$) {
|
||||
};
|
||||
|
||||
getJasmineRequireObj().version = function() {
|
||||
return '4.4.0';
|
||||
return '4.6.0';
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2008-2022 Pivotal Labs
|
||||
Copyright (c) 2008-2023 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jasmine-core",
|
||||
"license": "MIT",
|
||||
"version": "4.5.0",
|
||||
"version": "4.6.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jasmine/jasmine.git"
|
||||
@@ -35,9 +35,9 @@
|
||||
],
|
||||
"devDependencies": {
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-plugin-compat": "^4.0.0",
|
||||
"eslint-plugin-compat": ">=4.0.0 <4.1.0",
|
||||
"glob": "^7.2.0",
|
||||
"grunt": "^1.0.4",
|
||||
"grunt": ">=1.0.4 <1.6.0",
|
||||
"grunt-cli": "^1.3.2",
|
||||
"grunt-contrib-compress": "^2.0.0",
|
||||
"grunt-contrib-concat": "^2.0.0",
|
||||
@@ -48,7 +48,7 @@
|
||||
"jsdom": "^19.0.0",
|
||||
"load-grunt-tasks": "^5.1.0",
|
||||
"prettier": "1.17.1",
|
||||
"sass": "^1.45.1",
|
||||
"sass": "1.58.3",
|
||||
"shelljs": "^0.8.3",
|
||||
"temp": "^0.9.0"
|
||||
},
|
||||
|
||||
19
release_notes/4.6.0.md
Normal file
19
release_notes/4.6.0.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Jasmine Core 4.6.0 Release Notes
|
||||
|
||||
## New Features
|
||||
|
||||
* Report the ID of each suite/spec's parent
|
||||
* Report the path/url of the file that the spec/suite was defined in
|
||||
* Fixes [#1884](https://github.com/jasmine/jasmine/issues/1884)
|
||||
* Added Firefox 102 (current ESR) to supported browsers
|
||||
|
||||
|
||||
## Internal improvements
|
||||
|
||||
* Pinned sass to 1.58.3 for compatibility with Node 12
|
||||
* Pinned eslint-plugin-compat to <4.1.0 for compatibility with Node 12
|
||||
* Pinned Grunt to <1.6.0 for compatibility with Node 12
|
||||
|
||||
------
|
||||
|
||||
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_
|
||||
@@ -195,6 +195,8 @@ describe('Spec', function() {
|
||||
onStart: startCallback,
|
||||
resultCallback: resultCallback,
|
||||
description: 'with a spec',
|
||||
parentSuiteId: 'suite1',
|
||||
filename: 'someSpecFile.js',
|
||||
getSpecName: function() {
|
||||
return 'a suite with a spec';
|
||||
},
|
||||
@@ -219,6 +221,8 @@ describe('Spec', function() {
|
||||
status: 'pending',
|
||||
description: 'with a spec',
|
||||
fullName: 'a suite with a spec',
|
||||
parentSuiteId: 'suite1',
|
||||
filename: 'someSpecFile.js',
|
||||
failedExpectations: [],
|
||||
passedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
|
||||
@@ -1933,11 +1933,17 @@ describe('Env integration', function() {
|
||||
'specStarted',
|
||||
'specDone'
|
||||
]);
|
||||
const suiteFullNameToId = {};
|
||||
reporter.suiteStarted.and.callFake(function(e) {
|
||||
suiteFullNameToId[e.fullName] = e.id;
|
||||
});
|
||||
|
||||
env.addReporter(reporter);
|
||||
|
||||
env.it('a top level spec', function() {});
|
||||
|
||||
env.describe('A Suite', function() {
|
||||
env.it('with a top level spec', function() {
|
||||
env.it('with a spec', function() {
|
||||
env.expect(true).toBe(true);
|
||||
});
|
||||
env.describe('with a nested suite', function() {
|
||||
@@ -1960,37 +1966,109 @@ describe('Env integration', function() {
|
||||
await env.execute();
|
||||
|
||||
expect(reporter.jasmineStarted).toHaveBeenCalledWith({
|
||||
totalSpecsDefined: 5,
|
||||
totalSpecsDefined: 6,
|
||||
order: jasmine.any(jasmineUnderTest.Order)
|
||||
});
|
||||
|
||||
expect(reporter.specDone.calls.count()).toBe(5);
|
||||
expect(reporter.specStarted.calls.count()).toBe(6);
|
||||
expect(reporter.specDone.calls.count()).toBe(6);
|
||||
|
||||
expect(reporter.specDone).toHaveBeenCalledWith(
|
||||
expect(reporter.specStarted).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'with a top level spec',
|
||||
status: 'passed'
|
||||
description: 'a top level spec',
|
||||
parentSuiteId: null
|
||||
})
|
||||
);
|
||||
|
||||
expect(reporter.specDone).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: "with an x'ed spec",
|
||||
status: 'pending'
|
||||
description: 'a top level spec',
|
||||
status: 'passed',
|
||||
parentSuiteId: null
|
||||
})
|
||||
);
|
||||
expect(reporter.specStarted).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'with a spec',
|
||||
parentSuiteId: suiteFullNameToId['A Suite']
|
||||
})
|
||||
);
|
||||
|
||||
expect(reporter.specDone).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'with a spec',
|
||||
status: 'failed'
|
||||
status: 'passed',
|
||||
parentSuiteId: suiteFullNameToId['A Suite']
|
||||
})
|
||||
);
|
||||
|
||||
expect(reporter.specStarted).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: "with an x'ed spec",
|
||||
parentSuiteId: suiteFullNameToId['A Suite with a nested suite']
|
||||
})
|
||||
);
|
||||
expect(reporter.specDone).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: "with an x'ed spec",
|
||||
status: 'pending',
|
||||
parentSuiteId: suiteFullNameToId['A Suite with a nested suite']
|
||||
})
|
||||
);
|
||||
|
||||
expect(reporter.specStarted).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'with a spec',
|
||||
parentSuiteId: suiteFullNameToId['A Suite with a nested suite']
|
||||
})
|
||||
);
|
||||
expect(reporter.specDone).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'with a spec',
|
||||
status: 'failed',
|
||||
parentSuiteId: suiteFullNameToId['A Suite with a nested suite']
|
||||
})
|
||||
);
|
||||
|
||||
expect(reporter.specStarted).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'is pending',
|
||||
parentSuiteId:
|
||||
suiteFullNameToId['A Suite with only non-executable specs']
|
||||
})
|
||||
);
|
||||
expect(reporter.specDone).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'is pending',
|
||||
status: 'pending'
|
||||
status: 'pending',
|
||||
parentSuiteId:
|
||||
suiteFullNameToId['A Suite with only non-executable specs']
|
||||
})
|
||||
);
|
||||
|
||||
expect(reporter.suiteStarted).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'A Suite',
|
||||
parentSuiteId: null
|
||||
})
|
||||
);
|
||||
expect(reporter.suiteDone).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'A Suite',
|
||||
status: 'passed',
|
||||
parentSuiteId: null
|
||||
})
|
||||
);
|
||||
|
||||
expect(reporter.suiteStarted).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'with a nested suite',
|
||||
parentSuiteId: suiteFullNameToId['A Suite']
|
||||
})
|
||||
);
|
||||
expect(reporter.suiteDone).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'with a nested suite',
|
||||
status: 'passed',
|
||||
parentSuiteId: suiteFullNameToId['A Suite']
|
||||
})
|
||||
);
|
||||
|
||||
@@ -2001,6 +2079,89 @@ describe('Env integration', function() {
|
||||
expect(suiteResult.description).toEqual('A Suite');
|
||||
});
|
||||
|
||||
it('reports focused specs and suites as expected', async function() {
|
||||
const reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
'suiteStarted',
|
||||
'suiteDone',
|
||||
'specStarted',
|
||||
'specDone'
|
||||
]);
|
||||
const suiteFullNameToId = {};
|
||||
reporter.suiteStarted.and.callFake(function(e) {
|
||||
suiteFullNameToId[e.fullName] = e.id;
|
||||
});
|
||||
|
||||
env.fit('a focused top level spec', function() {});
|
||||
|
||||
env.describe('a suite', function() {
|
||||
env.fdescribe('a focused suite', function() {
|
||||
env.fit('a focused spec', function() {});
|
||||
});
|
||||
});
|
||||
|
||||
env.addReporter(reporter);
|
||||
await env.execute();
|
||||
|
||||
expect(reporter.specStarted).toHaveBeenCalledTimes(2);
|
||||
expect(reporter.specDone).toHaveBeenCalledTimes(2);
|
||||
|
||||
expect(reporter.specStarted).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'a focused top level spec',
|
||||
parentSuiteId: null
|
||||
})
|
||||
);
|
||||
expect(reporter.specDone).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'a focused top level spec',
|
||||
status: 'passed',
|
||||
parentSuiteId: null
|
||||
})
|
||||
);
|
||||
|
||||
expect(reporter.specStarted).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'a focused spec',
|
||||
parentSuiteId: suiteFullNameToId['a suite a focused suite']
|
||||
})
|
||||
);
|
||||
expect(reporter.specDone).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'a focused spec',
|
||||
status: 'passed',
|
||||
parentSuiteId: suiteFullNameToId['a suite a focused suite']
|
||||
})
|
||||
);
|
||||
|
||||
expect(reporter.suiteStarted).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'a suite',
|
||||
parentSuiteId: null
|
||||
})
|
||||
);
|
||||
expect(reporter.suiteDone).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'a suite',
|
||||
status: 'passed',
|
||||
parentSuiteId: null
|
||||
})
|
||||
);
|
||||
|
||||
expect(reporter.suiteStarted).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'a focused suite',
|
||||
parentSuiteId: suiteFullNameToId['a suite']
|
||||
})
|
||||
);
|
||||
expect(reporter.suiteDone).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
description: 'a focused suite',
|
||||
status: 'passed',
|
||||
parentSuiteId: suiteFullNameToId['a suite']
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('should report the random seed at the beginning and end of execution', async function() {
|
||||
const reporter = jasmine.createSpyObj('fakeReporter', [
|
||||
'jasmineStarted',
|
||||
@@ -4004,6 +4165,99 @@ describe('Env integration', function() {
|
||||
);
|
||||
});
|
||||
|
||||
it('reports suite and spec filenames', async function() {
|
||||
const methods = ['suiteStarted', 'suiteDone', 'specStarted', 'specDone'];
|
||||
const reporter = jasmine.createSpyObj('reporter', methods);
|
||||
env.addReporter(reporter);
|
||||
|
||||
// Simulate calling through global it and describe,
|
||||
// which add another stack frame vs calling env methods directly
|
||||
function describeShim(name, fn) {
|
||||
env.describe(name, fn);
|
||||
}
|
||||
function itShim(name, fn) {
|
||||
env.it(name, fn);
|
||||
}
|
||||
|
||||
describeShim('a suite', function() {
|
||||
itShim('a spec', function() {});
|
||||
});
|
||||
|
||||
await env.execute();
|
||||
|
||||
for (const method of methods) {
|
||||
expect(reporter[method])
|
||||
.withContext(method)
|
||||
.toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
filename: jasmine.stringMatching(/EnvSpec\.js$/)
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it('reports skipped suite and spec filenames', async function() {
|
||||
const methods = ['suiteStarted', 'suiteDone', 'specStarted', 'specDone'];
|
||||
const reporter = jasmine.createSpyObj('reporter', methods);
|
||||
env.addReporter(reporter);
|
||||
|
||||
// Simulate calling through global it and describe,
|
||||
// which add another stack frame vs calling env methods directly
|
||||
function xdescribeShim(name, fn) {
|
||||
env.xdescribe(name, fn);
|
||||
}
|
||||
function xitShim(name, fn) {
|
||||
env.xit(name, fn);
|
||||
}
|
||||
|
||||
xdescribeShim('a suite', function() {
|
||||
xitShim('a spec', function() {});
|
||||
});
|
||||
|
||||
await env.execute();
|
||||
|
||||
for (const method of methods) {
|
||||
expect(reporter[method])
|
||||
.withContext(method)
|
||||
.toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
filename: jasmine.stringMatching(/EnvSpec\.js$/)
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it('reports focused suite and spec filenames', async function() {
|
||||
const methods = ['suiteStarted', 'suiteDone', 'specStarted', 'specDone'];
|
||||
const reporter = jasmine.createSpyObj('reporter', methods);
|
||||
env.addReporter(reporter);
|
||||
|
||||
// Simulate calling through global it and describe,
|
||||
// which add another stack frame vs calling env methods directly
|
||||
function fdescribeShim(name, fn) {
|
||||
env.fdescribe(name, fn);
|
||||
}
|
||||
function fitShim(name, fn) {
|
||||
env.fit(name, fn);
|
||||
}
|
||||
|
||||
fdescribeShim('a suite', function() {
|
||||
fitShim('a spec', function() {});
|
||||
});
|
||||
|
||||
await env.execute();
|
||||
|
||||
for (const method of methods) {
|
||||
expect(reporter[method])
|
||||
.withContext(method)
|
||||
.toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({
|
||||
filename: jasmine.stringMatching(/EnvSpec\.js$/)
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
function browserEventMethods() {
|
||||
return {
|
||||
addEventListener() {},
|
||||
|
||||
@@ -674,17 +674,23 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
|
||||
this.describe = function(description, definitionFn) {
|
||||
ensureIsNotNested('describe');
|
||||
return suiteBuilder.describe(description, definitionFn).metadata;
|
||||
const filename = callerCallerFilename();
|
||||
return suiteBuilder.describe(description, definitionFn, filename)
|
||||
.metadata;
|
||||
};
|
||||
|
||||
this.xdescribe = function(description, definitionFn) {
|
||||
ensureIsNotNested('xdescribe');
|
||||
return suiteBuilder.xdescribe(description, definitionFn).metadata;
|
||||
const filename = callerCallerFilename();
|
||||
return suiteBuilder.xdescribe(description, definitionFn, filename)
|
||||
.metadata;
|
||||
};
|
||||
|
||||
this.fdescribe = function(description, definitionFn) {
|
||||
ensureIsNotNested('fdescribe');
|
||||
return suiteBuilder.fdescribe(description, definitionFn).metadata;
|
||||
const filename = callerCallerFilename();
|
||||
return suiteBuilder.fdescribe(description, definitionFn, filename)
|
||||
.metadata;
|
||||
};
|
||||
|
||||
function specResultCallback(spec, result, next) {
|
||||
@@ -711,17 +717,20 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
|
||||
this.it = function(description, fn, timeout) {
|
||||
ensureIsNotNested('it');
|
||||
return suiteBuilder.it(description, fn, timeout).metadata;
|
||||
const filename = callerCallerFilename();
|
||||
return suiteBuilder.it(description, fn, timeout, filename).metadata;
|
||||
};
|
||||
|
||||
this.xit = function(description, fn, timeout) {
|
||||
ensureIsNotNested('xit');
|
||||
return suiteBuilder.xit(description, fn, timeout).metadata;
|
||||
const filename = callerCallerFilename();
|
||||
return suiteBuilder.xit(description, fn, timeout, filename).metadata;
|
||||
};
|
||||
|
||||
this.fit = function(description, fn, timeout) {
|
||||
ensureIsNotNested('fit');
|
||||
return suiteBuilder.fit(description, fn, timeout).metadata;
|
||||
const filename = callerCallerFilename();
|
||||
return suiteBuilder.fit(description, fn, timeout, filename).metadata;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -861,5 +870,9 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
};
|
||||
}
|
||||
|
||||
function callerCallerFilename() {
|
||||
return new j$.StackTrace(new Error()).frames[3].file;
|
||||
}
|
||||
|
||||
return Env;
|
||||
};
|
||||
|
||||
@@ -4,6 +4,8 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
|
||||
this.resultCallback = attrs.resultCallback || function() {};
|
||||
this.id = attrs.id;
|
||||
this.filename = attrs.filename;
|
||||
this.parentSuiteId = attrs.parentSuiteId;
|
||||
this.description = attrs.description || '';
|
||||
this.queueableFn = attrs.queueableFn;
|
||||
this.beforeAndAfterFns =
|
||||
@@ -37,35 +39,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
this.exclude();
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef SpecResult
|
||||
* @property {String} id - The unique id of this spec.
|
||||
* @property {String} description - The description passed to the {@link it} that created this spec.
|
||||
* @property {String} fullName - The full description including all ancestors of this spec.
|
||||
* @property {Expectation[]} failedExpectations - The list of expectations that failed during execution of this spec.
|
||||
* @property {Expectation[]} passedExpectations - The list of expectations that passed during execution of this spec.
|
||||
* @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred during execution this spec.
|
||||
* @property {String} pendingReason - If the spec is {@link pending}, this will be the reason.
|
||||
* @property {String} status - Once the spec has completed, this string represents the pass/fail status of this spec.
|
||||
* @property {number} duration - The time in ms used by the spec execution, including any before/afterEach.
|
||||
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSpecProperty}
|
||||
* @property {DebugLogEntry[]|null} debugLogs - Messages, if any, that were logged using {@link jasmine.debugLog} during a failing spec.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
this.result = {
|
||||
id: this.id,
|
||||
description: this.description,
|
||||
fullName: this.getFullName(),
|
||||
failedExpectations: [],
|
||||
passedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
pendingReason: '',
|
||||
duration: null,
|
||||
properties: null,
|
||||
debugLogs: null
|
||||
};
|
||||
|
||||
this.reportedDone = false;
|
||||
this.reset();
|
||||
}
|
||||
|
||||
Spec.prototype.addExpectationResult = function(passed, data, isError) {
|
||||
@@ -175,14 +149,33 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
};
|
||||
|
||||
Spec.prototype.reset = function() {
|
||||
/**
|
||||
* @typedef SpecResult
|
||||
* @property {String} id - The unique id of this spec.
|
||||
* @property {String} description - The description passed to the {@link it} that created this spec.
|
||||
* @property {String} fullName - The full description including all ancestors of this spec.
|
||||
* @property {String|null} parentSuiteId - The ID of the suite containing this spec, or null if this spec is not in a describe().
|
||||
* @property {String} filename - The name of the file the spec was defined in.
|
||||
* @property {Expectation[]} failedExpectations - The list of expectations that failed during execution of this spec.
|
||||
* @property {Expectation[]} passedExpectations - The list of expectations that passed during execution of this spec.
|
||||
* @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred during execution this spec.
|
||||
* @property {String} pendingReason - If the spec is {@link pending}, this will be the reason.
|
||||
* @property {String} status - Once the spec has completed, this string represents the pass/fail status of this spec.
|
||||
* @property {number} duration - The time in ms used by the spec execution, including any before/afterEach.
|
||||
* @property {Object} properties - User-supplied properties, if any, that were set using {@link Env#setSpecProperty}
|
||||
* @property {DebugLogEntry[]|null} debugLogs - Messages, if any, that were logged using {@link jasmine.debugLog} during a failing spec.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
this.result = {
|
||||
id: this.id,
|
||||
description: this.description,
|
||||
fullName: this.getFullName(),
|
||||
parentSuiteId: this.parentSuiteId,
|
||||
filename: this.filename,
|
||||
failedExpectations: [],
|
||||
passedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
pendingReason: this.excludeMessage,
|
||||
pendingReason: this.excludeMessage || '',
|
||||
duration: null,
|
||||
properties: null,
|
||||
debugLogs: null
|
||||
|
||||
@@ -4,6 +4,8 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
this.id = attrs.id;
|
||||
this.parentSuite = attrs.parentSuite;
|
||||
this.description = attrs.description;
|
||||
this.reportedParentSuiteId = attrs.reportedParentSuiteId;
|
||||
this.filename = attrs.filename;
|
||||
this.expectationFactory = attrs.expectationFactory;
|
||||
this.asyncExpectationFactory = attrs.asyncExpectationFactory;
|
||||
this.throwOnExpectationFailure = !!attrs.throwOnExpectationFailure;
|
||||
@@ -109,6 +111,8 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
* @property {String} id - The unique id of this suite.
|
||||
* @property {String} description - The description text passed to the {@link describe} that made this suite.
|
||||
* @property {String} fullName - The full description including all ancestors of this suite.
|
||||
* @property {String|null} parentSuiteId - The ID of the suite containing this suite, or null if this is not in another describe().
|
||||
* @property {String} filename - The name of the file the suite was defined in.
|
||||
* @property {Expectation[]} failedExpectations - The list of expectations that failed in an {@link afterAll} for this suite.
|
||||
* @property {Expectation[]} deprecationWarnings - The list of deprecation warnings that occurred on this suite.
|
||||
* @property {String} status - Once the suite has completed, this string represents the pass/fail status of this suite.
|
||||
@@ -120,6 +124,8 @@ getJasmineRequireObj().Suite = function(j$) {
|
||||
id: this.id,
|
||||
description: this.description,
|
||||
fullName: this.getFullName(),
|
||||
parentSuiteId: this.reportedParentSuiteId,
|
||||
filename: this.filename,
|
||||
failedExpectations: [],
|
||||
deprecationWarnings: [],
|
||||
duration: null,
|
||||
|
||||
@@ -22,9 +22,9 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
this.focusedRunables = [];
|
||||
}
|
||||
|
||||
describe(description, definitionFn) {
|
||||
describe(description, definitionFn, filename) {
|
||||
ensureIsFunction(definitionFn, 'describe');
|
||||
const suite = this.suiteFactory_(description);
|
||||
const suite = this.suiteFactory_(description, filename);
|
||||
if (definitionFn.length > 0) {
|
||||
throw new Error('describe does not expect any arguments');
|
||||
}
|
||||
@@ -35,9 +35,9 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
return suite;
|
||||
}
|
||||
|
||||
fdescribe(description, definitionFn) {
|
||||
fdescribe(description, definitionFn, filename) {
|
||||
ensureIsFunction(definitionFn, 'fdescribe');
|
||||
const suite = this.suiteFactory_(description);
|
||||
const suite = this.suiteFactory_(description, filename);
|
||||
suite.isFocused = true;
|
||||
|
||||
this.focusedRunables.push(suite.id);
|
||||
@@ -47,37 +47,37 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
return suite;
|
||||
}
|
||||
|
||||
xdescribe(description, definitionFn) {
|
||||
xdescribe(description, definitionFn, filename) {
|
||||
ensureIsFunction(definitionFn, 'xdescribe');
|
||||
const suite = this.suiteFactory_(description);
|
||||
const suite = this.suiteFactory_(description, filename);
|
||||
suite.exclude();
|
||||
this.addSpecsToSuite_(suite, definitionFn);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
||||
it(description, fn, timeout) {
|
||||
it(description, fn, timeout, filename) {
|
||||
// it() sometimes doesn't have a fn argument, so only check the type if
|
||||
// it's given.
|
||||
if (arguments.length > 1 && typeof fn !== 'undefined') {
|
||||
ensureIsFunctionOrAsync(fn, 'it');
|
||||
}
|
||||
|
||||
return this.it_(description, fn, timeout);
|
||||
return this.it_(description, fn, timeout, filename);
|
||||
}
|
||||
|
||||
xit(description, fn, timeout) {
|
||||
xit(description, fn, timeout, filename) {
|
||||
// xit(), like it(), doesn't always have a fn argument, so only check the
|
||||
// type when needed.
|
||||
if (arguments.length > 1 && typeof fn !== 'undefined') {
|
||||
ensureIsFunctionOrAsync(fn, 'xit');
|
||||
}
|
||||
const spec = this.it_(description, fn, timeout);
|
||||
const spec = this.it_(description, fn, timeout, filename);
|
||||
spec.exclude('Temporarily disabled with xit');
|
||||
return spec;
|
||||
}
|
||||
|
||||
fit(description, fn, timeout) {
|
||||
fit(description, fn, timeout, filename) {
|
||||
// Unlike it and xit, the function is required because it doesn't make
|
||||
// sense to focus on nothing.
|
||||
ensureIsFunctionOrAsync(fn, 'fit');
|
||||
@@ -85,7 +85,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
if (timeout) {
|
||||
j$.util.validateTimeout(timeout);
|
||||
}
|
||||
const spec = this.specFactory_(description, fn, timeout);
|
||||
const spec = this.specFactory_(description, fn, timeout, filename);
|
||||
this.currentDeclarationSuite_.addChild(spec);
|
||||
this.focusedRunables.push(spec.id);
|
||||
this.unfocusAncestor_();
|
||||
@@ -145,12 +145,12 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
});
|
||||
}
|
||||
|
||||
it_(description, fn, timeout) {
|
||||
it_(description, fn, timeout, filename) {
|
||||
if (timeout) {
|
||||
j$.util.validateTimeout(timeout);
|
||||
}
|
||||
|
||||
const spec = this.specFactory_(description, fn, timeout);
|
||||
const spec = this.specFactory_(description, fn, timeout, filename);
|
||||
if (this.currentDeclarationSuite_.markedExcluding) {
|
||||
spec.exclude();
|
||||
}
|
||||
@@ -159,12 +159,17 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
return spec;
|
||||
}
|
||||
|
||||
suiteFactory_(description) {
|
||||
suiteFactory_(description, filename) {
|
||||
const config = this.env_.configuration();
|
||||
const parentSuite = this.currentDeclarationSuite_;
|
||||
const reportedParentSuiteId =
|
||||
parentSuite === this.topSuite ? null : parentSuite.id;
|
||||
return new j$.Suite({
|
||||
id: 'suite' + this.nextSuiteId_++,
|
||||
description,
|
||||
parentSuite: this.currentDeclarationSuite_,
|
||||
filename,
|
||||
parentSuite,
|
||||
reportedParentSuiteId,
|
||||
timer: new j$.Timer(),
|
||||
expectationFactory: this.expectationFactory_,
|
||||
asyncExpectationFactory: this.suiteAsyncExpectationFactory_,
|
||||
@@ -196,12 +201,15 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
this.currentDeclarationSuite_ = parentSuite;
|
||||
}
|
||||
|
||||
specFactory_(description, fn, timeout) {
|
||||
specFactory_(description, fn, timeout, filename) {
|
||||
this.totalSpecsDefined++;
|
||||
const config = this.env_.configuration();
|
||||
const suite = this.currentDeclarationSuite_;
|
||||
const parentSuiteId = suite === this.topSuite ? null : suite.id;
|
||||
const spec = new j$.Spec({
|
||||
id: 'spec' + this.nextSpecId_++,
|
||||
filename,
|
||||
parentSuiteId,
|
||||
beforeAndAfterFns: beforeAndAfterFns(suite),
|
||||
expectationFactory: this.expectationFactory_,
|
||||
asyncExpectationFactory: this.specAsyncExpectationFactory_,
|
||||
|
||||
Reference in New Issue
Block a user