Wednesday, January 15, 2020

Monokai: a trip through Japan

Monokai: a trip through Japan
Photos from a journey through Japan in the spring of 2019
by via Awwwards - Sites of the day

Facebook has no Immediate Plans to Implement End-to-End Encryption on Messenger App; Should you move to a Different Platform?

Facebook doesn’t have a positive reputation when it comes to safeguarding user privacy. So last year, when Mark Zuckerberg claimed about securing communications that take place over Facebook’s Messenger service, users of the said App were quite relieved. As per Wired however, it doesn’t look like...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Ali Siddiqui via Digital Information World

Over 50 Organizations Asking Google to Take Action against Android Bloatware

Android operating system always had an issue with bloatware, be it from OEMs or carriers. Recently, around 50 privacy organizations released an open letter on the web, persuading Google to do something about the bloatware on Android OS. An open letter was posted on Privacy International,...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Aqsa Rasool via Digital Information World

Learn End-to-end Testing with Puppeteer

End-to-end Testing with Puppeteer

Puppeteer is a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol. Puppeteer runs headless by default, but can be configured to run full (non-headless) Chrome or Chromium.

In this tutorial, we’ll learn what testing is, the different types of testing, and then we’ll use Puppeteer to perform end-to-end testing on our application. By the end of this tutorial, you should be able to end-to-end test your apps easily with Puppeteer.

Prerequisites

For this tutorial, you need a basic knowledge of JavaScript, ES6+ and Node.js.

You must also have installed the latest version of Node.js.

We’ll be using yarn throughout this tutorial. If you don’t have yarn already installed, install it from here.

You should also know the basics of Puppeteer. To understand the basics of Puppeteer, check out this simple tutorial.

To make sure we’re on the same page, these are the versions used in this tutorial:

  • Node 13.3.0
  • npm 6.13.2
  • yarn 1.21.1
  • puppeteer 2.0.0
  • create-react-app 3.3.0

Introduction to Testing

In simple terms, testing is a process to evaluate the application works as expected. It helps in catching bugs before your application gets deployed.

There are four different types of testing:

  1. Static Testing: uses a static type system like TypeScript, ReasonML, Flow or a linter like ESLint. This helps in capturing basic errors like typos and syntax.
  2. Unit Testing: the smallest part of an application, also known as a unit, is tested.
  3. Integration Testing: multiple related units are tested together to see if the application works perfectly in combination.
  4. End-to-end Testing: the entire application is tested from start to finish, just like a regular user would, to see if it behaves as expected.

The testing trophy by Kent C Dodds is a great visualization of the different types of testing:

Testing Trophy - Kent C Dodds

The testing trophy should be read bottom-to-top. If you perform these four levels of testing, you can be confident enough with the code you ship.

Now let’s perform end-to-end testing with Puppeteer.

End-to-end Testing with Puppeteer

Let's bootstrap a new React project with create-react-app, also known as CRA. Go ahead and type the following in the terminal:

$ npx create-react-app e2e-puppeteer

This will bootstrap a new React project in a e2e-puppeteer folder. Thanks to the latest create-react-app version, this will also install testing-library by default so we can test our applications easily.

Go inside the e2e-puppeteer directory and start the server by typing the following in the terminal:

$ cd e2e-puppeteer
$ yarn start

It should look like this:

React Init

Our App.js looks like this:

import React from 'react';
import logo from './logo.svg';
import './App.css';

function App() {
  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          Edit <code>src/App.js</code> and save to reload.
        </p>
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn React
        </a>
      </header>
    </div>
  );
}

export default App;

We’ll be testing the App.js function and the code will be written in App.test.js. So go ahead and open up App.test.js. It should have the following content:

import React from 'react';
import { render } from '@testing-library/react'; // 1
import App from './App';

test('renders learn react link', () => { // 2
  const { getByText } = render(<App />); // 3
  const linkElement = getByText(/learn react/i); // 4
  expect(linkElement).toBeInTheDocument(); // 5
});

Here's what's happening in the code above:

  1. We import the render function from the @testing-library/react package.
  2. We then use the global test function from Jest, which is our test runner installed by default through CRA. The first parameter is a string which describes our test, and the second parameter is a function where we write the code we want to test.
  3. Next up, we render the App component and destructure a method called getByText, which searches for all elements that have a text node with textContent.
  4. Then, we call the getByText function with the text we want to check. In this case, we check for learn react with the case insensitive flag.
  5. Finally, we make the assertion with the expect function to check if the text exists in the DOM.

