Forem

Manjush
Manjush

Posted on • Edited on

TWIL: Highlights from Week 27 2024

This Week I Learned:

1. Mocking imports with vitest

We can mock imports of imports with

vi.mock('pg', () => {
  const Client = vi.fn()
  Client.prototype.connect = vi.fn()
  Client.prototype.query = vi.fn()
  Client.prototype.end = vi.fn()

  return { Client }
})

vi.mock('./handlers.js', () => {
  return {
    success: vi.fn(),
    failure: vi.fn(),
  }
})
Enter fullscreen mode Exit fullscreen mode

2. Making Infinite Scroll keyboard accessible:

If you are using react-infinite-scroll-component and to make it keyboard accessible we can use buttons as child elements.

<InfiniteScroll
    dataLength={items.length}
    next={fetchData}
    hasMore={hasMoreData}
    loader={() => <p>Loading...</p>}
>
    {items.map((item, index) => (
        <div
            id={index}
            key={index}
            onClick={handleClick}
            style={styles}
        >
            <button>
                {childNodeOfScrollList}
            </button>
        </div>
    ))}
</InfiniteScroll>
Enter fullscreen mode Exit fullscreen mode

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay