Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

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

"Timed out while running tests" #2494

Closed
fregante opened this issue May 20, 2020 · 9 comments
Closed

"Timed out while running tests" #2494

fregante opened this issue May 20, 2020 · 9 comments

Comments

@fregante
Copy link

fregante commented May 20, 2020

I've been seeing more and more timeouts especially when running on GitHub Actions. I have very few and simple tests, so I'm not sure of why this times out so easily.

> @ ava /home/runner/work/refined-github/refined-github
> TS_NODE_FILES=true ava "--serial"

  ✖ Timed out while running tests

(node:3140) Warning: require() of ES modules is not supported.
require() of /home/runner/work/refined-github/refined-github/node_modules/select-dom/index.js from /home/runner/work/refined-github/refined-github/source/github-helpers/index.ts is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/runner/work/refined-github/refined-github/node_modules/select-dom/package.json.
  ✔ search-query.ts › .get
  ✔ search-query.ts › .getQueryParts
  ✔ search-query.ts › getQueryParts with spaces support
  ✔ search-query.ts › .set
  ✔ search-query.ts › .edit
  ✔ search-query.ts › .replace
  ✔ search-query.ts › .remove
  ✔ search-query.ts › .add
  ✔ search-query.ts › .includes
  ✔ search-query.ts › defaults

  9 tests passed
  1 known failure

  search-query.ts › getQueryParts with spaces support

Test file that times out: https://github.com/sindresorhus/refined-github/blob/master/test/helpers.ts
✅ Example run that completes: https://github.com/sindresorhus/refined-github/runs/695138978?check_suite_focus=true
❌ Example run that times out: https://github.com/sindresorhus/refined-github/runs/693030486?check_suite_focus=true

AVA 3.8.2
Node v12.16.3
{
	"ava": {
		"files": [
			"test/*.ts"
		],
		"extensions": [
			"ts"
		],
		"require": [
			"esm",
			"ts-node/register"
		]
	}
}
@novemberborn
Copy link
Member

You can configure a higher timeout value.

I'd also consider removing ts-node and compiling before you run tests. Then you can use @ava/typescript. This is what got does: https://github.com/sindresorhus/got/blob/a337dfdfc4151593044c8b729245308081a071be/package.json#L99-L103

(I'm closing this issue for housekeeping purposes, but let's keep the conversation going.)

@fregante
Copy link
Author

ts-node I think is easier to configure rather than pre-compilation for projects with a bundling step.

Without webpack, got can just add tests to tsconfig and it will just work.

With webpack, we'd have to configure a additional/separate run of tsc just to compile the tests folder.

Could the default timeout be configured to exclude ts-node or is that too difficult?

@novemberborn
Copy link
Member

Could the default timeout be configured to exclude ts-node or is that too difficult?

It's too difficult. It's a "lack of test progress" timer, but it doesn't know why there is no progress.

fregante added a commit to refined-github/refined-github that referenced this issue May 25, 2020
@fregante
Copy link
Author

fregante commented Jun 9, 2020

For the record, this is what a minimal build step looks like:

{
	"scripts": {
		"test": "rollup test/*.ts --plugin typescript --dir .built/test --chunkFileNames _.mjs --entryFileNames [name].mjs && ava"
	},
	"ava": {
		"files": [
			".built/test/*.mjs"
		]
	}
}

Not super elegant, but it works (refined-github/refined-github#3206) and also solves #2432

@ollyde
Copy link

ollyde commented May 27, 2021

Did you figure this out without pre-compiling? as we like to run with debugger :-D

@lovasoa
Copy link

lovasoa commented May 31, 2021

Did someone find a solution or a workaround for this issue ?

@ollyde
Copy link

ollyde commented May 31, 2021

@lovasoa for our Windows developers they had to increase the timeout to 5m in the AVA config. Also; if the test has any errors in TS it will show this message; check your tests.

@sculpt0r
Copy link
Contributor

sculpt0r commented May 23, 2022

Sorry for raising this topic after such a long time, but I've just started receiving more and more timed out. TBH It is rare to run proper tests... My config:

process.env.TS_NODE_PROJECT = './tsconfig.test.json';

module.exports = {
	failWithoutAssertions: false,
	extensions: [ 'js', 'ts' ],
	files: [ './src/**/tests/**/*.ts', '!./src/**/tests/_utils/**/*.ts' ],
	require: [ 'ts-node/register', 'source-map-support/register' ]
};

I'm not sure what else I could add here - because there is no errors in the console, only
image

Increasing the timeout in config or in the single test does not help at all...

It looks like the async tests cause this trouble: test( '', async t => {} ): Running a single test without async works fine - and the results seem to appear exactly at the moment when the Timed out appears in async test 🤔

AVA: 4.2.0
Node: Tried various: 16.11.0. 16.15.0, 17.9.0, 18.2.0
OS: MacOS 12.2.1

@novemberborn
Copy link
Member

@sculpt0r would you mind creating a separate discussion for this?

@avajs avajs locked as resolved and limited conversation to collaborators May 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants