OfficeDev / OfficeDev/Office-Addin-Scripts
feature request Office-Addin-Mock support CustomFunctions.Error
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 194
- Forks
- 117
- Avg merge
- 1d 32m
- Merged PRs (30d)
- 2
Description
In an excel custom functions add in, I have to add a CustomFunctions.Error function to the global scope before running tests. I am using the following code (which I am not suggesting is sufficient to cover the use cases for the broad range of users) which gives a brief outline of another module which could be useful if added to the Office-Addin-Mock package:
enum ErrorCode {
invalidValue = "#VALUE!",
notAvailable = "#N/A",
divisionByZero = "#DIV/0!",
invalidNumber = "#NUM!",
nullReference = "#NULL!",
invalidName = "#NAME?",
invalidReference = "#REF!",
}
class CustomFunctionError extends Error {
constructor(readonly code: ErrorCode, message?: string) {
super(message);
}
}
const CustomFunctions = {
Error: CustomFunctionError,
ErrorCode: ErrorCode,
associate: () => undefined,
};
and it is used something like (mocha/chai):
describe("myFunction", function () {
global.CustomFunctions = CustomFunctions;
it("throws an error when the string argument is empty", function () {
expect(() => myFunction("", [[["a"]]])).to.throw(/require/i);
'''
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Office-Addin-Mock package and its existing global Office API mocks. Check how similar APIs are represented and add support for CustomFunctions.Error, ErrorCode, and associate as shown in the issue. Done means an add-in test can assign the mock to global.CustomFunctions and exercise error handling without defining it manually.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing-qa, tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100