1.0.0 • Published 2 years ago

playwright-i18next-fixture v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Build Status Code Style Package Version MIT License

🚀 Use case

🌱 Installation

# Yarn
yarn add --dev playwright-i18next-fixture

# PNPM
pnpm add --D playwright-i18next-fixture

# NPM
npm install --save-dev playwright-i18next-fixture

📝 Usage

Create the i18next instance as you would in your browser

import { test as base } from "@playwright/test";
import { createI18nFixture, getI18nInstance } from "playwright-i18next-fixture";

const i18nFixture = createI18nFixture({
  // i18n plugins
  plugins: [ ... ]
  // i18n configuration options
  options: {
    lng: 'en',
    resources: { ... }
  },
  // Fetch translations in every test or fetch once
  // Default: true
  cache: false
  // Run as auto fixture to be available through all tests by getI18nInstance()
  // Default: true
  auto: true
})

const test = base.extend(i18nFixture);

// Context is now shared
test("my test", async ({ i18n, t }) => {});

// If auto is enabled, you can also use the manual fn
// This is useful to inject directly in classes
class ExampleClass {
   readonly i18n: i18n = getI18nInstance()
}

LICENSE

MIT