OfficeDev / OfficeDev/Office-Addin-Scripts

Office-AddIn-Mock failed to mock getOfficeDisplayLanguage and build a project

Open
#850 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs triage
Dominant language
TypeScript
Stars
194
Forks
117
Avg merge
1d 32m
Merged PRs (30d)
2

Description

Current behavior

I'm trying to mock Office.context.displayLanguage property, but without success. I've got the following error while accessing this property:
"error, property was not loaded". This is an output from console.log. I didn't get which property I should load and how?

And when I try to build project I've got ts2740 error saying that mock object doesn't implement members defined by Office namespace and which ain't used in fact.

Steps to Reproduce

https://codesandbox.io/p/devbox/officemock-rjtz6m?file=%2Fsrc%2FofficeService.test.ts%3A8%2C23

Context

  • Operating System: Windows 11, 22H2 22621.3296
  • Node version: v20.11.1

Just execute npm run test in repro

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox and run npm run test, focusing on src/officeService.test.ts. Reproduce both the displayLanguage loading error and the TS2740 build failure, then inspect the Office-Addin-Mock behavior involved. Done means the property can be mocked and the project builds without requiring unused Office namespace members.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.