Home
Softono
x

xiphe

Professional software vendor delivering innovative solutions on the Softono platform. Specialized in both open-source and proprietary software development.

Total Products
2

Software by xiphe

test-real-styles
Open Source

test-real-styles

# test-real-styles [![test & release](https://github.com/Xiphe/test-real-styles/actions/workflows/release.yml/badge.svg)](https://github.com/Xiphe/test-real-styles/actions/workflows/release.yml) [![codecov](https://codecov.io/gh/Xiphe/test-real-styles/branch/main/graph/badge.svg?token=LNLZ1IZK6W)](https://codecov.io/gh/Xiphe/test-real-styles) [![npm](https://img.shields.io/npm/v/test-real-styles)](https://www.npmjs.com/package/test-real-styles) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![Love and Peace](http://love-and-peace.github.io/love-and-peace/badges/base/v1.0-small.svg)](https://github.com/love-and-peace/love-and-peace/blob/master/versions/base/v1.0/en.md) (test-)framework agnostic utilities to test real styling of (virtual) dom elements ## Motivation I created this with [jest](https://jestjs.io/) and [testing-library](https://testing-library.com/) in mind to [programmatically test appearance effects of component APIs](https://xiphe.net/blog/testing/component-design-testing.html?rel=test-real-styles) in [real browsers](https://github.com/microsoft/playwright/). While [`@testing-library/jest-dom` has a `toHaveStyle` assertion](https://github.com/testing-library/jest-dom#tohavestyle) and there are [ways to test css-in-js](https://github.com/styled-components/jest-styled-components) all solutions I've tried ignore the [css cascade](https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Cascade_and_inheritance) or use a [buggy/incomplete simulation of it](https://github.com/jsdom/jsdom/labels/css). But real-world components do use the cascade. This library aims to give you confidence that a style is actually active on an element. ## Installation ```bash npm install test-real-styles ``` ## Usage Assuming a [NodeJS](https://nodejs.org/en/) test environment with [jsdom](https://github.com/jsdom/jsdom) like [jest](https://jestjs.io/). ```ts import { getRealStyles, launch, toCss, LaunchedPage } from '../index'; const MY_CSS = ` button { background-color: fuchsia; } button::after { border: 2px solid olive; } button:hover { color: #123456; } button:focus { color: rgba(255, 0, 123, 0.5); } `; describe(`button`, () => { it('is pink', async () => { /** * This will * - launch a headless chromium * - insert the css * - update the page with `doc` * - return getComputedStyle(doc)['backgroundColor'] */ const styles = await getRealStyles({ css: MY_CSS, doc: document.createElement('button'), getStyles: ['backgroundColor'], }); expect(styles).toEqual({ backgroundColor: 'fuchsia' }); }); describe('launch API', () => { /* In case you want to re-use the browser, interact with the page or do stuff before styles are returned */ let launchedPage: LaunchedPage | null = null; beforeAll(() => { launchedPage = launch('webkit', MY_CSS); }); it('gets hover and focus styles', async () => { const { updatePage, hover, focus, getStyles } = launchedPage!; const button = document.createElement('button'); await updatePage(button); await hover(button); const hoverStyles = await getStyles(button, ['color', 'backgroundColor']); await focus(button); const focusStyles = await getStyles(button, ['color']); expect(toCss(hoverStyles)).toMatchInlineSnapshot(` "color: #123456; background-color: fuchsia;" `); expect(focusStyles.color).toBe('rgba(255, 0, 123, 0.5)'); }); it('gets pseudo elements', async () => { const { updatePage, getStyles } = launchedPage!; const button = document.createElement('button'); await updatePage(button); expect( await getStyles(button, ['border'], { pseudoElt: '::after' }), ).toEqual({ border: '2px solid olive' }); }); }); }); ``` ## Examples - [Using Sass or other pre-processors](https://github.com/Xiphe/test-real-styles/blob/main/src/__tests__/sass.spec.tsx) - [Using CSS-Modules, React & TestingLibrary](https://github.com/Xiphe/test-real-styles/blob/main/src/__tests__/testingLibraryReact.spec.tsx) - [Using StyledComponents](https://github.com/Xiphe/test-real-styles/blob/main/src/__tests__/styledComponents.spec.tsx) - [Run test in multiple browsers parallel](https://github.com/Xiphe/test-real-styles/blob/main/src/__tests__/parallel.spec.tsx) ## License > The MIT License > > Copyright (C) 2022 Hannes Diercks > > Permission is hereby granted, free of charge, to any person obtaining a copy of > this software and associated documentation files (the "Software"), to deal in > the Software without restriction, including without limitation the rights to > use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies > of the Software, and to permit persons to whom the Software is furnished to do > so, subject to the following conditions: > > The above copyright notice and this permission notice shall be included in all > copies or substantial portions of the Software. > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS > FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR > COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER > IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN > CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Design & Creative Browser Automation Testing & QA
38 Github Stars
budgetbudget
Open Source

budgetbudget

<div align="center"> <a href="https://budgetbudget.app"> <img width="150" src="https://user-images.githubusercontent.com/911218/102475657-6e7f4180-405a-11eb-9722-06f500fd4492.png" alt="BudgetBudget App Icon" /> </a> </div> <h1 align="center">BudgetBudget</h1> <div align="center"> <a href="https://github.com/Xiphe/budgetbudget/releases"> <img alt="GitHub release (latest SemVer including pre-releases)" src="https://img.shields.io/github/v/release/Xiphe/budgetbudget?include_prereleases"> </a> <a href="https://github.com/Xiphe/budgetbudget/actions?query=workflow%3A%22build+%26+release%22"> <img src="https://github.com/Xiphe/budgetbudget/workflows/build%20&%20release/badge.svg" alt="build & release" /> </a> <a href="https://dashboard.cypress.io/projects/ia745w"> <img alt="Cypress Dashboard" src="https://img.shields.io/badge/cypress-dashboard-00C390.svg"> </a> <a href="https://github.com/semantic-release/semantic-release"> <img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg" alt="semantic-release" /> </a> </div> &nbsp; <div align="center">gain confidence in financial decisions</div> <div align="center">by planning monthly budgets for <a href="https://moneymoney-app.com/">MoneyMoney</a> transactions</div> &nbsp; ## How to use 1. Go to the [BudgetBudget download page](https://budgetbudget.app/download) 2. Download the latest version 3. Open the `.dmg` file in your downloads folder 4. Drag the Application into your Applications folder 5. Start the App 6. Follow the instructions 7. Value 🤑 ## Contributing You're really welcome to submit Pull Requests and Issues. Please keep in mind that i'm building this app in my free time and don't plan to monetize it. That means all help is really welcome but it might take some time for me to respond to issues or review PRs. ### Run the app in development mode All of the following assume that you're working on a recent version of MacOS and have [NodeJS](https://nodejs.org/) installed. Run the following in your terminal: ```sh # check out the source-code git clone [email protected]:Xiphe/budgetbudget.git cd budgetbudget # install dependencies npm install # start the app in development mode npm start ``` ## Screenshot <img width="941" alt="screenshot_1" src="https://github.com/Xiphe/budgetbudget/assets/7121202/415ef68a-6982-4183-bb04-8840727b9c4d"> ## License BudgetBudget - work with monthly budgets alongside moneymoney Copyright (C) 2020 Hannes Diercks This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Productivity Budget & Expense Tracking Personal Finance
108 Github Stars