This comes by default when we bootstrap with CRA. Go ahead and open up another terminal and type the following:

$ yarn test

When it shows a prompt, type a to run all the tests. You should now see this:

React Init Test

Now let's test this application with end-to-end testing.

Testing the Boilerplate with Puppeteer

Go ahead and install puppeteer as a dev dependency by typing the following in the terminal:

$ yarn add -D puppeteer

Now open up App.test.js and paste the following:

import puppeteer from "puppeteer"; // 1

let browser;
let page;

// 2
beforeAll(async () => {
  browser = await puppeteer.launch({
    headless: false
  });
  page = await browser.newPage();
  await page.goto("http://localhost:3000/");
});

// 3
test("renders learn react link", async () => {
  await page.waitForSelector(".App");

  const header = await page.$eval(".App-header>p", e => e.innerHTML);
  expect(header).toBe(`Edit <code>src/App.js</code> and save to reload.`);

  const link = await page.$eval(".App-header>a", e => {
    return {
      innerHTML: e.innerHTML,
      href: e.href
    };
  });
  expect(link.innerHTML).toBe(`Learn React`);
  expect(link.href).toBe("https://reactjs.org/");
});

// 4
afterAll(() => {
  browser.close();
});

This is what we're doing in the code above:

  1. Firstly, we import the puppeteer package and declare some global variables, browser and page.
  2. Then we have the beforeAll function provided by Jest. This runs before all tests are run. Here, we launch a new Chromium browser by calling puppeteer.launch(), while setting headless mode to false so we see what's happening. Then, we create a new page by calling browser.newPage() and then go to our React application's URL http://localhost:3000/ by calling the page.goto() function.
  3. Next up, we wait for the .App selector to load. When it loads, we get the innerHTML of .App-header>p selector by using the page.$eval() method and compare it with Edit src/App.js and save to reload.. We do the same thing with the .App-header>a selector. We get back innerHTML and href and then we compare them with Learn React and https://reactjs.org/ respectively to test our assertion with Jest's expect() function.
  4. Finally, we call the afterAll function provided by Jest. This runs after all tests are run. Here, we close the browser.

This test should automatically run and give you the following result:

E2E Test Puppeteer Basic

Let's go ahead and make a counter app.

The post Learn End-to-end Testing with Puppeteer appeared first on SitePoint.


by Akshay Kadam via SitePoint

Death of Microsoft Windows 7 is a Milestone for Windows 10

Windows is one of the best operating systems around the world with millions of people using it every single day. Not everyone can operate Linux and other operating systems easily, which is why Windows has remained the first choice of every user. When Windows released Windows 10, the company was...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Madiha via Digital Information World

Reddit’s New Policies – Impersonation Banned on the Platform

Recently, Reddit has released new policies that are focused on banning the impersonation of the platform. Such content includes Deepfakes or any misleading content that involves the impersonation of an individual in an ill manner. This is not new; the company has also put a ban on deepfake porn...

[ This is a content summary only. Visit our website https://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Madiha via Digital Information World

Microsoft's Chromium-based browser arrives

#423 — January 15, 2020

Read on the Web

Frontend Focus

Microsoft's Chromium-Powered Browser Arrives — The new version of Microsoft Edge is now out of preview and available for download. Developer documentation for the updated browser can be found here. (So, what's the nickname for this one then? Edgium? Credge? 😅)

Kyle Pflug (Microsoft)

Google to Phase Out User-Agent Strings in Chrome — User agent strings have been a part of the Web since (almost) the very beginning, but there’s a growing movement to reduce their status. Chrome plans to shift to using Client Hints and Apple, Microsoft and Mozilla have shown interest in freezing or phasing out user agent strings too.

Catalin Cimpanu

On-Demand Webinar: How to Prepare Your Data Pipeline for Machine Learning and AI — Training-based session on transforming your data to power machine learning and AI projects. Use AWS Data Pipeline to automate data movement and transformation and explore software solutions in AWS Marketplace that make your data analytics-ready.

Amazon Web Services (AWS) sponsor

Chrome Experimenting with Web NFC Implementation — Web NFC aims to provide a way for sites to read and write to a nearby NFC tag. Google are currently experimenting with implementing the API with a view to shipping in Chrome 84. You can scrub up on the spec here, and try a Chrome-only demo (behind a flag) here.

François Beaufort

