This guide assumes you've got a project using Detox with Jest, and you want to write your Detox tests in TypeScript.
- Refer to this guide if you need to set up such a project.
We'll be using ts-jest to run Jest tests with TypeScript.
| // A `Fruit` object contains `name` and `color` | |
| class Fruit { | |
| final String name; | |
| final String color; | |
| Fruit( this.name, this.color ); | |
| } | |
| // A `Fruits` collection contains the List of `Fruit` object | |
| // `iterator` getter returns an instance of `FruitsIterator` instance |
This guide assumes you've got a project using Detox with Jest, and you want to write your Detox tests in TypeScript.
We'll be using ts-jest to run Jest tests with TypeScript.
While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.
JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it much simpler to think about both the old list and the new one, what they contain, and
| FROM node:lts-alpine AS build-stage | |
| WORKDIR /app | |
| COPY package*.json ./ | |
| RUN npm install | |
| COPY . . | |
| RUN npm run build | |
| FROM nginx:stable-alpine | |
| COPY --from=build-stage /app/dist /usr/share/nginx/html | |
| # this isn't necessary - you don't have to expose a port here |
| /* eslint-disable no-var,no-console */ | |
| // detect unused CSS selectors | |
| (function() { | |
| var parsedRules = parseCssRules(); | |
| console.log('Parsed CSS rules:', parsedRules); | |
| detectDuplicateSelectors(parsedRules); | |
| var selectorsToTrack = getSelectorsToTrack(parsedRules); | |
| window.selectorStats = { unused: [], added: [], removed: [] }; | |
| console.log('Tracking style usage (inspect window.selectorStats for details)...'); |
| /* eslint-disable no-var,no-console */ | |
| /** | |
| * Проверка на масштабирование изображений в браузере. | |
| * Срабатывает, если натуральный размер изображения намного больше отображаемого на странице, | |
| * то есть браузер грузит большую картинку и масштабирует её до маленькой. | |
| */ | |
| (function() { | |
| if (!window.Promise || !String.prototype.startsWith || window.MSInputMethodContext) { | |
| // Не запускаем проверку в IE11 и браузерах, не поддерживающих нужные API | |
| return; |
| // Measure page scroll speed | |
| (function() { | |
| if (document.body.scrollHeight <= window.innerHeight) { | |
| console.log('Scrolling measurement is only possible if the window can actually be scrolled!'); | |
| return; | |
| } | |
| function calcScrollTime(startTime, iterations) { | |
| return Math.round((Date.now() - startTime) / iterations) / 1000; | |
| } |
This gives you that beautiful green lock in Chrome. I'm assuming you're putting your SSL documents in /etc/ssl, but you can put them anywhere and replace the references in the following commands. Tested successfully on Mac OS Sierra and High Sierra.
sudo nano /etc/ssl/localhost/localhost.conf
Content:
[req]