diff --git a/.eslintrc.js b/.eslintrc.js index 5d6ce4f7c1..e6a85da5eb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -429,7 +429,10 @@ const config = { }, }, { - files: ['packages/algoliasearch-helper/test/**/*.js'], + files: [ + 'packages/algoliasearch-helper/__tests__/**/*.js', + 'packages/algoliasearch-helper/test/**/*.js', + ], rules: { 'no-console': 'off', 'jest/no-done-callback': 'off', diff --git a/jest.config.js b/jest.config.js index b3fbb1af55..7c6b23836c 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,22 +1,28 @@ // @ts-check +const enableIntegrationTest = + process.env.ONLY_UNIT !== 'true' && + process.env.INTEGRATION_TEST_API_KEY && + process.env.INTEGRATION_TEST_APPID; + /** @type {import('@jest/types').Config.InitialOptions} */ const config = { rootDir: process.cwd(), testRunner: 'jest-circus', testEnvironment: 'node', setupFilesAfterEnv: ['./tests/utils/setupTests.ts'], + globalTeardown: './tests/utils/teardownTests.ts', testPathIgnorePatterns: [ '/node_modules/', '/packages/*/node_modules/', '/packages/*/dist*', '/tests/e2e/*', '/examples/', - '/packages/algoliasearch-helper', '/packages/create-instantsearch-app', '/packages/react-instantsearch-hooks-router-nextjs', '/__utils__/', - ], + enableIntegrationTest ? '' : '/integration-spec/', + ].filter(Boolean), watchPathIgnorePatterns: [ '/packages/*/cjs', '/packages/*/dist', diff --git a/package.json b/package.json index d5e4d71ac8..2720d3aac3 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "test:e2e": "yarn test:e2e:local", "test:e2e:local": "wdio scripts/wdio/local.conf.js", "test:e2e:saucelabs": "wdio scripts/wdio/saucelabs.conf.js", - "test:v3": "lerna run test:v3", + "test:v3": "./scripts/retry.sh 3 'jest --maxWorkers=4 --ci' && lerna run test:v3 --concurrency=1", "release": "shipjs prepare", "prepare": "lerna run prepare && patch-package", "prepare-vue3": "./scripts/prepare-vue3.js" diff --git a/packages/algoliasearch-helper/test/integration-spec/helper.derive.js b/packages/algoliasearch-helper/__tests__/integration-spec/helper.derive.js similarity index 94% rename from packages/algoliasearch-helper/test/integration-spec/helper.derive.js rename to packages/algoliasearch-helper/__tests__/integration-spec/helper.derive.js index 5b98efa33e..5133a192c2 100644 --- a/packages/algoliasearch-helper/test/integration-spec/helper.derive.js +++ b/packages/algoliasearch-helper/__tests__/integration-spec/helper.derive.js @@ -1,6 +1,8 @@ 'use strict'; -var utils = require('../integration-utils'); +jest.retryTimes(3, { logErrorsBeforeRetry: true }); + +var utils = require('../../test/integration-utils'); var setup = utils.setupSimple; var createIndexName = utils.createIndexName; diff --git a/packages/algoliasearch-helper/test/integration-spec/helper.distinct.facet.js b/packages/algoliasearch-helper/__tests__/integration-spec/helper.distinct.facet.js similarity index 92% rename from packages/algoliasearch-helper/test/integration-spec/helper.distinct.facet.js rename to packages/algoliasearch-helper/__tests__/integration-spec/helper.distinct.facet.js index cb3752fa68..28fee7508d 100644 --- a/packages/algoliasearch-helper/test/integration-spec/helper.distinct.facet.js +++ b/packages/algoliasearch-helper/__tests__/integration-spec/helper.distinct.facet.js @@ -1,6 +1,8 @@ 'use strict'; -var utils = require('../integration-utils'); +jest.retryTimes(3, { logErrorsBeforeRetry: true }); + +var utils = require('../../test/integration-utils'); var setup = utils.setupSimple; var createIndexName = utils.createIndexName; diff --git a/packages/algoliasearch-helper/test/integration-spec/helper.filters.js b/packages/algoliasearch-helper/__tests__/integration-spec/helper.filters.js similarity index 94% rename from packages/algoliasearch-helper/test/integration-spec/helper.filters.js rename to packages/algoliasearch-helper/__tests__/integration-spec/helper.filters.js index 627bce9b93..c7e6f2ecd0 100644 --- a/packages/algoliasearch-helper/test/integration-spec/helper.filters.js +++ b/packages/algoliasearch-helper/__tests__/integration-spec/helper.filters.js @@ -1,6 +1,8 @@ 'use strict'; -var utils = require('../integration-utils'); +jest.retryTimes(3, { logErrorsBeforeRetry: true }); + +var utils = require('../../test/integration-utils'); var setup = utils.setupSimple; var createIndexName = utils.createIndexName; diff --git a/packages/algoliasearch-helper/test/integration-spec/helper.geo.js b/packages/algoliasearch-helper/__tests__/integration-spec/helper.geo.js similarity index 94% rename from packages/algoliasearch-helper/test/integration-spec/helper.geo.js rename to packages/algoliasearch-helper/__tests__/integration-spec/helper.geo.js index 027479a37c..9a40a3f23c 100644 --- a/packages/algoliasearch-helper/test/integration-spec/helper.geo.js +++ b/packages/algoliasearch-helper/__tests__/integration-spec/helper.geo.js @@ -1,6 +1,8 @@ 'use strict'; -var utils = require('../integration-utils'); +jest.retryTimes(3, { logErrorsBeforeRetry: true }); + +var utils = require('../../test/integration-utils'); var setup = utils.setupSimple; var createIndexName = utils.createIndexName; diff --git a/packages/algoliasearch-helper/test/integration-spec/helper.highlight.js b/packages/algoliasearch-helper/__tests__/integration-spec/helper.highlight.js similarity index 93% rename from packages/algoliasearch-helper/test/integration-spec/helper.highlight.js rename to packages/algoliasearch-helper/__tests__/integration-spec/helper.highlight.js index 87a91586b1..91e121aa53 100644 --- a/packages/algoliasearch-helper/test/integration-spec/helper.highlight.js +++ b/packages/algoliasearch-helper/__tests__/integration-spec/helper.highlight.js @@ -1,6 +1,8 @@ 'use strict'; -var utils = require('../integration-utils'); +jest.retryTimes(3, { logErrorsBeforeRetry: true }); + +var utils = require('../../test/integration-utils'); var setup = utils.setupSimple; var createIndexName = utils.createIndexName; diff --git a/packages/algoliasearch-helper/test/integration-spec/helper.insights.js b/packages/algoliasearch-helper/__tests__/integration-spec/helper.insights.js similarity index 90% rename from packages/algoliasearch-helper/test/integration-spec/helper.insights.js rename to packages/algoliasearch-helper/__tests__/integration-spec/helper.insights.js index 7a0b9ca608..defb9bf1ca 100644 --- a/packages/algoliasearch-helper/test/integration-spec/helper.insights.js +++ b/packages/algoliasearch-helper/__tests__/integration-spec/helper.insights.js @@ -1,6 +1,8 @@ 'use strict'; -var utils = require('../integration-utils'); +jest.retryTimes(3, { logErrorsBeforeRetry: true }); + +var utils = require('../../test/integration-utils'); var setup = utils.setupSimple; var createIndexName = utils.createIndexName; diff --git a/packages/algoliasearch-helper/test/integration-spec/helper.numerics.js b/packages/algoliasearch-helper/__tests__/integration-spec/helper.numerics.js similarity index 97% rename from packages/algoliasearch-helper/test/integration-spec/helper.numerics.js rename to packages/algoliasearch-helper/__tests__/integration-spec/helper.numerics.js index 21459f4cf5..6ef883045a 100644 --- a/packages/algoliasearch-helper/test/integration-spec/helper.numerics.js +++ b/packages/algoliasearch-helper/__tests__/integration-spec/helper.numerics.js @@ -1,6 +1,8 @@ 'use strict'; -var utils = require('../integration-utils'); +jest.retryTimes(3, { logErrorsBeforeRetry: true }); + +var utils = require('../../test/integration-utils'); var setup = utils.setupSimple; var createIndexName = utils.createIndexName; diff --git a/packages/algoliasearch-helper/test/integration-spec/helper.results.getFacetValues.js b/packages/algoliasearch-helper/__tests__/integration-spec/helper.results.getFacetValues.js similarity index 91% rename from packages/algoliasearch-helper/test/integration-spec/helper.results.getFacetValues.js rename to packages/algoliasearch-helper/__tests__/integration-spec/helper.results.getFacetValues.js index 0dbf72b958..8eb2cecb07 100644 --- a/packages/algoliasearch-helper/test/integration-spec/helper.results.getFacetValues.js +++ b/packages/algoliasearch-helper/__tests__/integration-spec/helper.results.getFacetValues.js @@ -1,6 +1,8 @@ 'use strict'; -var utils = require('../integration-utils'); +jest.retryTimes(3, { logErrorsBeforeRetry: true }); + +var utils = require('../../test/integration-utils'); var setup = utils.setupSimple; var createIndexName = utils.createIndexName; diff --git a/packages/algoliasearch-helper/test/integration-spec/helper.searchForFacetValues.js b/packages/algoliasearch-helper/__tests__/integration-spec/helper.searchForFacetValues.js similarity index 98% rename from packages/algoliasearch-helper/test/integration-spec/helper.searchForFacetValues.js rename to packages/algoliasearch-helper/__tests__/integration-spec/helper.searchForFacetValues.js index 7c46aed7eb..7bd577cc6a 100644 --- a/packages/algoliasearch-helper/test/integration-spec/helper.searchForFacetValues.js +++ b/packages/algoliasearch-helper/__tests__/integration-spec/helper.searchForFacetValues.js @@ -1,6 +1,8 @@ 'use strict'; -var utils = require('../integration-utils'); +jest.retryTimes(3, { logErrorsBeforeRetry: true }); + +var utils = require('../../test/integration-utils'); var setup = utils.setupSimple; var createIndexName = utils.createIndexName; diff --git a/packages/algoliasearch-helper/test/integration-spec/helper.searchOnce.js b/packages/algoliasearch-helper/__tests__/integration-spec/helper.searchOnce.js similarity index 95% rename from packages/algoliasearch-helper/test/integration-spec/helper.searchOnce.js rename to packages/algoliasearch-helper/__tests__/integration-spec/helper.searchOnce.js index 3e4f115ea4..b0c1e83e0d 100644 --- a/packages/algoliasearch-helper/test/integration-spec/helper.searchOnce.js +++ b/packages/algoliasearch-helper/__tests__/integration-spec/helper.searchOnce.js @@ -1,6 +1,8 @@ 'use strict'; -var utils = require('../integration-utils'); +jest.retryTimes(3, { logErrorsBeforeRetry: true }); + +var utils = require('../../test/integration-utils'); var setup = utils.setupSimple; var createIndexName = utils.createIndexName; diff --git a/packages/algoliasearch-helper/test/integration-spec/helper.tags.js b/packages/algoliasearch-helper/__tests__/integration-spec/helper.tags.js similarity index 95% rename from packages/algoliasearch-helper/test/integration-spec/helper.tags.js rename to packages/algoliasearch-helper/__tests__/integration-spec/helper.tags.js index 6968754435..4c4cbfb531 100644 --- a/packages/algoliasearch-helper/test/integration-spec/helper.tags.js +++ b/packages/algoliasearch-helper/__tests__/integration-spec/helper.tags.js @@ -1,6 +1,8 @@ 'use strict'; -var utils = require('../integration-utils'); +jest.retryTimes(3, { logErrorsBeforeRetry: true }); + +var utils = require('../../test/integration-utils'); var setup = utils.setupSimple; var createIndexName = utils.createIndexName; diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/RefinementList/clear.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/RefinementList/clear.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/RefinementList/clear.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/RefinementList/clear.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/_clearNumericRefinements.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/_clearNumericRefinements.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/_clearNumericRefinements.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/_clearNumericRefinements.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/_parseNumbers.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/_parseNumbers.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/_parseNumbers.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/_parseNumbers.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/constructorFn.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/constructorFn.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/constructorFn.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/constructorFn.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/getConjunctiveRefinements.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/getConjunctiveRefinements.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/getConjunctiveRefinements.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/getConjunctiveRefinements.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/getDisjunctiveRefinements.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/getDisjunctiveRefinements.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/getDisjunctiveRefinements.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/getDisjunctiveRefinements.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/getExcludeRefinements.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/getExcludeRefinements.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/getExcludeRefinements.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/getExcludeRefinements.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/hierarchical-facets/add.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/hierarchical-facets/add.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/hierarchical-facets/add.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/hierarchical-facets/add.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/hierarchical-facets/remove.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/hierarchical-facets/remove.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/hierarchical-facets/remove.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/hierarchical-facets/remove.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/isDisjunctiveFacetRefined.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/isDisjunctiveFacetRefined.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/isDisjunctiveFacetRefined.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/isDisjunctiveFacetRefined.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/isExcludeRefined.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/isExcludeRefined.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/isExcludeRefined.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/isExcludeRefined.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/isFacetRefined.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/isFacetRefined.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/isFacetRefined.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/isFacetRefined.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/isHierarchicalFacetRefined.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/isHierarchicalFacetRefined.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/isHierarchicalFacetRefined.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/isHierarchicalFacetRefined.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/isNumericRefined.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/isNumericRefined.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/isNumericRefined.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/isNumericRefined.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/listAttributes.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/listAttributes.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/listAttributes.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/listAttributes.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/noChanges.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/noChanges.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/noChanges.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/noChanges.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/numericAttributes.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/numericAttributes.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/numericAttributes.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/numericAttributes.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/numericFilters.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/numericFilters.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/numericFilters.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/numericFilters.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/removeXFacet.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/removeXFacet.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/removeXFacet.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/removeXFacet.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/removeXFacetRefinement.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/removeXFacetRefinement.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/removeXFacetRefinement.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/removeXFacetRefinement.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/resetPage.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/resetPage.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/resetPage.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/resetPage.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/setQueryParameter.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/setQueryParameter.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/setQueryParameter.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/setQueryParameter.js diff --git a/packages/algoliasearch-helper/test/spec/SearchParameters/setQueryParameters.js b/packages/algoliasearch-helper/__tests__/spec/SearchParameters/setQueryParameters.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchParameters/setQueryParameters.js rename to packages/algoliasearch-helper/__tests__/spec/SearchParameters/setQueryParameters.js diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/getFacet.js b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacet.js similarity index 83% rename from packages/algoliasearch-helper/test/spec/SearchResults/getFacet.js rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacet.js index 7672523f70..7aa6088027 100644 --- a/packages/algoliasearch-helper/test/spec/SearchResults/getFacet.js +++ b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacet.js @@ -3,7 +3,8 @@ var SearchResults = require('../../../src/SearchResults'); test('getFacetByName should return a given facet be it disjunctive or conjunctive', function () { - var data = require('../../datasets/SearchParameters/search.dataset')(); + var data = + require('../../../test/datasets/SearchParameters/search.dataset')(); var result = new SearchResults(data.searchParams, data.response.results); diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/getFacetStats.js b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacetStats.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchResults/getFacetStats.js rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacetStats.js diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/getFacetValues-facetOrdering.js b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacetValues-facetOrdering.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchResults/getFacetValues-facetOrdering.js rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacetValues-facetOrdering.js diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/getFacetValues.js b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacetValues.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchResults/getFacetValues.js rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacetValues.js diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/getFacetValues/conjunctive.json b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacetValues/conjunctive.json similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchResults/getFacetValues/conjunctive.json rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacetValues/conjunctive.json diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/getFacetValues/disjunctive.json b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacetValues/disjunctive.json similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchResults/getFacetValues/disjunctive.json rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacetValues/disjunctive.json diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/getFacetValues/hierarchical.json b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacetValues/hierarchical.json similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchResults/getFacetValues/hierarchical.json rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacetValues/hierarchical.json diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/getFacetValues/noFilters.json b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacetValues/noFilters.json similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchResults/getFacetValues/noFilters.json rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacetValues/noFilters.json diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/getFacetValues/sparse.json b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacetValues/sparse.json similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchResults/getFacetValues/sparse.json rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/getFacetValues/sparse.json diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/getRefinements.js b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getRefinements.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchResults/getRefinements.js rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/getRefinements.js diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/getRefinements/conjunctive-brand-apple.json b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getRefinements/conjunctive-brand-apple.json similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchResults/getRefinements/conjunctive-brand-apple.json rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/getRefinements/conjunctive-brand-apple.json diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/getRefinements/disjunctive-type-trendcase.json b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getRefinements/disjunctive-type-trendcase.json similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchResults/getRefinements/disjunctive-type-trendcase.json rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/getRefinements/disjunctive-type-trendcase.json diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/getRefinements/dummy-tags.json b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getRefinements/dummy-tags.json similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchResults/getRefinements/dummy-tags.json rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/getRefinements/dummy-tags.json diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/getRefinements/exclude-apple.json b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getRefinements/exclude-apple.json similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchResults/getRefinements/exclude-apple.json rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/getRefinements/exclude-apple.json diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/getRefinements/exclude-artificial-results.json b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getRefinements/exclude-artificial-results.json similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchResults/getRefinements/exclude-artificial-results.json rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/getRefinements/exclude-artificial-results.json diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/getRefinements/hierarchical-cards.json b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getRefinements/hierarchical-cards.json similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchResults/getRefinements/hierarchical-cards.json rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/getRefinements/hierarchical-cards.json diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/getRefinements/noFilters.json b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getRefinements/noFilters.json similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchResults/getRefinements/noFilters.json rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/getRefinements/noFilters.json diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/getRefinements/numeric-rating-3.json b/packages/algoliasearch-helper/__tests__/spec/SearchResults/getRefinements/numeric-rating-3.json similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchResults/getRefinements/numeric-rating-3.json rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/getRefinements/numeric-rating-3.json diff --git a/packages/algoliasearch-helper/test/spec/SearchResults/initialization.js b/packages/algoliasearch-helper/__tests__/spec/SearchResults/initialization.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/SearchResults/initialization.js rename to packages/algoliasearch-helper/__tests__/spec/SearchResults/initialization.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/addFacetRefinement.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/addFacetRefinement.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/addFacetRefinement.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/addFacetRefinement.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/clears.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/clears.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/clears.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/clears.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/client.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/client.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/client.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/client.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/constructor.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/constructor.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/constructor.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/constructor.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/derive/detach.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/derive/detach.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/derive/detach.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/derive/detach.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/derive/empty-index.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/derive/empty-index.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/derive/empty-index.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/derive/empty-index.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/derive/events.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/derive/events.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/derive/events.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/derive/events.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/derive/multiqueries.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/derive/multiqueries.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/derive/multiqueries.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/derive/multiqueries.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/distinct.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/distinct.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/distinct.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/distinct.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/events.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/events.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/events.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/events.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/excludes.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/excludes.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/excludes.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/excludes.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/facetFilters.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/facetFilters.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/facetFilters.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/facetFilters.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/findAnswers.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/findAnswers.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/findAnswers.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/findAnswers.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/getNumericRefinement.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/getNumericRefinement.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/getNumericRefinement.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/getNumericRefinement.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/getQuery.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/getQuery.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/getQuery.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/getQuery.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/hasRefinements.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/hasRefinements.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/hasRefinements.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/hasRefinements.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/incorrectFacetDefinition.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/incorrectFacetDefinition.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/incorrectFacetDefinition.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/incorrectFacetDefinition.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/numericFilters.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/numericFilters.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/numericFilters.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/numericFilters.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/pages.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/pages.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/pages.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/pages.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/pendingSearch.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/pendingSearch.js similarity index 93% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/pendingSearch.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/pendingSearch.js index b6fdab9bc6..db187e935b 100644 --- a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/pendingSearch.js +++ b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/pendingSearch.js @@ -5,7 +5,8 @@ var algoliaSearch = require('algoliasearch'); var algoliasearchHelper = require('../../../index'); test('When searchOnce with callback, hasPendingRequests is true', function (done) { - var testData = require('../../datasets/SearchParameters/search.dataset')(); + var testData = + require('../../../test/datasets/SearchParameters/search.dataset')(); var client = algoliaSearch('dsf', 'dsfdf'); var triggerCb; @@ -38,7 +39,8 @@ test('When searchOnce with callback, hasPendingRequests is true', function (done }); test('When searchOnce with promises, hasPendingRequests is true', function (done) { - var testData = require('../../datasets/SearchParameters/search.dataset')(); + var testData = + require('../../../test/datasets/SearchParameters/search.dataset')(); var client = algoliaSearch('dsf', 'dsfdf'); var triggerCb; @@ -109,7 +111,8 @@ test('When searchForFacetValues, hasPendingRequests is true', function (done) { }); test('When helper.search(), hasPendingRequests is true', function (done) { - var testData = require('../../datasets/SearchParameters/search.dataset')(); + var testData = + require('../../../test/datasets/SearchParameters/search.dataset')(); var client = algoliaSearch('dsf', 'dsfdf'); var triggerCb; @@ -144,7 +147,8 @@ test('When helper.search(), hasPendingRequests is true', function (done) { }); test('When helper.search() and one request is discarded, hasPendingRequests is true unless all come back', function (done) { - var testData = require('../../datasets/SearchParameters/search.dataset')(); + var testData = + require('../../../test/datasets/SearchParameters/search.dataset')(); var client = algoliaSearch('dsf', 'dsfdf'); var triggerCbs = []; diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/queryID.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/queryID.js similarity index 95% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/queryID.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/queryID.js index 80fcbd5067..8c5ad491b0 100644 --- a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/queryID.js +++ b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/queryID.js @@ -22,7 +22,8 @@ test('the queryid should keep increasing when new requests arrives', function () }); test('the response handler should check that the query is not outdated', function (done) { - var testData = require('../../datasets/SearchParameters/search.dataset')(); + var testData = + require('../../../test/datasets/SearchParameters/search.dataset')(); var shouldTriggerResult = true; var callCount = 0; diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/searchForFacetValues.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/searchForFacetValues.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/searchForFacetValues.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/searchForFacetValues.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/searchOnce.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/searchOnce.js similarity index 97% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/searchOnce.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/searchOnce.js index 2481cd5591..cfe4f5429a 100644 --- a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/searchOnce.js +++ b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/searchOnce.js @@ -5,7 +5,8 @@ var SearchParameters = require('../../../src/SearchParameters'); var algoliasearchHelper = require('../../../index'); test('searchOnce should call the algolia client according to the number of refinements and call callback with no error and with results when no error', function (done) { - var testData = require('../../datasets/SearchParameters/search.dataset')(); + var testData = + require('../../../test/datasets/SearchParameters/search.dataset')(); var client = { search: jest.fn().mockImplementationOnce(function () { diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/setQueryParameter.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/setQueryParameter.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/setQueryParameter.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/setQueryParameter.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/state.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/state.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/state.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/state.js diff --git a/packages/algoliasearch-helper/test/spec/algoliasearch.helper/tags.js b/packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/tags.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/algoliasearch.helper/tags.js rename to packages/algoliasearch-helper/__tests__/spec/algoliasearch.helper/tags.js diff --git a/packages/algoliasearch-helper/test/spec/functions/compact.js b/packages/algoliasearch-helper/__tests__/spec/functions/compact.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/functions/compact.js rename to packages/algoliasearch-helper/__tests__/spec/functions/compact.js diff --git a/packages/algoliasearch-helper/test/spec/functions/defaultsPure.js b/packages/algoliasearch-helper/__tests__/spec/functions/defaultsPure.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/functions/defaultsPure.js rename to packages/algoliasearch-helper/__tests__/spec/functions/defaultsPure.js diff --git a/packages/algoliasearch-helper/test/spec/functions/find.js b/packages/algoliasearch-helper/__tests__/spec/functions/find.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/functions/find.js rename to packages/algoliasearch-helper/__tests__/spec/functions/find.js diff --git a/packages/algoliasearch-helper/test/spec/functions/findIndex.js b/packages/algoliasearch-helper/__tests__/spec/functions/findIndex.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/functions/findIndex.js rename to packages/algoliasearch-helper/__tests__/spec/functions/findIndex.js diff --git a/packages/algoliasearch-helper/test/spec/functions/formatSort.js b/packages/algoliasearch-helper/__tests__/spec/functions/formatSort.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/functions/formatSort.js rename to packages/algoliasearch-helper/__tests__/spec/functions/formatSort.js diff --git a/packages/algoliasearch-helper/test/spec/functions/intersection.js b/packages/algoliasearch-helper/__tests__/spec/functions/intersection.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/functions/intersection.js rename to packages/algoliasearch-helper/__tests__/spec/functions/intersection.js diff --git a/packages/algoliasearch-helper/test/spec/functions/merge.js b/packages/algoliasearch-helper/__tests__/spec/functions/merge.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/functions/merge.js rename to packages/algoliasearch-helper/__tests__/spec/functions/merge.js diff --git a/packages/algoliasearch-helper/test/spec/functions/orderBy.js b/packages/algoliasearch-helper/__tests__/spec/functions/orderBy.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/functions/orderBy.js rename to packages/algoliasearch-helper/__tests__/spec/functions/orderBy.js diff --git a/packages/algoliasearch-helper/test/spec/functions/valToNumber.js b/packages/algoliasearch-helper/__tests__/spec/functions/valToNumber.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/functions/valToNumber.js rename to packages/algoliasearch-helper/__tests__/spec/functions/valToNumber.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/add-remove.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/add-remove.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/add-remove.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/add-remove.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/attributes-order.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/attributes-order.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/attributes-order.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/attributes-order.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/breadcrumb.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/breadcrumb.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/breadcrumb.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/breadcrumb.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/custom-prefix-path.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/custom-prefix-path.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/custom-prefix-path.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/custom-prefix-path.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/custom-separator.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/custom-separator.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/custom-separator.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/custom-separator.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/do-not-show-parent-level.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/do-not-show-parent-level.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/do-not-show-parent-level.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/do-not-show-parent-level.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/facet-value-length.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/facet-value-length.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/facet-value-length.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/facet-value-length.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/getFacetValues.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/getFacetValues.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/getFacetValues.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/getFacetValues.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/no-refinement.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/no-refinement.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/no-refinement.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/no-refinement.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/no-trim.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/no-trim.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/no-trim.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/no-trim.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/objects-with-multiple-categories.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/objects-with-multiple-categories.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/objects-with-multiple-categories.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/objects-with-multiple-categories.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/one-level.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/one-level.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/one-level.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/one-level.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/pagination.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/pagination.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/pagination.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/pagination.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/parent-toggleRefine.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/parent-toggleRefine.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/parent-toggleRefine.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/parent-toggleRefine.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/refined-no-result.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/refined-no-result.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/refined-no-result.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/refined-no-result.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/show-parent-level.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/show-parent-level.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/show-parent-level.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/show-parent-level.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/simple-usage.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/simple-usage.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/simple-usage.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/simple-usage.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/sort-by.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/sort-by.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/sort-by.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/sort-by.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/two-facets.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/two-facets.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/two-facets.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/two-facets.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/unknown-facet.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/unknown-facet.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/unknown-facet.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/unknown-facet.js diff --git a/packages/algoliasearch-helper/test/spec/hierarchical-facets/with-a-disjunctive-facet.js b/packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/with-a-disjunctive-facet.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/hierarchical-facets/with-a-disjunctive-facet.js rename to packages/algoliasearch-helper/__tests__/spec/hierarchical-facets/with-a-disjunctive-facet.js diff --git a/packages/algoliasearch-helper/test/spec/refinements.js b/packages/algoliasearch-helper/__tests__/spec/refinements.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/refinements.js rename to packages/algoliasearch-helper/__tests__/spec/refinements.js diff --git a/packages/algoliasearch-helper/test/spec/requestBuilder.js b/packages/algoliasearch-helper/__tests__/spec/requestBuilder.js similarity index 95% rename from packages/algoliasearch-helper/test/spec/requestBuilder.js rename to packages/algoliasearch-helper/__tests__/spec/requestBuilder.js index 42f94ae76a..aa54360ac7 100644 --- a/packages/algoliasearch-helper/test/spec/requestBuilder.js +++ b/packages/algoliasearch-helper/__tests__/spec/requestBuilder.js @@ -5,7 +5,8 @@ var SearchParameters = require('../../src/SearchParameters'); var getQueries = requestBuilder._getQueries; test('The request builder should set analytics to subsequent queries', function () { - var testData = require('../datasets/SearchParameters/search.dataset')(); + var testData = + require('../../test/datasets/SearchParameters/search.dataset')(); var searchParams = testData.searchParams; searchParams.analytics = true; @@ -17,7 +18,8 @@ test('The request builder should set analytics to subsequent queries', function }); test('The request builder should set clickAnalytics to subsequent queries', function () { - var testData = require('../datasets/SearchParameters/search.dataset')(); + var testData = + require('../../test/datasets/SearchParameters/search.dataset')(); var searchParams = testData.searchParams; searchParams.clickAnalytics = true; @@ -29,7 +31,8 @@ test('The request builder should set clickAnalytics to subsequent queries', func }); test('The request builder should should force analytics to false on subsequent queries if not specified', function () { - var testData = require('../datasets/SearchParameters/search.dataset')(); + var testData = + require('../../test/datasets/SearchParameters/search.dataset')(); var searchParams = testData.searchParams; var queries = getQueries(searchParams.index, searchParams); @@ -39,7 +42,8 @@ test('The request builder should should force analytics to false on subsequent q }); test('The request builder should should force clickAnalytics to false on subsequent queries if not specified', function () { - var testData = require('../datasets/SearchParameters/search.dataset')(); + var testData = + require('../../test/datasets/SearchParameters/search.dataset')(); var searchParams = testData.searchParams; var queries = getQueries(searchParams.index, searchParams); diff --git a/packages/algoliasearch-helper/test/spec/search.js b/packages/algoliasearch-helper/__tests__/spec/search.js similarity index 95% rename from packages/algoliasearch-helper/test/spec/search.js rename to packages/algoliasearch-helper/__tests__/spec/search.js index 535f0df87a..1b2f626e79 100644 --- a/packages/algoliasearch-helper/test/spec/search.js +++ b/packages/algoliasearch-helper/__tests__/spec/search.js @@ -3,7 +3,8 @@ var algoliasearchHelper = require('../../index'); test('Search should call the algolia client according to the number of refinements', function (done) { - var testData = require('../datasets/SearchParameters/search.dataset')(); + var testData = + require('../../test/datasets/SearchParameters/search.dataset')(); var client = { search: jest.fn().mockImplementationOnce(function () { @@ -90,7 +91,8 @@ test('Search should call the algolia client according to the number of refinemen }); test('Search should not mutate the original client response', function (done) { - var testData = require('../datasets/SearchParameters/search.dataset')(); + var testData = + require('../../test/datasets/SearchParameters/search.dataset')(); var client = { search: jest.fn().mockImplementationOnce(function () { diff --git a/packages/algoliasearch-helper/test/spec/utils/isValidUserToken.js b/packages/algoliasearch-helper/__tests__/spec/utils/isValidUserToken.js similarity index 100% rename from packages/algoliasearch-helper/test/spec/utils/isValidUserToken.js rename to packages/algoliasearch-helper/__tests__/spec/utils/isValidUserToken.js diff --git a/packages/algoliasearch-helper/jest.config.js b/packages/algoliasearch-helper/jest.config.js deleted file mode 100644 index 9e932a4e9d..0000000000 --- a/packages/algoliasearch-helper/jest.config.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = { - testEnvironment: 'node', - testMatch: ['/test/spec/**/*.[jt]s?(x)'], - watchPlugins: [ - 'jest-watch-typeahead/filename', - 'jest-watch-typeahead/testname', - ], -}; diff --git a/packages/algoliasearch-helper/jest.setup.js b/packages/algoliasearch-helper/jest.setup.js deleted file mode 100644 index 26cf8e5a2c..0000000000 --- a/packages/algoliasearch-helper/jest.setup.js +++ /dev/null @@ -1,5 +0,0 @@ -/* eslint-env jest */ - -'use strict'; - -jest.setTimeout(20000); diff --git a/packages/algoliasearch-helper/package.json b/packages/algoliasearch-helper/package.json index c384da9af9..a5f6c2f294 100644 --- a/packages/algoliasearch-helper/package.json +++ b/packages/algoliasearch-helper/package.json @@ -9,10 +9,6 @@ "build": "./scripts/build.sh", "lint": "eslint .", "doc": "node documentation-src/metalsmith.js", - "test": "../../scripts/retry.sh 3 'scripts/test.sh'", - "test:unit": "jest", - "test:watch": "jest --watch", - "test:v3": "yarn run test", "version": "./scripts/update-version.js" }, "author": { diff --git a/packages/algoliasearch-helper/scripts/test.sh b/packages/algoliasearch-helper/scripts/test.sh deleted file mode 100755 index 01bd948cb3..0000000000 --- a/packages/algoliasearch-helper/scripts/test.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -e # exit when error - -[ -z $CIRCLE_BUILD_NUM ] && CI='false' || CI='true' - -if [ $CI == 'true' ]; then - set -x # debug messages -fi - -node test/run.js diff --git a/packages/algoliasearch-helper/test/integration-utils.js b/packages/algoliasearch-helper/test/integration-utils.js index e6dd4b7ce4..e34f6db772 100644 --- a/packages/algoliasearch-helper/test/integration-utils.js +++ b/packages/algoliasearch-helper/test/integration-utils.js @@ -6,6 +6,13 @@ function setup(indexName, fn) { var appID = process.env.INTEGRATION_TEST_APPID; var key = process.env.INTEGRATION_TEST_API_KEY; + if (!appID) { + throw new Error('Missing environment variable INTEGRATION_TEST_APPID'); + } + if (!key) { + throw new Error('Missing environment variable INTEGRATION_TEST_API_KEY'); + } + var client = algoliasearch(appID, key, { // all indexing requests must be done in https protocol: 'https:', diff --git a/packages/algoliasearch-helper/test/run.js b/packages/algoliasearch-helper/test/run.js deleted file mode 100644 index 2810e779d4..0000000000 --- a/packages/algoliasearch-helper/test/run.js +++ /dev/null @@ -1,52 +0,0 @@ -'use strict'; - -var path = require('path'); -var jest = require('jest'); -var algoliasearch = require('algoliasearch'); -var staticJestConfig = require('../jest.config'); - -var enableIntegrationTest = - process.env.ONLY_UNIT !== 'true' && - process.env.INTEGRATION_TEST_API_KEY && - process.env.INTEGRATION_TEST_APPID; - -var projectsRootPaths = [path.resolve(__dirname, '..')]; -var dynamicJestConfig = Object.assign({}, staticJestConfig, { - maxWorkers: 4, - setupFilesAfterEnv: staticJestConfig.setupFilesAfterEnv || [], -}); - -if (enableIntegrationTest) { - dynamicJestConfig.testMatch.push( - '/test/integration-spec/**/*.[jt]s?(x)' - ); - dynamicJestConfig.setupFilesAfterEnv.push( - path.resolve(__dirname, '..', 'jest.setup.js') - ); -} - -jest.runCLI(dynamicJestConfig, projectsRootPaths).then(function (response) { - if (!response.results.success) { - process.exitCode = response.globalConfig.testFailureExitCode; - } - - if (enableIntegrationTest) { - var client = algoliasearch( - process.env.INTEGRATION_TEST_APPID, - process.env.INTEGRATION_TEST_API_KEY - ); - client.deleteIndex = - client.deleteIndex || - function (deleteIndexName) { - return client.initIndex(deleteIndexName).delete(); - }; - client.listIndexes = client.listIndexes || client.listIndices; - - client.listIndexes().then((content) => { - content.items - .map((i) => i.name) - .filter((n) => n.indexOf('_circle-algoliasearch-helper') !== -1) - .forEach((n) => client.deleteIndex(n)); - }); - } -}); diff --git a/tests/utils/setupTests.ts b/tests/utils/setupTests.ts index fae3f1e249..c6cb4b0bdf 100644 --- a/tests/utils/setupTests.ts +++ b/tests/utils/setupTests.ts @@ -33,3 +33,12 @@ beforeEach(() => { if (isVue2) { Vue2.config.productionTip = false; } + +const enableIntegrationTest = + process.env.ONLY_UNIT !== 'true' && + process.env.INTEGRATION_TEST_API_KEY && + process.env.INTEGRATION_TEST_APPID; + +if (enableIntegrationTest) { + jest.setTimeout(20_000); +} diff --git a/tests/utils/teardownTests.ts b/tests/utils/teardownTests.ts new file mode 100644 index 0000000000..5f5993d97d --- /dev/null +++ b/tests/utils/teardownTests.ts @@ -0,0 +1,34 @@ +import algoliasearch from 'algoliasearch'; + +export default async function cleanup() { + const enableIntegrationTest = + process.env.ONLY_UNIT !== 'true' && + process.env.INTEGRATION_TEST_API_KEY && + process.env.INTEGRATION_TEST_APPID; + + if (enableIntegrationTest) { + // eslint-disable-next-line no-console + console.log('Cleaning up integration tests'); + + const client = algoliasearch( + process.env.INTEGRATION_TEST_APPID!, + process.env.INTEGRATION_TEST_API_KEY! + ); + + const deleteIndex = function deleteIndex(indexName: string) { + if ((client as any).deleteIndex) + return (client as any).deleteIndex(indexName); + return client.initIndex(indexName).delete(); + }; + + (client as any).listIndices = + client.listIndices || (client as any).listIndexes; + + await client.listIndices().then((content) => { + content.items + .map((i) => i.name) + .filter((n) => n.indexOf('_circle-algoliasearch-helper') !== -1) + .forEach((n) => deleteIndex(n)); + }); + } +}