16,011 questions
-1
votes
0
answers
27
views
Mock React component with Jest [closed]
I have a problematic component that Jest cannot parse, so I want to mock it, but nothing I do seems to work at all. I've tried mocking other components that work just fine and I can't mock them either....
0
votes
0
answers
54
views
How to "Don't Mock Things You Dont Own" with JDBC
This is a question about "testing patterns". How to "Don't Mock Things You Dont Own" with JDBC?
I tried to Proof Of Concept a JDBC Adapter in the below link, and after trying a ...
-1
votes
0
answers
38
views
when to use vi.hoisted
I got two difference cases when using vitest to write mocks:
case 1:
const mockedMethod = vi.fn();
vi.mock('./path/to/module.js', () => ({
originalMethod: mockedMethod,
}));
case 2:
const ...
1
vote
1
answer
35
views
Flutter Mocktail : <type 'Future<PermissionStatus>' is not a subtype of type 'Permissions'>
I'm trying to mock the background_downloader package , specifically this line in my class I'm trying to mock:
var status = await fileDownloader.permissions.status(permissionType);
I keep getting error ...
0
votes
0
answers
50
views
Error Value of type Boolean incompatible with return type int
I am using:
junit 4.12
jmockit 1.54
Adopt JDK 21
Test case:
@Test(expected = Exception.class)
public void testCreateWareshousesNonSupplierDebugModeFalseException(@Mocked Iterator itr,
...
0
votes
0
answers
34
views
Mocking an embedded Jetty server request with test body content
I'm using the delightful Jetty org.eclipse.jetty:jetty-server:12.0.18 for an embedded HTTP server (not using Java EE servlets). Jetty passes an org.eclipse.jetty.server.Request to a custom handler, ...
0
votes
1
answer
41
views
Is it possible to mock out a character device file in userspace?
I have a user space application that opens a Linux device file handle (e.g., /dev/foobar) and then sends ioctls to it.
I need to replicate a specific series of answers from the device delivered back ...
0
votes
1
answer
26
views
mockk/spyk on WebView in instrumented tests
My app uses Jetpack Compose and includes a WebView.
I want to use Mockk (or something like that) in instrumented tests,
for example, I want my tests to check that
WHEN webView.canGoBack() THEN the ...
0
votes
1
answer
65
views
How to mock functions in streamlit unit tests?
I have a streamlit app, for which I'd like to create unit tests. I am unable to mock objects though.
I have a foo.py with the following content:
import streamlit as st
def dialog_func():
result = ...
0
votes
0
answers
18
views
ZKTeco MA300 Connection Issues: ECONNRESET on Node.js TCP Server
I'm developing a Node.js application to communicate with a ZKTeco MA300 biometric device over TCP. I'm running a mock server to test the connection, but I'm facing an issue where the connection gets ...
0
votes
0
answers
63
views
RSpec -- re-evaluate allow .and_yield when mocked method is called
In this code, sync_external accepts an array of posts and modifies it by calling a sync method from an external module ExternalService, which is mocked in the test.
Assume there's some reason to pass ...
2
votes
2
answers
107
views
Create std::filesystem::directory_entry without backing files for testing
I have some code iterating over files using std::filesystem. I am using dependency injection to mock out the directory_iterator logic, but I have trouble constructing a mocked directory_entry, which ...
0
votes
0
answers
32
views
Using explicit mocks for Typer CLI tests
I want to write unit-tests for a Typer based CLI, that will run the CLI with different inputs and validate correct argument parsing and input validation.
The point isn't to test Typer itself, but ...
0
votes
0
answers
21
views
ViTest Mock is not replacing function
For some reason in ViTest mocks are not replacing my real function. I have a main function here
const { handler1 } = require(./path/handler1)
exports.mainFunction = async (event) => {
try {
...
0
votes
0
answers
28
views
Looking for examples of how to unit test GraphQL resolvers?
I have a graphQL resolver that looks like this:
import { GraphQLSchema } from 'graphql';
import { buildSubgraphSchema } from '@apollo/subgraph';
...
const schema: GraphQLSchema = buildSubgraphSchema(...