A Short History of Body Copy Sizes on the Web — An interesting look into how default text sizes have changed over the years, some thoughts as to why we’ve seemingly landed on 16px as the default, and what modern variable solutions are emerging.

Florens Verschelde

Get Started Building Extensions for The New Microsoft Edge — Now that it's here, you may want to look into developing an extension for Microsoft’s new version of Edge. The good news is that most existing extensions built for Chrome will work without any modifications.

Killian McCoy

Google Plans to Kill Off Third-Party Cookies in Chrome 'Within 2 Years' — The search giant is setting out a long grace period for its intended browser change and is asking the online advertising industry to help it build more privacy-focused alternatives to the cookie. Here's Google's blog post on it.

Digiday

💻 Jobs

Full-Stack or Front-End Engineer - Rails/React (Remote/NYC) — Got 2+ years of experience? Come help build the next iteration of our growing digital recovery platform centered on providing alcohol abuse treatment.

TEMPEST

Find a Job Through Vettery — Vettery is completely free for job seekers. Make a profile, name your salary, and connect with hiring managers from top employers.

Vettery

📙 Articles, Tutorials & Opinion

Why You Should Choose <article> over <section>“Think of <article> not just as a newspaper article, or a blog post, but as an article of clothing — a discrete entity that can be reused in another context.” This has key implications for users using assistive technology like screen readers.

Bruce Lawson

CSS4 Is Here — Of course, it isn’t - but PPK argues that saying as much may be a good marketing move to entice the 'cult of new'.

Peter-Paul Koch

Text Links: Best Practices for Screen Readers — Compares screen reader behavior for aria-label and title attributes on text links. This sort of stuff is always worth scrubbing up on.

Sailesh Panchang

Make 2020 the Year to Master MongoDB. Try Studio 3T Today — Generate driver code for JavaScript, Python, Ruby and more? Build queries fast with our drag & drop editor? Of course.

Studio 3T sponsor

A Basic Example of the Web Share API — The Web Share API enables native sharing (via other apps/social networks) on pages.

Dillion Megida

The End of Indie Web Browsers: You Can (Not) Compete — Explores how DRM in browsers (in place to appease the Netflix’s and HBO’s of the world) has somewhat restricted independent browser development.

Samuel Maddock

Pixels Vs. Relative Units in CSS: Why It’s Still A Big Deal

Kathleen McMahon

Why Should You Use HSL Color Representation in CSS?

Mateusz Piguła

▶  Building Resilient Frontend Architecture

Monica Lent

CSS-Only Carousel — A look at just how far HTML and CSS will take you when building a carousel/slideshow.

Chris Coyier

Fixed Table Headers — Revisiting how to build a table with fixed headers using position: sticky.

Adrian Roselli

Seven CSS Properties You Had No Idea About — I wasn’t familiar with bleed, caret-color and the now deprecated azimuth properties.

Tomasz Łakomy

🔧 Code, Tools and Resources

Tailwind CSS Adds Grid Support — Note this is only the pre-release of version 1.2.0, but adds plenty, including CSS Transition, Transform & Grid support.

Tailwind CSS

Variable Fonts — This site isn’t new, but continues to be a handy resource for both finding and trying out a growing collection of variable fonts.

Nick Sherman

CFP for ForwardJS San Francisco and Ottawa Now OPEN

ForwardJS sponsor

Palettab — If you’re constantly on the source for color palette inspiration then this Chrome extension may be just the ticket. It shows a color swatch and font pairing on every new tab.

Tim Holman & Claudio Guglieri

Tiny Helpers — Some good stuff in this growing collection of single-purpose online tools for web devs.

Stefan Judis

Harp: A Static Web Server with Built-in Preprocessing

Chloi Inc.

   🗓 Upcoming Events

Flashback Conference, February 10-11 — Orlando, USA — Looks at cutting-edge web dev, browser APIs and tooling, but adds how they’ve evolved from the past to the web of today.

Frontend Developer Love, February 19-21 — Amsterdam, Netherlands — Three full days of talks from 35+ global JavaScript leaders from around the world.

ConveyUX, March 3-5 — Seattle, USA — This West Coast user experience conference features over 65 sessions across three days.

W3C Workshop on Web & Machine Learning, 24-25 March — Berlin, Germany — Hosted by Microsoft, this free event aims to “bring together providers of Machine Learning tools and frameworks with Web platform practitioners to enrich the Open Web Platform with better foundations for machine learning”.


by via Frontend Focus