並び順

ブックマーク数

期間指定

  • から
  • まで

241 - 280 件 / 381件

新着順 人気順

jestの検索結果241 - 280 件 / 381件

  • Alexa スキルを Serverless + Typescriptで開発する - Qiita

    はじめに 自分もAlexaスキルを作ってみようとちょっといじってみた。 Alexaスキルのバックエンドには AWS Lambda を Node.js ランタイムで利用するのが手っ取り早い。 どうせなら、この機会に Typescript も使ってみようと思って Typescript と VSCode にも入門した。 また、Lambdaのデプロイ等の操作には今の所、 AWS SAM よりも 手間が少ないと感じる Serverless Framework を利用している。 Serverless Framework にはGithubなどで公開されている既存のアプリケーションを元にアプリケーションの雛形を作る機能(serverless install)があるので、ベースの部分をテンプレートとして公開してみた。 HeRoMo/serverless-aws-alexa-ts READMEの日本語版がわり

      Alexa スキルを Serverless + Typescriptで開発する - Qiita
    • Jestで非同期関数が例外を投げることをテストする。 - Qiita

      背景 バイトで、Async関数が例外を投げてくれること、そしてその例外がどの例外であるかをテストする必要が出てきました。そのときのメモを残しておこうと思います。 やってみよう expectに関数を渡して、toThrowしてやると非同期でない関数が例外を投げるかどうかをテストできます。しかし、この場合、expectにAsync関数を渡しても期待どおりのテストを行うことはできません。 test('throws on octopus', () => { expect(() => { drinkFlavor('octopus'); }).toThrow(); }); 非同期処理が失敗したときに追加でアサーションを行うためには、rejectsを使います。この場合、Promiseが成功したときはアサーションが失敗します。 次のようなdrinkFlavorがあったとします。 async function

        Jestで非同期関数が例外を投げることをテストする。 - Qiita
      • ES6+Babel7環境でJestする方法 - Qiita

        概要 JavaScriptのテストフレームワークJestをES6+Babel7の環境で使う方法について書きます 仕掛けを理解するために、ゼロからnpmプロジェクトを作っていきます npmプロジェクトを作る

          ES6+Babel7環境でJestする方法 - Qiita
        • Expect · Jest

          When you're writing tests, you often need to check that values meet certain conditions. expect gives you access to a number of "matchers" that let you validate different things.

            Expect · Jest
          • jest で Node.js の テストするなら testEnvironment: "node" を使う - Qiita

            jest はデフォルトコンテキストが browser になる。 そのため axios とかだと内部に使われるhttp requestライブラリがデフォルトで XHR になる。 XHR になると、Nodeのhttpモジュールとは違い、CORSの制約などの細々した制約を受けてしまう。 受けた結果、 jestでだけNetwork Error になる、CORSのエラーとしてわかりやすいエラーが出てくれたら良いが、 Network Error とだけ返ってくる事になり、意味不明の状態で半日デバッグしていたら、jsdom/xmlhttprequest で変な問題を見つけた。 どうも origin が "null" (string の null) のときと access-control-allow-origin のヘッダに何も指定しないと null (普通のnull) になり、同一性チェックに失敗するよ

              jest で Node.js の テストするなら testEnvironment: "node" を使う - Qiita
            • Storybookのテストランナー

              はじめに Storybook test runner turns all of your stories into executable tests. https://github.com/storybookjs/test-runner Storybookの全てのStoryをテスト可能にする@storybook/test-runnerについてのメモ。 Storybookの公式ドキュメントではv6.5からテストランナーについてのページが設けられている。 何をテストするものか テスト対象についてはplay関数の有無によって異なる。 For those without a play function: it verifies whether the story renders without any errors. For those with a play function: it also

                Storybookのテストランナー
              • GitHub - jest-community/jest-extended: Additional Jest matchers 🃏💪

                You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

                  GitHub - jest-community/jest-extended: Additional Jest matchers 🃏💪
                • puppeteer を使用する · Jest

                  page.$eval, page.$$eval または page.evaluate をテストで使用している場合、Jestのスコープ外でパスする関数が実行されているため、現時点ではPuppeteerを使用したテストがいつのカバレッジの生成はできません。 Check out issue #7962 on GitHub for a workaround. jest-puppeteer プリセットを使用する​ Jest Puppeteer は、Puppeteer を使ってテストを実行するために必要な、すべての設定を提供します。 First, install jest-puppeteer

                    puppeteer を使用する · Jest
                  • TypeScriptとJestとCircleCIとCodecovな環境 - Qiita

                    export function plus(x: number, y: number): number { return x + y; }

                      TypeScriptとJestとCircleCIとCodecovな環境 - Qiita
                    • Fix the "not wrapped in act(...)" warning

                      Here's the code for that (if you were to do it with class components, don't worry a function version is coming later in the post): class UsernameFormClass extends React.Component { state = {status: 'idle', error: null} handleSubmit = async event => { event.preventDefault() const newUsername = event.target.elements.username.value this.setState({status: 'pending'}) try { await this.props.updateUsern

                        Fix the "not wrapped in act(...)" warning
                      • jest で非同期関数をテストするときの注意点 - Qiita

                        Register as a new user and use Qiita more conveniently You get articles that match your needsYou can efficiently read back useful informationWhat you can do with signing up

                          jest で非同期関数をテストするときの注意点 - Qiita
                        • Troubleshooting · Jest

                          Uh oh, something went wrong? Use this guide to resolve issues with Jest. Tests are Failing and You Don't Know Why​ Try using the debugging support built into Node. Place a debugger; statement in any of your tests, and then, in your project's directory, run: node --inspect-brk node_modules/.bin/jest --runInBand [any other arguments here] or on Windows node --inspect-brk ./node_modules/jest/bin/jest

                            Troubleshooting · Jest
                          • jest : SecurityError: localStorage is not available for opaque origins · Issue #2304 · jsdom/jsdom

                            Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community. Pick a username Email Address Password Sign up for GitHub By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails. Already on GitHub? Sign in to your account

                              jest : SecurityError: localStorage is not available for opaque origins · Issue #2304 · jsdom/jsdom
                            • javascript-testing-best-practices/readme-jp.md at master · yuichkun/javascript-testing-best-practices

                              You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

                                javascript-testing-best-practices/readme-jp.md at master · yuichkun/javascript-testing-best-practices
                              • Fetch do not work on Jest · Issue #2071 · jestjs/jest

                                jest version = 17.0.0 test framework = jasmine2 config = { "haste": { "defaultPlatform": "ios", "platforms": [ "android", "ios" ], "providesModuleNodeModules": [ "react", "react-native" ] }, "moduleNameMapper": [ [ "^image![a-zA-Z0-9$_-]+$", "GlobalImageStub" ], [ "^[./a-zA-Z0-9$_-]+\\.(bmp|gif|jpg|jpeg|png|psd|svg|webp)$", "RelativeImageStub" ] ], "modulePathIgnorePatterns": [ "app/node_modules/r

                                  Fetch do not work on Jest · Issue #2071 · jestjs/jest
                                • Reactのテストを mocha + nyc から Jestにしてみる - Qiita

                                  { "test": "NODE_ENV=test mocha test/", "coverage": "nyc -c npm test" } /srcにソースディレクトリ /testにテストディレクトリ MISC jsdom-global使って色々小細工していた。 mocha -> jestにするモチベーション 興味本位 Jestがv15.0.0でAutomockingを捨てて本気を出してきたのでちょっと使ってみたかった気持ち Railsプロジェクトにjavascriptプロジェクトを混ぜようとしたとき、mochaのテストディレクトリに悩んでしまうぐらいなら、Jestのテストフでやってみようかと思った jestでは、/srcなどのコードに対して、/src/__tests__というディレクトリを作るか、some.test.jsという名前をつけるのがデフォルト設定になっている。 mochaでも

                                    Reactのテストを mocha + nyc から Jestにしてみる - Qiita
                                  • Database Design Diagram Full Guide and Tools | AppMaster

                                    Databases are crucial for organizing and preserving company data, and databases must be appropriately maintained and designed effectively to require minor maintenance. The database model design process comprises the architecture, programming, installation, and upkeep stages. Do you wish to create a database diagram? Diagrams are the most efficient tool for designing a database model. Creating comp

                                    • 3 ways to test mapStateToProps and mapDispatchToProps

                                      You already know that you shouldn't actually test the result of calling connect (the connected component) - as Redux already makes sure the behaviour of connect is correct. Instead, you test your wrapped component separately, by exporting it as a named export. But what about mapStateToProps and mapDispatchToProps? This is custom code that could have bugs. The Redux docs don’t really mention an off

                                      • Jest CLI オプション · Jest

                                        jest のコマンドラインランナーは多くの便利なオプションを持っています。 jest --help を実行することで使用可能な全てのオプションを見ることができます。 以下に示すオプションの多くは任意のテストを実行する際に利用できます。 Jest の各設定オプションは CLI 経由で指定できます。 以下に簡単な概要を示します。 コマンドラインから実行する​ 全てのテストを実行する (既定値):

                                          Jest CLI オプション · Jest
                                        • fbjs/inline-requires.js at master · facebook/fbjs · GitHub

                                          * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant

                                          • AngularプロジェクトへJestを導入する | Marginalia

                                            TL;DR npm i -D jest @types/jest jest-preset-angular rm karma.conf.js src/test.ts touch jest.config.js src/setup-jest.ts jest-preset-angular プリセットを jest.config.js から読み込む require('jest-preset-angular/ngcc-jest-processor'); module.exports = { preset: 'jest-preset-angular', setupFilesAfterEnv: ['<rootDir>/src/setup-jest.ts'], };

                                              AngularプロジェクトへJestを導入する | Marginalia
                                            • Testing React Native and Redux

                                              Test driven development is essential for any project. In my experience I’ve delayed on delivery several times because I relied on manual testing, so it’s very important that there’s adequate level of understanding of what it takes to test a framework. The ComponentThe ComponentThe component allows users punch in pass codes to login. It needs to: Keep track of all the keys.Clear all the keys.Send t

                                                Testing React Native and Redux
                                              • Reactのテストをちょっとよくするかもしれない細いTips

                                                こんにちは。株式会社スペースマーケットでフロントエンドエンジニアをしておりますwado63です。 以前弊社の記事でReactのテストの実践的なTipsを紹介していましたが、もっと細かい、テストをちょっとよくするかもしれないTipsを紹介したいと思います。 Mock関数に型を当てる jestのnamespaceには、jest.MockedFunctionという型があります。 これを使うことでMock関数に元の関数の型を当てることができます。 import { myFunction } from './myFunction' jest.mock('./myFunction', () => ({ myFunction: jest.fn() })) const mockedMyFunction = myFunction as unknown as jest.MockedFunction<typeo

                                                  Reactのテストをちょっとよくするかもしれない細いTips
                                                • Vue/Jestテストのハマりどころ3選!! - RAKUS Developers Blog | ラクス エンジニアブログ

                                                  はじめに こんにちは。choreiiです。最近自チームで扱っている商材のフロントエンドのテストコードを大量に書く機会がありました。その中で大きくハマった3点について紹介します。 はじめに 環境 1. ライフサイクルフックをmock化(上書き)したい 2. テストによってcomputedを差し替えたい 3. localStorageをmock化したい まとめ 参考 環境 Vue:2.6.11 vue-test-utils:1.0.0-beta.29 Jest:23.6.0 1. ライフサイクルフックをmock化(上書き)したい 以下のようにbeforeMountで初期化処理を書いている場合、beforeMountをまるごとmock化(上書き)したくなる時があります。 <script> export default { beforeMount() { // コンポーネントで必要なデータの取得や

                                                    Vue/Jestテストのハマりどころ3選!! - RAKUS Developers Blog | ラクス エンジニアブログ
                                                  • jest/CHANGELOG.md at 0.8.0 · jestjs/jest

                                                    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

                                                      jest/CHANGELOG.md at 0.8.0 · jestjs/jest
                                                    • Common mistakes with React Testing Library の和訳 - Qiita

                                                      本記事は Kent C. Dodds氏による Common mistakes with React Testing Library の和訳です。 React Testing Library のよくある間違い こんにちは👋 私がReact Testing Libraryを作ったのは、当時のテストの状況に満足していなかったからです。 それが DOM Testing Library に発展し、今ではすべての人気のある JavaScript フレームワークと DOM を対象とした(そうでないものも含めて)テストツールのための実装(ラッパー)があります。 時間の経過とともに、私たちは API にいくつかの小さな変更を加え、最適ではないパターンを発見してきました。 私たちが提供するユーティリティを使用する「より良い方法」を文書化しようと努力しているにもかかわらず、私はいまだにこのような最適ではないパ

                                                        Common mistakes with React Testing Library の和訳 - Qiita
                                                      • Running tests in the browser · Issue #139 · jestjs/jest

                                                        You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert

                                                          Running tests in the browser · Issue #139 · jestjs/jest
                                                        • [Node.js][Jest]LocalStackを使ったDynamoDBテストを並列で行う方法 | DevelopersIO

                                                          吉川@広島です。 テストでのデータベース単位の捉えかた - 日々常々 こちらの記事がはてなブックマークに上がっており、興味深く拝見していました。 テストに閉じたデータベース ここでのテストはテストメソッドのイメージです。テストインスタンスがクラス単位ならテストクラス単位でもいいんですが、とにかくテストの実行単位ごとに完全に独立したデータベースを使用します。 図はシンプルですが、テストケース数が100ならデータベース数も100になるイメージです。 すべての情報がテストに閉じている、理想の形です。実現できるならこれでいきたい。 荒唐無稽なことを言っているように感じるかもしれませんが、たとえばH2 Database Engineをインメモリでテストごとに名前を変えれば実現できます。 こちらの記述を見て、普段行っているLocalStack上のDynamoDBに対するJest自動テストにおいても活か

                                                            [Node.js][Jest]LocalStackを使ったDynamoDBテストを並列で行う方法 | DevelopersIO
                                                          • React TDD Example: Unit Testing and Building a React Component with Jest, Gulp and React Test Utils

                                                            ReactJs has attained lot of momentum since its initial release in 2013, and became the best JavaScript library for developing rich UI interface. React also popularized different concepts like Virtual DOM, Uni-directional data flow and Componentization in the front-end community. As of today, React has more than 20,000 stars in Github repo, and actively maintained by the Facebook team. Update Feb 9

                                                            • インターン生がVueのテストコードをJestで書いたら5000行になった話。 - Qiita

                                                              ある日CTOから僕に勅命が下りました。 テストコードを作成せよ... と、 環境はVue + Jestということで色々調べてみたものの、種類が多すぎる... ・https://vue-test-utils.vuejs.org/ja/guides/ ・https://lmiller1990.github.io/vue-testing-handbook/ja/#vue-js%E3%83%86%E3%82%B9%E3%83%88%E3%83%8F%E3%83%B3%E3%83%89%E3%83%96%E3%83%83%E3%82%AF ・https://jestjs.io/docs/ja/testing-frameworks どれみればええねん。 すでにJest-test-Vueのようなライブラリが入っていたのでこれを使うことにしました。 要件の設定 とりあえず、動くテストコードをとのお達しを受

                                                                インターン生がVueのテストコードをJestで書いたら5000行になった話。 - Qiita
                                                              • Testing Non-Exported Functions in JavaScript | SamanthaMing.com

                                                                # Testing Non-Exported Functions in JavaScript Recently, I finally integrated unit testing into my startup project. I've settled with Jest , I'll speak more about this in a separate journal entry. While writing my test, I ran into a bit of a dilemma of trying to write unit tests for non-exported functions 😖

                                                                  Testing Non-Exported Functions in JavaScript | SamanthaMing.com
                                                                • 【Jest】new Date()をモック化する方法 - Qiita

                                                                  const mockDate = new Date(2021, 0, 1, 1, 1, 1); jest.useFakeTimers(); jest.setSystemTime(mockDate); Jest公式通りの多分一番簡単なベストな方法 https://jestjs.io/ja/docs/timer-mocks 【追記】 非同期処理が入っているとreactのコンポーネント生成が終わる前にDOMの判定をしてしまったり、Timeoutになってしまったりします。 その場合は .useFakeTimers({ doNotFake: [ "nextTick", "setImmediate", "clearImmediate", "setInterval", "clearInterval", "setTimeout", "clearTimeout", ], })

                                                                    【Jest】new Date()をモック化する方法 - Qiita
                                                                  • Vite+React+TypeScriptに テスト環境 Jest+TesttingLibrary をステップbyステップで作る

                                                                    前回 React の テスト方針を調べたでテスト環境について調べました。 今回は、Vite + React + TypeScript + EsLint + Prettier に テスト環境を Jest + Testting Library を ステップbyステップで作っていきます。 環境作成 まずは Viteを使って、React + TypeScript を作成し、EsLint + Prettier を導入した状態までのプロジェクトを用意します。 環境作成の詳細 Viteを使用したアプリの作成方法 → 参考 EsLint + Prettier の導入方法 → 参考1、参考2 環境作成用のコマンド Viteを使用してReact(TypeScript)アプリを、「testsample-app」というアプリ名で作成します。 npm init vite testsample-app -- --te

                                                                      Vite+React+TypeScriptに テスト環境 Jest+TesttingLibrary をステップbyステップで作る
                                                                    • Typescript and Jest: Avoiding type errors on mocked functions

                                                                      When wanting to mock external modules with Jest, we can use the jest.mock() method to auto-mock functions on a module. We can then manipulate and interrogate the mocked functions on our mocked module as we wish. For example, consider the following contrived example for mocking the axios module: import myModuleThatCallsAxios from '../myModule'; import axios from 'axios'; jest.mock('axios'); it('Cal

                                                                        Typescript and Jest: Avoiding type errors on mocked functions
                                                                      • Setting up Rails with React and Jest

                                                                        James Burnett I write software for fun and profit. At the moment, I'm doing front-end web development because it is fun. React is Awesome! Rails is Awesome! Jest is awesome! Using Jest with React in Rails should be Awesome Cubed... and yet it seems so difficult. Recently, the author was in a position where a legacy project wanted to redesign the front-end while keeping the Rails backend. The proj

                                                                        • Babel Config option | ts-jest

                                                                          ts-jest by default does NOT use Babel. But you may want to use it, especially if your code rely on Babel plugins to make some transformations. ts-jest can call the BabelJest processor once TypeScript has transformed the source into JavaScript. The option is babelConfig and it works pretty much as the tsConfig option, except that it is disabled by default. Here is the possible values it can take: f

                                                                          • ts-jestが外部ライブラリをimportできない場合の対処方

                                                                            あるnpmパッケージを追加した後、Webpackのビルドは通っているのにJestでは以下のようなエラーが出るようになった。 ● Test suite failed to run Jest encountered an unexpected token This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript. By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules". Here's what you can do: • If you are trying to use EC

                                                                              ts-jestが外部ライブラリをimportできない場合の対処方
                                                                            • Why I stopped using snapshot testing with Jest

                                                                              These days a lot of people is using Jest’s snapshot testing on a daily basis. I will show you reasons why I stopped. We build spectacular apps, check auriosoftware.com FragilityWe changed a little bit of code and it blew off half of our tests. The problem is that these snapshots are highly coupled with our implementation and as we all know, coupling is one of the biggest pain in software developme

                                                                                Why I stopped using snapshot testing with Jest
                                                                              • redux-observable の処理を marble testing で簡単にテストする

                                                                                TL;DR redux-observable の公式ドキュメントでは Redux の Store を Mock するテスト手法が紹介されており、redux-saga に比べて Test が記述しにくい印象を持ちます。 しかし、Rx の Test 手法である marble testing を用いることで簡単に非同期の Test を記述することができます。 redux-observable とは redux-observable とは Redux の Middleware です。 Redux は自身では非同期処理や副作用に対応できないため、これらを用いるには何らかの Middleware に頼る必要があります。 そこで、redux-observable を用いることになります。 redux-observable は RxJS でアクションを受け取りアクションを返す、Epic と呼ばれる Str

                                                                                • フロントエンドのテストを書く時に私が考えていること | DevelopersIO

                                                                                  最近フロントエンドのテストについて考えることが多いので、自分なりの観点をまとめてみます。 どの程度の粒度で書くのが適切かはプロジェクトやチームによって色々有ると思うので、 あくまで私個人としての考え方になりますのでご理解ください。 最終的にできあがったソースはこちら 環境 今回は以下のバージョンで検証しています。 Node: v15.8.0 Vue 3 Vue Test Utils 2 特にVue 3とVue Test Utils 2に関しては前バージョンからの変更箇所が多いので、実際に動かす場合は注意してください。 想定する画面 以下のようなテーブルからなる画面を想定します。 簡易なユーザー管理画面のようなイメージで、 削除フラグが立っているユーザーには取り消し線が付き 右のボタンを押すと削除フラグが立ち 管理者ユーザーの場合はボタンが非活性になる(削除できない) みたいな仕様とします。

                                                                                    フロントエンドのテストを書く時に私が考えていること | DevelopersIO