The battle to keep covid-19 from becoming established in the United States is probably over without a single shot being fired. We were not outwitted, outpaced or outflanked. We knew what was coming. We just twiddled our thumbs as the coronavirus waltzed in.

The first thing officials need when responding to an infectious disease is a way to test for it — a way to tell who has it and who is at risk. Dozens of such test procedures have been produced in the scant weeks since covid-19 announced itself to the world by shutting down Wuhan, China, a city the size of New York. Public health agencies around the globe have generated huge amounts of data on how well these tests work and have rolled them out on a massive scale. South Korea alone has tested more than 100,000 of its citizens.

But the United States has lagged far behind the rest of the world in testing for the new coronavirus. As a result, outbreaks here are likely to be more numerous and more difficult to control than they would have been otherwise. I research infectious disease and how to fight it, so I know how important it is to detect outbreaks early. The covid-19 outbreak is the largest acute infectious-disease emergency most of us have experienced. And we may have let it go undetected here for too long.

For countries that are lucky enough so far to have been spared large covid-19 outbreaks, the way to handle the virus is simple: Strangle it at birth. If you detect it while there are still just a handful of cases, it is comparatively easy to chase down the contacts of the people who have it, isolate them quickly and halt transmission. If that fails, stopping transmission might take measures like the draconian restrictions imposed in China, which — while apparently successful — we should wish to avoid.

Once infection starts spreading — as it clearly has in the United States, even though we haven’t been testing enough people to turn up a large number of cases — the virus has an expanding pool of potential hosts. As the numbers of infected people climb, it is ever harder to stop them before they fatefully join their family for dinner, head to work at a toy store or go to a soccer match.

If you don’t diagnose the disease, it doesn’t go away. It keeps being transmitted without being noticed, and a thousand little fires spark. If we don’t start aggressively testing mild illness and contacts of contacts, we will lose all track of them. Bruce Aylward, leader of the joint World Health Organization China mission, put it bluntly: “It’s all about the speed.” We’re in a race with the virus, and if it wins, we only get more contacts to chase in an ever-growing chain reaction.

Most cases of the disease are mild, which makes it more likely to spread undetected without a good testing regime in place. But every infected person is at risk of being one of the unlucky fraction — 10 percent or so — whose symptoms are severe. Some of them will die. Some of them already have.

Testing for the virus is like turning on the light. If you don’t test, you cannot know where it is spreading. And if you don’t know where it is spreading, you cannot mount an effective response. How different countries affected by covid-19 have tested for it shows what can be done and the consequences of failure.

Singapore enjoys an exceptional capacity for high-quality investigation, partly a legacy of the 2003 SARS outbreak, which hit it hard. They take contact-tracing seriously there. The city-state was among the first international locations to report cases of covid-19 exported from Wuhan, the epicenter of the outbreak, but investigators went further. If you test only people connected to known cases, you are just one missed infection from losing track of the transmission chain.

Understanding this, in early February, Singapore authorities tested cases of respiratory disease that were negative for other viral pathogens, which meant they might have been the result of covid-19 transmission chains that had escaped detection. This aggressive testing almost immediately found four infections with no known contacts with other cases. Diligent contact tracing has managed to keep a lid on the outbreak, and, despite reporting its first case on Jan. 23, Singapore’s total as of Friday was only 130 cases, with no deaths (although seven people were in serious condition). This is a remarkable achievement.

The coronavirus has caused large outbreaks, severe disruption and significant numbers of deaths in China, Iran, Italy and South Korea. South Korea now has the highest number of cases outside China — more than 6,200. But this reflects high numbers of tests: As of Friday, officials there had conducted 164,740. Iran and Italy were both surprised by the sudden arrival of the virus in their communities. It’s not clear how much this was due to underreporting or wishful thinking by officials that it might go away, but in both cases, a lack of testing allowed the viru1s to spread unseen; gradually, then suddenly.

And yet as of late February, when the first case of covid-19 without links to known cases in the United States was detected in California, fewer than 500 tests had been conducted to detect transmission in this country. (By the end of this past week, testing had sped up, and more than 200 U.S. cases had been diagnosed, but the administration admitted that the country still doesn’t have enough tests to meet the expected demand.) Most worrying, some U.S. cases, like two reported Tuesday in King County, Wash., have only been detected retrospectively, after patients died. If the virus announces its presence only at the postmortem, that suggests the outbreak is already out of control.

Estimates suggest that about 1 in 50 people known to be infected die, so multiply the number of deaths by 50 to estimate the total cases. But that is not enough. It takes people quite a few weeks to die of covid-19, so when there’s a death, we have to go back to when that person was infected and ask how the outbreak grew since then. Current estimates say that it takes about a week for the number of cases to double, though there’s considerable uncertainty around the exact number. But if for each death, there were 49 other infections in the community when the patient who died became infected, then one week later, those cases would have grown to 98; after two weeks, to 196. If the patient dies three weeks after contracting covid-19, by that time, we would expect about 392 cases. That means for each dead body, a community already has hundreds of other cases, infected and infectious.

Explanations for this shortfall in basic outbreak response in the United States range from the bureaucratic (confusion among federal and state agencies) to the scientific (which test is the best?) and the economic (who pays?). While U.S. officials talk about how to fix things, South Korea has drive-through testing facilities. On Wednesday, the Centers for Disease Control and Prevention announced that coronavirus testing is now available for anyone, with a doctor’s approval, which is great news. But making test kits is one thing. Using them on patients requires trained professionals to deploy them. And even those professionals aren’t getting tested quickly enough to help slow the virus’s spread; I know of people right now, some of them front-line health-care workers (a group at particular risk for covid-19), who are sick and struggling to get tested.

Test early. Test often. Testing costs money, but this should be considered an investment in public health. A negative test result is just as important as a positive one.

We all know that the best way to fight covid-19 would have been to keep it out. But we left the door open and made little attempt to spot it as it tiptoed in and got established. It is hard to understand how this could have happened, but now the least we can do is prepare and mitigate the worst outcomes. The first step is turning on the lights.

Twitter: @BillHanage