Skip to content

Instantly share code, notes, and snippets.

View vkbansal's full-sized avatar
💭
I may be slow to respond.

Vivek Kumar Bansal vkbansal

💭
I may be slow to respond.
View GitHub Profile
@vkbansal
vkbansal / pipeline.yaml
Created August 1, 2022 07:06
Harness blog snippet - Cypress CI YAML 3
execution:
steps:
- parallel:
- step:
name: run1
identifier: run1
type: Run
spec:
connectorRef: myDockerConnector
image: myorg/cypress-test:run-<+pipeline.sequenceId>
@vkbansal
vkbansal / pipeline.yaml
Created August 1, 2022 07:05
Harness blog snippet - Cypress CI YAML 2
serviceDependencies:
- identifier: Cypress_Server
name: Cypress Server
type: Service
spec:
connectorRef: myDockerConnector
image: myorg/cypress-test:run-<+pipeline.sequenceId>
@vkbansal
vkbansal / entrypoint.sh
Created August 1, 2022 07:03
Harness blog snippet - Cypress CI entrypoint
# reference https://docs.cypress.io/guides/continuous-integration/introduction#Xvfb
Xvfb -screen 0 1024x768x24 :8099 &
# start the mock node server
node /opt/cypress/server.js
@vkbansal
vkbansal / Dockerfile
Created August 1, 2022 07:01
Harness blog snippet - Cypress CI DockerFile
FROM cypress/browsers:node14.16.0-chrome90-ff88
WORKDIR /opt/cypress
# copy the built app
COPY dist /opt/app
# copy cypress folder
COPY cypress /opt/cypress
@vkbansal
vkbansal / pipeline.yaml
Created August 1, 2022 06:59
Harness blog snippet - Cypress CI YAML 1
execution:
steps:
- step:
type: Run
name: Build
identifier: Build
spec:
connectorRef: myDockerConnector
image: node:16
shell: Sh
import React from "react";
import { useLocaleStrings, LocaleString } from "./StringsContext";
export default function HomePage(): React.ReactElement {
const { getString } = useLocaleStrings();
return (
<div>
<h1>Home</h1>
- <p>{getString("homePageContent.para1")}</p>
# strings.yaml
homePageContent:
para1: |
+ Hello {{name}}
Lorem ipsum dolor sit amet consectetur adipisicing elit. Aliquam, eos
animi. Corporis harum quaerat dicta possimus illum aut unde laborum
excepturi suscipit quibusdam perspiciatis dolorum alias, exercitationem
similique illo? Distinctio.
para2: |
+ Hello {{name}}
// StringsContext.tsx
+ import mustache from "mustache";
export interface UseLocaleStringsReturn {
- getString(key: string): string;
+ getString(key: string, variables?: any): string;
}
export function useLocaleStrings() {
const strings = useStringsContext();
// HomePage.tsx
import React from "react";
- import { useLocaleStrings } from "./StringsContext";
+ import { useLocaleStrings, LocaleString } from "./StringsContext";
export default function HomePage(): React.ReactElement {
const { getString } = useLocaleStrings();
return (
<div>
<h1>Home</h1>
<p>{getString("homePageContent.para1")}</p>
// StringsContext.tsx
export interface LocaleStringProps extends React.HTMLAttributes<any> {
strKey: string;
as?: keyof JSX.IntrinsicElements;
}
export function LocaleString(props: LocaleStringProps): React.ReactElement {
const { strKey, as, ...rest } = props;
const { getString } = useLocaleStrings();
const Component = as || "span";