정현수
현수 세상
정현수
전체 방문자
오늘
어제
반응형
  • 분류 전체보기 (267)
    • NEXTSTEP 자바스크립트 클린코드 2기 (1)
    • 우테코 4기 (6)
    • 회고록 (5)
    • 개발지식 (6)
    • React (3)
      • React Clone Coding (3)
    • React Native (2)
    • Kubernetes & Docker (36)
      • 궁금한 것 (13)
    • Flutter (2)
    • 알고리즘 (168)
      • 프로그래머스 1단계 (27)
      • 프로그래머스 2단계 (37)
      • 백준 (98)
      • 이론 (6)
    • 자료구조 (3)
    • 유튜브 (1)
    • 책 읽자 (1)
    • 취업준비 (1)
    • 대내 활동 (31)
      • 2022년 겨울방학 알고리즘 특강 (0)
      • 2020년 여름방학 모각코 (13)
      • 2020년 겨울방학 모각코 (13)
      • 웹프로그래밍 상상튜터링 (5)

인기 글

최근 글

공지사항

  • 블로그 이동

태그

  • docker
  • Kubernetes
  • 쿠버네티스
  • 알고리즘
  • javascript
  • kubelet
  • mysql
  • image run
  • React
  • flutter
  • replicaset
  • 모각코
  • image pull
  • 자바스크립트
  • 백준
  • 파이썬
  • 공식문서
  • 이코테
  • Jenkins
  • programmers
  • 개발지식
  • 그리디
  • 디플로이먼트
  • 우테코
  • 노드
  • Deployment
  • 프로그래머스
  • NodePort
  • 레플리카셋
  • 리액트

최근 댓글

블로그 메뉴

  • 홈

티스토리

hELLO · Designed By 정상우.
정현수

현수 세상

[NEXTSTEP 자바스크립트 클린코드 2기] 환경설정
NEXTSTEP 자바스크립트 클린코드 2기

[NEXTSTEP 자바스크립트 클린코드 2기] 환경설정

2022. 3. 9. 15:38
반응형

eslint, prettier 설치

npm install -D eslint eslint-config-airbnb-base eslint-config-prettier eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-prettier prettier​

우선 eslint와 Prettier를 설치해준다.

.eslintrc.js

module.exports = {
  env: {
    browser: true,
    es2021: true,
    node: true,
  },
  extends: ['eslint:recommended', 'airbnb-base', 'prettier'],
  plugins: ['prettier'],
  rules: {
    'import/prefer-default-export': 'off',
    'import/extensions': ['off'],
    'class-methods-use-this': 'off',
    'no-alert': 'off',
    'no-undef': 'off',
    'no-new': 'off',
  },
};

eslint 내용을 작성해준다.

 

추가적으로 numeric-separators을 활용하고 싶다면 추가적인 설정이 필요하다.

  parserOptions: {
    ecmaVersion: 2021,
  },

 numeric-separators이 ecma 2021 버전에서만 동작하기 때문에  numeric-separators을 사용하고 싶다면 eslintrc에 추가!

 

.prettierrc.js

module.exports = {
  singleQuote: true,
  semi: true,
  useTabs: false,
  tabWidth: 2,
  trailingComma: 'all',
  printWidth: 100,
  bracketSpacing: true,
  arrowParens: 'avoid',
};

prettierc 파일도 작성!

 

Cypress 설치

npm install cypress --save-dev

후에 만약 cypress 폴더랑 cypress.json 파일이 생성되지 않으면

npx cypress open

위의 명령어를 통해서 cypress 폴더랑 cypress.json 파일을 생성

cypress-watch-and-reload 설치

cypress로 TDD를 할 때, 코드가 저장될 때 마다 테스트를 돌리고 싶다면 해당 라이브러리를 설치해서 설정해야 한다.

 

cypress.json 설정

{
  "video": false,
  "baseUrl": "http://localhost:8080",
  "cypress-watch-and-reload": {
    "watch": "src/js/*"
  }
}

baseUrl은 live-server했을 때 구동되는 포트번호로 맞춰서 쓰면된다.

video: false는 테스트 실패 시 테스트 실패에 관한 비디오를 만드는 것인데, 용량을 위해서 사용하지 않는다.

cypress-watch-and-reload 설치

npm install cypress-watch-and-reload

cypress/plugins/index.js 파일 수정

/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

module.exports = (on, config) => {
  // https://github.com/bahmutov/cypress-watch-and-reload
  // eslint-disable-next-line global-require
  require('cypress-watch-and-reload/plugins')(config);
  // IMPORTANT: return the config object
  // because the plugin might have changed it
  return config;
};

 

cypress/integration/_.spec.js 파일 생성

describe('자동차 경주 게임', () => {
  it('테스트1', () => {
    expect(true).to.be(false);
  });
});

 

 

그리고 열심히 개발을 진행하면 된다...!

반응형
    정현수
    정현수
    깃허브 : https://github.com/junghyeonsu 개인 블로그 : https://junghyeonsu.com/ (양질의 글을 올리려고 항상 노력합니다.)

    티스토리툴바