Skip to content

Instantly share code, notes, and snippets.

View sabesansathananthan's full-sized avatar
:octocat:
Work

Sathananthan Sabesan sabesansathananthan

:octocat:
Work
View GitHub Profile
@sabesansathananthan
sabesansathananthan / requestService.js
Last active August 11, 2022 13:36
The Missing Part of Medium RSS Feed
const request = require("request");
const cheerio = require("cheerio");
const url = "https://medium.com/p/d5b52f24d53c";
const element = url.split("/");
const postId = element[element.length - 1];
request(url, async (error, response, body) => {
if (error) {
console.log(error);
@sabesansathananthan
sabesansathananthan / .eslintrc
Created October 8, 2021 07:18
Using Absolute Imports in ReactJs
"eslintConfig": {
"extends": ["airbnb", "prettier", "plugin:jsx-a11y/recommended"],
"settings": {
"import/resolver": {
"node": {
"paths": ["src"],
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
}
@sabesansathananthan
sabesansathananthan / jsconfig.json
Created October 7, 2021 18:23
Using Absolute Imports in ReactJs
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"]
}
@sabesansathananthan
sabesansathananthan / tsconfig.json
Created October 7, 2021 18:14
Using Absolute Imports in ReactJs
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"]
}
@sabesansathananthan
sabesansathananthan / AbsoluteImportApp.js
Created October 7, 2021 18:06
Using Absolute Imports in ReactJs
import React from 'react';
import { LINKS, STRINGS } from 'utils/constants';
import Button from 'components/Button/Button';
import styles from './App.module.css';
function App() {
return (
<div className={styles.App}>
<Button>
{STRINGS.HELLO}
@sabesansathananthan
sabesansathananthan / RelativeImportApp.js
Created October 7, 2021 18:03
Using Absolute Imports in ReactJs
import React from 'react';
import Button from '../../Button/Button';
import { LINKS, STRINGS } from '../../../utils/constants';
import styles from './App.module.css';
function App() {
return (
<div className={styles.App}>
<Button>
{STRINGS.HELLO}
@sabesansathananthan
sabesansathananthan / demo4.test.js
Created September 22, 2021 10:31
mock network request in Jest
import { counter } from "./demo";
import { setSuitesData } from "../src/index";
import data from "./data/demo1.data";
beforeAll(() => {
return setSuitesData(data);
});
describe("Simple mock", () => {
it("test success", () => {
@sabesansathananthan
sabesansathananthan / demo1.data.ts
Last active September 22, 2021 09:48
mock network request in Jest
import { DataMapper } from "../../src";
const data: DataMapper = {
"/api/setCounter": [
{
request: {
method: "POST",
data: '{"id":1,"operate":1}',
},
response: {
@sabesansathananthan
sabesansathananthan / jest.config.js
Created September 22, 2021 08:16
mock network request in Jest
module.exports = {
// ...
globals: {
host: "127.0.0.1",
port: "5000",
debug: false,
},
// ...
}
@sabesansathananthan
sabesansathananthan / global-setup.js
Created September 22, 2021 08:13
mock network request in Jest
import { run } from "../../src";
export default async () => {
await run();
};