configureMockStore почему не видит как функицю: import { createStore, applyMiddleware } from "redux";
import { thunk } from "redux-thunk";
import fetchMock from "fetch-mock";
import { loginThunk } from "../actions"; // Adjust the import path
import { loginAction } from "../actions"; // Adjust the import path
import { reducer, userReducer } from "../../reducer";
import { configureStore } from "@reduxjs/toolkit";

// Create a mock store using redux-mock-store
const middleware = [thunk];
const mockStore = configureStore({
  reducer: userReducer,
});
console.log(mockStore);

describe("loginThunk", () => {
  let store;

  beforeEach(() => {
    store = mockStore({});
    fetchMock.restore();
  });

  it("should dispatch loginAction and store user data on successful login", async () => {
    const mockResponse = { username: "admin", token: "1234" };
    fetchMock.post("/api/login", {
      body: mockResponse,
      headers: { "content-type": "application/json" },
      status: 200,
    });

    const expectedActions = [loginAction(mockResponse)];

    const result = await store.dispatch(loginThunk("testuser", "password123"));

    expect(store.getActions()).toEqual(expectedActions);
    expect(localStorage.getItem("user")).toEqual(JSON.stringify(mockResponse));
    expect(result).toEqual({ success: true });
  });

  it("should return error message on failed login", async () => {
    fetchMock.post("/api/login", {
      body: { message: "Invalid credentials" },
      headers: { "content-type": "application/json" },
      status: 401,
    });

    const result = await store.dispatch(
      loginThunk("testuser", "wrongpassword")
    );

    expect(store.getActions()).toEqual([]);
    expect(result).toEqual({ success: false, message: "Invalid credentials" });
  });

  it("should handle network errors", async () => {
    fetchMock.post("/api/login", 500);

    const result = await store.dispatch(loginThunk("testuser", "password123"));

    expect(store.getActions()).toEqual([]);
    expect(result).toEqual({
      success: false,
      message: "TypeError: Failed to fetch",
    });
  });
});


{
  "name": "reactspringcopy",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "proxy": "http://localhost:5000",
  "jest": {
    "transform": {
      "^.+.(js|jsx)$": "babel-jest"
    },
    "testEnvironment": "jsdom",
    "moduleFileExtensions": [
      "js",
      "jsx",
      "json",
      "node"
    ]
  },
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "lint": "eslint .",
    "preview": "vite preview",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d dist",
    "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
  },
  "dependencies": {
    "@reduxjs/toolkit": "^2.2.7",
    "gh-pages": "^6.1.1",
    "jest-environment-jsdom": "^29.7.0",
    "prop-types": "^15.8.1",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "react-redux": "^9.1.2",
    "react-router-dom": "^6.26.2",
    "redux": "^5.0.1"
  },
  "devDependencies": {
    "@babel/preset-env": "^7.25.4",
    "@babel/preset-react": "^7.24.7",
    "@eslint/js": "^9.9.0",
    "@testing-library/jest-dom": "^6.5.0",
    "@testing-library/react": "^16.0.1",
    "@types/react": "^18.3.3",
    "@types/react-dom": "^18.3.0",
    "@vitejs/plugin-react": "^4.3.1",
    "babel-jest": "^29.7.0",
    "eslint": "^9.9.0",
    "eslint-plugin-react": "^7.35.0",
    "eslint-plugin-react-hooks": "^5.1.0-rc.0",
    "eslint-plugin-react-refresh": "^0.4.9",
    "fetch-mock": "^11.1.5",
    "globals": "^15.9.0",
    "jest": "^29.7.0",
    "redux-mock-store": "^1.5.4",
    "redux-thunk": "^3.1.0",
    "sass": "^1.79.2",
    "vite": "^5.4.1",
    "vite-plugin-svgr": "^4.2.0"
  },
  "lint-staged": {
    "*.js": "eslint --fix",
    "*.css": "stylelint --fix",
    "*.json": "prettier --write"
  }
}