Content-Length: 324904 | pFad | http://github.com/jorisre/jest-wake-lock-mock

F3 GitHub - jorisre/jest-wake-lock-mock: Mock Screen Wake Lock API `navigator.wakeLock` with ease and run your tests using Jest
Skip to content

Mock Screen Wake Lock API `navigator.wakeLock` with ease and run your tests using Jest

License

Notifications You must be signed in to change notification settings

jorisre/jest-wake-lock-mock

Repository files navigation

Welcome to jest-wake-lock-mock 👋

npm GitHub Workflow Status Codecov License: MIT Twitter: _jorisre

Mock Screen Wake Lock API (navigator.wakeLock) with ease and run your tests using Jest

Prerequisites

  • node >=10

Install

npm i -D jest-wake-lock-mock
# or
yarn add -D jest-wake-lock-mock

Usage

In your jest.config.js or package.json under jest section create a setupFiles array and add jest-wake-lock-mock to it.

{
  setupFiles: ['jest-wake-lock-mock'],
  // jest config...
}

Tests

Write your tests with confidence using the same Screen Wake Lock API api as in the browser.

Example (More):

const requestWakeLock = async () => {
  try {
    const wakeLock = await navigator.wakeLock.request('screen');

    return { wakeLock };
  } catch (error) {
    return { error };
  }
};

test('wakeLock request with success', async () => {
  const { wakeLock, error } = await requestWakeLock(handleRelease);

  expect(error).not.toBeDefined();
  expect(wakeLock).toBeDefined();
  expect(wakeLock?.type).toEqual('screen');
  expect(wakeLock?.released).toBe(false);
});

Author

👤 Joris

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2020 Joris.
This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator

About

Mock Screen Wake Lock API `navigator.wakeLock` with ease and run your tests using Jest

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/jorisre/jest-wake-lock-mock

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy