MCPcopy Index your code
hub / github.com/webpack/sass-loader / spyOnCompiler

Function spyOnCompiler

test/implementation-option.test.js:136–160  ·  view source on GitHub ↗
(implementation)

Source from the content-addressed store, hash-verified

134 * @returns {EXPECTED_ANY} spies bag
135 */
136const spyOnCompiler = (implementation) => {
137 const actualFn = implementation.initAsyncCompiler.bind(implementation);
138
139 const initSpy = mock.method(implementation, "initAsyncCompiler", async () => {
140 const compiler = await actualFn();
141 // eslint-disable-next-line no-use-before-define
142 spies.compileStringSpy = mock.method(compiler, "compileStringAsync");
143 return compiler;
144 });
145
146 const spies = {
147 initSpy,
148 mockClear() {
149 if (this.compileStringSpy) {
150 this.compileStringSpy.mock.resetCalls();
151 }
152 },
153 mockRestore() {
154 initSpy.mock.restore();
155 delete this.compileStringSpy;
156 },
157 };
158
159 return spies;
160};
161
162describe("implementation option", () => {
163 const dartSassSpyModernAPI = mock.method(sass, "compileStringAsync");

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…