Reading some Rust code examples in documentation and blogs, I can see the use of Box<T> declaration. Like:
structSchema { commands:Vec<Box<dynMigration>>,}
structSchema { commands:Vec<Box<dynMigration>>,}
According to the official Rust documentation: "All values in Rust are stack allocated by default. Values can be boxed (allocated on the heap) by creating a Box<T>. A box is a smart pointer to a heap allocated value of type T. When a box goes out of scope, its destructor is called, the inner object is destroyed, and the memory on the heap is freed."
When we run a node script, we can see incovenie warnings like:
(node:3174) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.(Use `node --trace-deprecation ...` to show where the warning was created)
(node:3174) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.(Use `node --trace-deprecation ...` to show where the warning was created)
For disable this warnings, just pass NODE_NO_WARNINGS=1 as environment variable before node command or script, e.g.:
NODE_NO_WARNINGS=1 node index.js
NODE_NO_WARNINGS=1 node index.js
On package.json script:
// ..."script": {"test": "NODE_NO_WARNINGS=1 jest --watch" }// ...
// ..."script": {"test": "NODE_NO_WARNINGS=1 jest --watch" }// ...
Position Sticky
Use position sticky with tailwindcss
tailwindcsscssui
We can use sticky class when using tailwind to make an element fixed on screen while the parent element is visible.
Sometimes you are testing a component and need to mock a module (in this case I needed to mock a zustand store), but with the exemple of "next/navigation" mock, you are mocking the module for entire test suit on the file that you declare the jest.mock(). But, if you want to mock a specific implementation for each test? So first, with need to declare the module mock, without pass the implementation function:
jest.mock('../../stores/sounds-state-store')
jest.mock('../../stores/sounds-state-store')
In this case we are mocking "../../stores/sounds-state-store" module
And, inside each test, we will use the jest.Mock.mockImplementation() function to mock the implementation of module inside it/test scope:
the store we want to mock is useSoundsStateStore, from '../../stores/sounds-state-store'
When you try to test a component or hook that uses some function from "next/navigation" module (like useRouter, useSearchParams, useSearchParams, etc.), you may come across the error:
● Test suite failed to run invariant expected app router to be mounted 5 | 6 | export default function useQueryState(key: string, defaultValue: string = '') { > 7 | const router = useRouter() | ^ 8 | const searchParams = useSearchParams() 9 | const pathname = usePathname() 10 |
● Test suite failed to run invariant expected app router to be mounted 5 | 6 | export default function useQueryState(key: string, defaultValue: string = '') { > 7 | const router = useRouter() | ^ 8 | const searchParams = useSearchParams() 9 | const pathname = usePathname() 10 |
This happening because the "next/navigation" just works when app router was monted, to solve this, you need to mock the entire module. Put this before all your describes and it/tests: